Skip to content

Commit

Permalink
code coverage (#16)
Browse files Browse the repository at this point in the history
- code coverage in PRs
  • Loading branch information
maddin1502 authored Apr 13, 2024
1 parent 8e83255 commit b903b58
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 6 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/build-validation-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Collect test coverage
on:
pull_request:
branches:
- main

jobs:
get-coverage:
runs-on: ubuntu-latest
strategy:
matrix:
branch:
- ${{ github.head_ref }}
- "main"

permissions:
# Required to checkout the code
contents: read

steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install Deps
run: npm install
- name: Test
run: npm run test:coverage
- name: Generate upload artifact name
run: |
name=$(echo -n "${{ matrix.branch }}" | sed -e 's/[ \t:\/\\"<>|*?]/-/g' -e 's/--*/-/g')
echo "ARTIFACT_NAME_UPLOAD=$name" >> $GITHUB_ENV
- name: Upload Coverage
uses: actions/upload-artifact@v4
with:
name: coverage-${{ env.ARTIFACT_NAME_UPLOAD }}
path: tests/reports/coverage

report-coverage:
needs: get-coverage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Generate download artifact name
run: |
name=$(echo -n "${{ github.head_ref }}" | sed -e 's/[ \t:\/\\"<>|*?]/-/g' -e 's/--*/-/g')
echo "ARTIFACT_NAME_DOWNLOAD=$name" >> $GITHUB_ENV
- name: Download Coverage Artifacts
uses: actions/download-artifact@v4
with:
name: coverage-${{ env.ARTIFACT_NAME_DOWNLOAD }}
path: coverage
- uses: actions/download-artifact@v4
with:
name: coverage-main
path: coverage-main
- name: Report Coverage
uses: davelosert/vitest-coverage-report-action@v2
with:
json-summary-compare-path: coverage-main/coverage-summary.json
file-coverage-mode: all
2 changes: 2 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ jobs:
run: npm i
- name: Validate (build, test)
run: npm run build:validate
- name: Publish package
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
13 changes: 13 additions & 0 deletions tests/code/types.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import '@/array.js';
import '@/constructor.js';
import '@/dictionary.js';
import '@/emptyObject.js';
import '@/event/types.js';
import '@/mapping.js';
import { describe, expect, test } from 'vitest';

describe('dummy types test', () => {
test('dummy', () => {
expect(true).toBe(true);
});
});
12 changes: 6 additions & 6 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export default defineConfig({
clean: true,
cleanOnRerun: true,
reportOnFailure: true,
// thresholds: {
// lines: 90,
// branches: 90,
// functions: 90,
// statements: 90
// }
thresholds: {
lines: 90,
branches: 90,
functions: 90,
statements: 90
}
},
reporters: ['default', 'junit'],
dir: './tests',
Expand Down

0 comments on commit b903b58

Please sign in to comment.