Skip to content

Commit

Permalink
ci(workflows): upload coverage reports to codecov
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <[email protected]>
  • Loading branch information
unicornware committed Dec 16, 2022
1 parent 6482dd9 commit 9814979
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 11 deletions.
114 changes: 114 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# CODECOV CONFIGURATION
# https://docs.codecov.com/docs/codecovyml-reference

---
codecov:
notify:
after_n_builds: 4
wait_for_ci: true
require_ci_to_pass: true

comment:
after_n_builds: 4
behavior: default
layout: header,diff,files,components,footer
require_base: false
require_changes: false
require_head: true
show_critical_paths: true

component_management:
default_rules:
statuses:
- type: project
target: 100%
individual_components:
- component_id: internal
name: internal
paths:
- src/internal/
- component_id: lib
name: lib
paths:
- src/lib/
- component_id: utils
name: utils
paths:
- src/utils/

coverage:
precision: 2
range: 90..100
round: nearest
status:
changes:
default:
branches:
- feat/*
- hotfix/*
- main
- release/*
if_ci_failed: error
if_not_found: success
informational: false
only_pulls: false
patch:
default:
branches:
- feat/*
- hotfix/*
- main
- release/*
if_ci_failed: error
if_not_found: success
informational: false
only_pulls: false
target: 100%
threshold: 0%
project:
default:
branches:
- feat/*
- hotfix/*
- main
- release/*
if_ci_failed: error
if_not_found: success
informational: false
only_pulls: false
target: 100%
threshold: 0%

flags:
node19:
carryforward: false
paths:
- src/
node18:
carryforward: false
paths:
- src/
node16:
carryforward: false
paths:
- src/
node14:
carryforward: false
paths:
- src/

github_checks:
annotations: true

ignore:
- '**/__mocks__/**'
- '**/__tests__/**'
- '**/index.ts'
- src/interfaces/
- src/pathe.ts
- src/types/

profiling:
critical_files_paths:
- src/lib/
- src/utils/
22 changes: 12 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
# References:
#
# - https://docs.github.com/actions/automating-builds-and-tests/building-and-testing-nodejs
# - https://docs.github.com/actions/learn-github-actions/contexts
# - https://docs.github.com/actions/using-jobs/using-a-matrix-for-your-jobs
# - https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#pull_request
# - https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#push
# - https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
# - https://github.com/actions/checkout
# - https://github.com/actions/upload-artifact
# - https://github.com/codecov/codecov-action
# - https://github.com/hmarr/debug-action

---
Expand Down Expand Up @@ -86,20 +88,20 @@ jobs:
- id: package-version
name: Get package version
run: echo "result=$(jq .version package.json -r)" >> $GITHUB_OUTPUT
- id: test-archive
name: Archive code coverage results
uses: actions/[email protected]
with:
name: |
${{ format('@{0}-{1}-{2}-coverage', github.repository_owner, github.event.repository.name, steps.package-version.outputs.result) }}
path: |
coverage
!coverage/tmp/
!coverage/lcov.info
- id: package-archive
name: Archive production artifacts
uses: actions/[email protected]
with:
name: |
${{ format('@{0}-{1}-{2}', github.repository_owner, github.event.repository.name, steps.package-version.outputs.result) }}
path: '*.tgz'
- id: codecov
name: Upload coverage report to Codecov
uses: codecov/[email protected]
with:
fail_ci_if_error: true
file: ./coverage/lcov.info
flags: ${{ format('node{0}', matrix.node-version) }}
override_build: ${{ github.run_id }}
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"clean:pack": "trash ./*.tgz",
"clean:test": "yarn clean:coverage && trash ./__tests__/report.json",
"codecov": "yarn test:cov && yarn test:cov:upload",
"codecov:validate": "cat .codecov.yml | curl --data-binary @- https://codecov.io/validate",
"conventional-changelog": "node --loader=./loader.mjs ./node_modules/.bin/conventional-changelog -n ./changelog.config.cts",
"fix:cg": "yarn fix:format && yarn fix:lint",
"fix:dedupe": "yarn dedupe --strategy=highest",
Expand Down
2 changes: 1 addition & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const config: UserConfigExport = defineConfig((): UserConfig => {
],
extension: ['.ts'],
include: ['src'],
reporter: ['json-summary', 'lcov', 'text'],
reporter: [ci ? 'lcovonly' : 'lcov', 'text'],
reportsDirectory: './coverage',
skipFull: false
},
Expand Down

0 comments on commit 9814979

Please sign in to comment.