Skip to content

Commit

Permalink
chore(ci): add code coverage support
Browse files Browse the repository at this point in the history
  • Loading branch information
evansims committed Apr 4, 2024
1 parent 7676cc6 commit 6f96c64
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 20 deletions.
4 changes: 4 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage:
precision: 2
range: "60...80"
round: down
33 changes: 20 additions & 13 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ jobs:
node-version: [14.x, 16.x, 18.x, 20.x]

steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0

- name: Set up node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
scope: '@openfga'
registry-url: "https://registry.npmjs.org"
scope: "@openfga"
always-auth: false
cache: 'npm'
cache: "npm"

- name: Install dependencies
run: npm ci
Expand All @@ -41,15 +41,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0

- name: Set up node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: '20'
cache: 'npm'
node-version: "20"
cache: "npm"

- name: Install dependencies
run: npm ci
Expand All @@ -63,6 +63,13 @@ jobs:
- name: Run tests
run: npm test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@c16abc29c95fcf9174b58eb7e1abf4c866893bc8 # v4.1.1
continue-on-error: true
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: openfga/js-sdk

publish:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
Expand All @@ -72,18 +79,18 @@ jobs:
id-token: write

steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0

- name: Set up node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
scope: '@openfga'
node-version: "20"
registry-url: "https://registry.npmjs.org"
scope: "@openfga"
always-auth: false
cache: 'npm'
cache: "npm"

- name: Install dependencies
run: npm ci
Expand All @@ -101,7 +108,7 @@ jobs:
contents: write

steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0

Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/semgrep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
image: returntocorp/semgrep
if: (github.actor != 'dependabot[bot]' && github.actor != 'snyk-bot')
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
fetch-depth: 0
- run: semgrep ci --no-suppress-errors
env:
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- run: semgrep ci --no-suppress-errors
env:
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
1 change: 1 addition & 0 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.codecov.yml
.eslintignore
.eslintrc.js
.fossa.yml
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"scripts": {
"build": "tsc --outDir dist/",
"prepublishOnly": "rm -rf dist/ && npm run build",
"test": "jest --config ./tests/jest.config.js",
"test": "jest --coverage --config ./tests/jest.config.js",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix"
},
Expand Down
2 changes: 2 additions & 0 deletions tests/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module.exports = {
collectCoverage: true,
coverageReporters: ['text', 'cobertura'],
testEnvironment: "node",
preset: "ts-jest",
coveragePathIgnorePatterns: ["/node_modules/", "/tests/"],
Expand Down

0 comments on commit 6f96c64

Please sign in to comment.