Skip to content

Commit

Permalink
update ci to collect coverage (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
guplersaxanoid authored May 21, 2023
1 parent 5851a72 commit d5aa9cf
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 17 deletions.
46 changes: 40 additions & 6 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,60 @@ on:
paths-ignore:
- '.github/workflows/**'
jobs:
pr:
name: pr
code-style:
name: code-style
runs-on: ubuntu-latest
env:
SUBQL_ACCESS_TOKEN: ${{ secrets.SUBQL_ACCESS_TOKEN }}
SUBQL_ACCESS_TOKEN_TEST: ${{ secrets.SUBQL_ACCESS_TOKEN_TEST }}
SUBQL_ORG_TEST: ${{ secrets.SUBQL_ORG_TEST }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup Node.js environment
uses: actions/setup-node@v2
with:
node-version: 18
node-version: 16
- run: yarn
- name: build
run: yarn build
- name: code-style check
run: yarn pretty-quick --check --pattern 'packages/*/src/**/*' --branch origin/main
- name: lint
run: yarn lint
- name: test
run: yarn test:docker

coverage:
name: Coverage report
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
DB_USER: postgres
DB_PASS: postgres
DB_DATABASE: postgres
DB_HOST: postgres
DB_PORT: 5432
steps:
- uses: actions/checkout@v3

- name: Use Node 16
uses: actions/setup-node@v2
with:
node-version: 16

- name: Installing dependencies
run: yarn install

- uses: artiomtr/jest-coverage-report-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
skip-step: install
working-directory: ${{ matrix.path }}
test-script: yarn test-jest
14 changes: 3 additions & 11 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ module.exports = {

// An array of glob patterns indicating a set of files for which coverage information should be collected
collectCoverageFrom: [
'packages/cli/src/**/*.ts',
'packages/common/src/**/*.ts',
'packages/common-substrate/src/**/*.ts',
'packages/node-core/src/**/*.ts',
'packages/common-near/src/**/*.ts',
'packages/node/src/**/*.ts',
'packages/utils/src/**/*.ts',
'packages/validator/src/**/*.ts',
],

// The directory where Jest should output its coverage files
Expand Down Expand Up @@ -90,11 +85,8 @@ module.exports = {
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
// moduleNameMapper: {},
moduleNameMapper: {
'^@subql/common-substrate/(.*)$': '<rootDir>/packages/common-substrate/src/$1',
'^@subql/common/(.*)$': '<rootDir>/packages/common/src/$1',
'^@subql/node-core/(.*)$': '<rootDir>/packages/node-core/src/$1',
'^@subql/utils/(.*)$': '<rootDir>/packages/utils/src/$1',
'^@subql/node-core/logger': '<rootDir>/packages/node-core/logger',
'@subql/common-near': '<rootDir>/packages/common-near/src',
'@subql/types-near': '<rootDir>/packages/types/src',
},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"test": "jest --coverage",
"test:all": "node --expose-gc ./node_modules/.bin/jest --logHeapUsage --testRegex='.*\\.(spec|test)\\.ts$' --forceExit --ci -w=2 --clearMocks",
"test:docker": "docker-compose -f test/docker-compose.yaml up --remove-orphans --abort-on-container-exit --build test",
"test-jest": "jest --testRegex='.*\\.(spec|test)\\.ts$'",
"postinstall": "husky install"
},
"lint-staged": {
Expand Down

0 comments on commit d5aa9cf

Please sign in to comment.