Skip to content

Commit

Permalink
Merge pull request #15 from grafana/add-ci-remove-old-test-files
Browse files Browse the repository at this point in the history
  • Loading branch information
sd2k authored Jun 11, 2024
2 parents ed834be + 3257547 commit d92cdd0
Show file tree
Hide file tree
Showing 15 changed files with 191 additions and 588 deletions.
20 changes: 20 additions & 0 deletions .autorc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"author": {
"name": "grafanabot",
"email": "[email protected]"
},
"onlyPublishWithReleaseLabel": true,
"plugins": [
[
"npm",
{}
],
"released",
[
"omit-commits",
{
"labels": "no-changelog"
}
]
]
}
105 changes: 105 additions & 0 deletions .github/actions/yarn-nm-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
########################################################################################
# "yarn install" composite action for yarn 3/4+ and "nodeLinker: node-modules" #
#--------------------------------------------------------------------------------------#
# Requirement: @setup/node should be run before #
# #
# Usage in workflows steps: #
# #
# - name: Yarn install #
# uses: ./.github/actions/yarn-nm-install #
# with: #
# cwd: ${{ github.workspace }}/apps/my-app # (default = '.') #
# cache-node-modules: false # (default = 'false') #
# cache-install-state: false # (default = 'false') #
# #
# Reference: #
# - latest: https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a #
# #
########################################################################################

name: 'Yarn install'
description: 'Run yarn install with node_modules linker and cache enabled'
inputs:
cwd:
description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()"
required: false
default: '.'
cache-npm-cache:
description: 'Cache npm global cache folder often used by node-gyp, prebuild binaries (invalidated on lock/os/node-version)'
required: false
default: 'true'
cache-node-modules:
description: 'Cache node_modules, might speed up link step (invalidated lock/os/node-version/branch)'
required: false
default: 'true'
cache-install-state:
description: 'Cache yarn install state, might speed up resolution step when node-modules cache is activated (invalidated lock/os/node-version/branch)'
required: false
default: 'true'

runs:
using: 'composite'
steps:
- name: Enable Corepack
shell: bash
working-directory: ${{ inputs.cwd }}
run: corepack enable

- name: Expose yarn config as "$GITHUB_OUTPUT"
id: yarn-config
shell: bash
working-directory: ${{ inputs.cwd }}
env:
YARN_ENABLE_GLOBAL_CACHE: 'false'
run: |
echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
echo "CURRENT_NODE_VERSION="node-$(node --version)"" >> $GITHUB_OUTPUT
echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's,/,-,g')" >> $GITHUB_OUTPUT
echo "NPM_GLOBAL_CACHE_FOLDER=$(npm config get cache)" >> $GITHUB_OUTPUT
- name: Restore yarn cache
uses: actions/cache@v3
id: yarn-download-cache
with:
path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }}
key: yarn-download-cache-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }}
restore-keys: |
yarn-download-cache-
- name: Restore node_modules
if: inputs.cache-node-modules == 'true'
id: yarn-nm-cache
uses: actions/cache@v3
with:
path: ${{ inputs.cwd }}/**/node_modules
key: yarn-nm-cache-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }}

- name: ♻️ Restore global npm cache folder
if: inputs.cache-npm-cache == 'true'
id: npm-global-cache
uses: actions/cache@v3
with:
path: ${{ steps.yarn-config.outputs.NPM_GLOBAL_CACHE_FOLDER }}
key: npm-global-cache-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }}

- name: Restore yarn install state
if: inputs.cache-install-state == 'true' && inputs.cache-node-modules == 'true'
id: yarn-install-state-cache
uses: actions/cache@v3
with:
path: ${{ inputs.cwd }}/.yarn/ci-cache
key: yarn-install-state-cache-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }}

