Skip to content

Commit

Permalink
ci: improve js tests/lint speed (grafana#1266)
Browse files Browse the repository at this point in the history
* ci: don't run build and set max-workers
  • Loading branch information
eh-am authored Jul 15, 2022
1 parent 51feb74 commit 0cd7437
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 21 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/lint-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: JS Lint

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
js-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn
- name: Install Webapp dependencies
run: yarn install
- run: yarn build
- name: Run Format check
run: yarn format:check
- name: Run Lint
# Use use --quiet so that it only report errors
run: yarn lint:quiet

- name: Run Type check
run: yarn type-check
22 changes: 5 additions & 17 deletions .github/workflows/tests-js.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: JS Tests/Lint/Type-check
name: JS Tests

on:
push:
Expand Down Expand Up @@ -27,27 +27,15 @@ jobs:
- name: Install Webapp dependencies
run: yarn install

# build the application before testing
# otherwise it won't be able to resolve dependencies
- name: build
run: yarn build

- name: Get number of CPU cores
id: cpu-cores
uses: SimenB/github-actions-cpu-cores@v1
- name: Run Webapp tests
run: yarn run test --coverage
run: yarn run test --coverage --max-workers ${{ steps.cpu-cores.outputs.count }}
- name: Upload codecov coverage
if: always()
uses: codecov/codecov-action@v1
with:
name: js coverage
fail_ci_if_error: false
verbose: true

- name: Run Lint
# Use use --quiet so that it only report errors
run: yarn lint:quiet
- name: Run Format check
run: yarn format:check

- name: Run Type check
run: yarn type-check
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:standalone": "webpack --config scripts/webpack/webpack.standalone.ts",
"build:size-limit": "NODE_ENV=production webpack --config scripts/webpack/webpack.size-limit.ts",
"build:flamegraph": "lerna run build --scope=@pyroscope/flamegraph",
"test": "jest --runInBand",
"test": "jest",
"test:ss": "UPDATE_SNAPSHOTS=true ./scripts/jest-snapshots/run-docker.sh",
"test:ss-check": "./scripts/jest-snapshots/run-docker.sh",
"lint": "lerna run lint --parallel --no-bail",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { Maybe } from 'true-myth';
import type { Units } from '@pyroscope/models';
import type { Units } from '@pyroscope/models/src';

import { diffColorRed, diffColorGreen } from './color';
import Tooltip, { TooltipProps } from './Tooltip';
Expand Down
3 changes: 1 addition & 2 deletions scripts/jest-snapshots/run-snapshots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ fi
# error [email protected]: The engine "node" is incompatible with this module. Expected version "^16 || ^15 || ^14 || ^13 || ^12 || ^11 || ^10 || ^9 || ^8 || ^7 || ^6". Got "17.0.1"
# error Found incompatible module.
yarn install --ignore-engines
yarn build
RUN_SNAPSHOTS=true yarn test --testNamePattern='group:snapshot' --verbose "$updateArg"
RUN_SNAPSHOTS=true yarn test --testNamePattern='group:snapshot' --verbose "$updateArg" --runInBand

0 comments on commit 0cd7437

Please sign in to comment.