Skip to content

Commit dc6a39c

Browse files
authored
chore(ci): add code coverage support (#83)
2 parents ab77704 + a3b2a98 commit dc6a39c

File tree

6 files changed

+34
-20
lines changed

6 files changed

+34
-20
lines changed

.codecov.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
coverage:
2+
precision: 2
3+
range: "60...80"
4+
round: down

.github/workflows/main.yaml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ jobs:
1818
node-version: [14.x, 16.x, 18.x, 20.x]
1919

2020
steps:
21-
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
21+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2222
with:
2323
fetch-depth: 0
2424

2525
- name: Set up node
2626
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
2727
with:
2828
node-version: ${{ matrix.node-version }}
29-
registry-url: 'https://registry.npmjs.org'
30-
scope: '@openfga'
29+
registry-url: "https://registry.npmjs.org"
30+
scope: "@openfga"
3131
always-auth: false
32-
cache: 'npm'
32+
cache: "npm"
3333

3434
- name: Install dependencies
3535
run: npm ci
@@ -41,15 +41,15 @@ jobs:
4141
runs-on: ubuntu-latest
4242

4343
steps:
44-
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
44+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
4545
with:
4646
fetch-depth: 0
4747

4848
- name: Set up node
4949
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
5050
with:
51-
node-version: '20'
52-
cache: 'npm'
51+
node-version: "20"
52+
cache: "npm"
5353

5454
- name: Install dependencies
5555
run: npm ci
@@ -63,6 +63,13 @@ jobs:
6363
- name: Run tests
6464
run: npm test
6565

66+
- name: Upload coverage to Codecov
67+
uses: codecov/codecov-action@c16abc29c95fcf9174b58eb7e1abf4c866893bc8 # v4.1.1
68+
continue-on-error: true
69+
with:
70+
token: ${{ secrets.CODECOV_TOKEN }}
71+
slug: openfga/js-sdk
72+
6673
publish:
6774
runs-on: ubuntu-latest
6875
if: startsWith(github.ref, 'refs/tags/v')
@@ -72,18 +79,18 @@ jobs:
7279
id-token: write
7380

7481
steps:
75-
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
82+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
7683
with:
7784
fetch-depth: 0
7885

7986
- name: Set up node
8087
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
8188
with:
82-
node-version: '20'
83-
registry-url: 'https://registry.npmjs.org'
84-
scope: '@openfga'
89+
node-version: "20"
90+
registry-url: "https://registry.npmjs.org"
91+
scope: "@openfga"
8592
always-auth: false
86-
cache: 'npm'
93+
cache: "npm"
8794

8895
- name: Install dependencies
8996
run: npm ci
@@ -101,7 +108,7 @@ jobs:
101108
contents: write
102109

103110
steps:
104-
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
111+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
105112
with:
106113
fetch-depth: 0
107114

.github/workflows/semgrep.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ jobs:
1111
image: returntocorp/semgrep
1212
if: (github.actor != 'dependabot[bot]' && github.actor != 'snyk-bot')
1313
steps:
14-
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
15-
with:
16-
fetch-depth: 0
17-
- run: semgrep ci --no-suppress-errors
18-
env:
19-
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
14+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
15+
with:
16+
fetch-depth: 0
17+
- run: semgrep ci --no-suppress-errors
18+
env:
19+
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}

.openapi-generator/FILES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.codecov.yml
12
.eslintignore
23
.eslintrc.js
34
.fossa.yml

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"scripts": {
1818
"build": "tsc --outDir dist/",
1919
"prepublishOnly": "rm -rf dist/ && npm run build",
20-
"test": "jest --config ./tests/jest.config.js",
20+
"test": "jest --coverage --config ./tests/jest.config.js",
2121
"lint": "eslint . --ext .ts",
2222
"lint:fix": "eslint . --ext .ts --fix"
2323
},

tests/jest.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
module.exports = {
2+
collectCoverage: true,
3+
coverageReporters: ['text', 'cobertura'],
24
testEnvironment: "node",
35
preset: "ts-jest",
46
coveragePathIgnorePatterns: ["/node_modules/", "/tests/"],

0 commit comments

Comments
 (0)