Skip to content

Commit 232bb48

Browse files
authored
feat: add coverage to github ci (#1920)
1 parent 4d488b7 commit 232bb48

File tree

6 files changed

+971
-1261
lines changed

6 files changed

+971
-1261
lines changed

.github/workflows/coverage.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: 'coverage'
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
7+
jobs:
8+
coverage:
9+
if: ${{ github.actor != 'dependabot[bot]' }}
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout PR branch
13+
uses: actions/checkout@v4
14+
15+
- name: Install Node
16+
run: |
17+
export NVM_DIR="$HOME/.nvm"
18+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
19+
nvm install
20+
nvm use
21+
node -v
22+
npm install
23+
24+
- name: Install gucci
25+
run: |
26+
GUCCI_VERSION="1.6.13"
27+
curl -L -o gucci https://github.com/noqcks/gucci/releases/download/v${GUCCI_VERSION}/gucci-v${GUCCI_VERSION}-linux-amd64
28+
chmod +x gucci
29+
sudo mv gucci /usr/local/bin/
30+
31+
- name: Compare Coverage
32+
uses: ArtiomTr/jest-coverage-report-action@v2
33+
with:
34+
test-script: npm run test:ts

.husky/post-checkout

+6-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ source_nvm
2323
# automatically change node version to the one indicated in .nvmrc
2424
nvm use
2525

26-
npm run run-if-changed
26+
# Prevent errors on shallow clones
27+
if git rev-parse --verify HEAD@{1} >/dev/null 2>&1; then
28+
npm run run-if-changed
29+
else
30+
echo "Skipping run-if-changed: Not enough Git history"
31+
fi

jest.config.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
import type { Config } from '@jest/types'
22

3-
// Sync object
43
const config: Config.InitialOptions = {
5-
// automock: true,
64
preset: 'ts-jest',
75
roots: ['<rootDir>/src'],
86
setupFilesAfterEnv: ['<rootDir>/src/test-init.ts'],
97
moduleDirectories: ['node_modules', __dirname],
108
modulePathIgnorePatterns: ['src/cmd/test.ts'],
119
testEnvironment: 'node',
12-
globals: {
13-
'ts-jest': {
14-
compiler: 'ttypescript',
15-
tsconfig: 'tsconfig.jest.json',
16-
},
10+
transform: {
11+
'^.+.tsx?$': ['ts-jest', { compiler: 'ttypescript', tsconfig: 'tsconfig.jest.json' }],
1712
},
1813
silent: false,
1914
testMatch: ['**/*.test.ts'],

0 commit comments

Comments
 (0)