- name: Install dependencies
shell: bash
working-directory: ${{ inputs.cwd }}
run: |
yarn install --immutable --inline-builds
env:
# Overrides/align yarnrc.yml options (v3, v4) for a CI context
YARN_ENABLE_GLOBAL_CACHE: 'false' # Use local cache folder to keep downloaded archives
YARN_ENABLE_MIRROR: 'false' # Prevent populating global cache for caches misses (local cache only)
YARN_NM_MODE: 'hardlinks-local' # Reduce node_modules size
YARN_INSTALL_STATE_PATH: '.yarn/ci-cache/install-state.gz' # Might speed up resolution step when node_modules present
# Other environment variables
HUSKY: '0' # By default do not run HUSKY install
63 changes: 63 additions & 0 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Node CI

on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened]

jobs:
test:
name: Run tests
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
steps:
- uses: actions/checkout@v4

- name: Test using Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
uses: ./.github/actions/yarn-nm-install

- name: Test library
run: yarn test --scope '@grafana/scenes-ml'

- name: Typecheck library
run: yarn typecheck --scope '@grafana/scenes-ml'

- name: Build library
run: yarn build --scope '@grafana/scenes-ml'

release:
name: Release
runs-on: ubuntu-latest
needs: test
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_ADMIN_TOKEN }}

- name: Prepare repository
run: git fetch --unshallow --tags

- name: Test using Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
uses: ./.github/actions/yarn-nm-install

- name: Build library
run: yarn run lerna run build --no-private

- name: Run auto shipit
run: yarn auto shipit
env:
GITHUB_TOKEN: ${{ secrets.GH_ADMIN_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"test:lib": "lerna run test --scope '@grafana/scenes-ml' --",
"dev:lib": "lerna run dev --scope '@grafana/scenes-ml' --",
"dev:app": "lerna run dev --scope 'scenes-ml-app' --",
"test": "lerna run test --scope '@grafana/scenes-ml' -- --watch",
"test": "lerna run test --scope '@grafana/scenes-ml'",
"typecheck": "lerna run typecheck --scope @grafana/scenes-ml"
},
"resolutions": {
Expand Down
2 changes: 1 addition & 1 deletion packages/scenes-ml-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build": "webpack -c ./webpack.config.ts --env production",
"dev": "webpack -w -c ./webpack.config.ts --env development",
"e2e": "yarn exec cypress install && yarn exec grafana-e2e run",
"test": "jest --watch --onlyChanged",
"test": "jest --passWithNoTests",
"test:ci": "jest --passWithNoTests --maxWorkers 4",
"typecheck": "tsc --noEmit",
"lint": "eslint --cache --ignore-path ./.gitignore --ext .js,.jsx,.ts,.tsx .",
Expand Down
2 changes: 1 addition & 1 deletion packages/scenes-ml/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"build:dev": "yarn build --environment NODE_ENV:development",
"clean": "rimraf ./dist ./compiled ./package.tgz",
"typecheck": "tsc --emitDeclarationOnly false --noEmit",
"test": "jest",
"test": "jest --passWithNoTests",
"lint": "eslint --ignore-path ../../.gitignore . --ext .js,.tsx,.ts --cache",
"prepack": "node ./scripts/prepack.js",
"postpack": "node ./scripts/postpack.js"
Expand Down
4 changes: 0 additions & 4 deletions packages/scenes-ml/utils/setupTests.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import '@testing-library/jest-dom';
import { TextEncoder, TextDecoder } from 'util';

import { matchers } from './test';

Object.assign(global, { TextDecoder, TextEncoder });

Object.defineProperty(global, 'matchMedia', {
Expand All @@ -28,5 +26,3 @@ global.IntersectionObserver = jest.fn(() => ({
rootMargin: '',
thresholds: [],
}));

expect.extend(matchers);
35 changes: 0 additions & 35 deletions packages/scenes-ml/utils/test/__mocks__/pluginMocks.ts

This file was deleted.

7 changes: 0 additions & 7 deletions packages/scenes-ml/utils/test/index.ts

This file was deleted.

Loading

0 comments on commit d92cdd0

Please sign in to comment.