Skip to content

Commit

Permalink
chore: Upload coverage using GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
manferlo81 committed Nov 11, 2024
1 parent 3ae7b9f commit 66bcc7b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 26 deletions.
21 changes: 0 additions & 21 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
version: 2.1

orbs:
codecov: codecov/codecov@4.1.0

executors:
executor_node_18:
docker:
Expand Down Expand Up @@ -114,14 +111,6 @@ jobs:
- command_checkout_cache_install
- command_test_and_build

job_upload_coverage:
description: Upload coverage to Codecov
executor: executor_node_20
steps:
- command_restore_workspace
- codecov/upload:
file: coverage/*.json

job_publish_to_npm:
description: Publish package to npm
executor: executor_node_20
Expand Down Expand Up @@ -175,16 +164,6 @@ workflows:
branches:
only: /.*/

- job_upload_coverage:
requires:
- job_node_18_test_and_build
- job_node_20_test_and_build
- job_node_21_test_and_build
- job_node_22_test_and_build
filters:
branches:
only: /main/

- job_publish_to_npm:
context: npm
requires:
Expand Down
20 changes: 18 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,30 @@ jobs:
uses: './.github/workflows/lint-test-build.yml'

job_upload_coverage:
name: Upload Coverage
name: Upload Coverage Report to Codecov

runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref_type == 'branch'
needs: job_lint_test_build

steps:
- run: echo "not implemented yet..."
- name: Checkout, Setup Node.js v${{ env.NODE_VERSION }} and Install dependencies
uses: manferlo81/action-checkout-node-install@v0
with:
node-version: ${{ env.NODE_VERSION }}
env:
NODE_VERSION: 20.x

- name: Collect Coverage
run: npm test
env:
COVERAGE: CI

- name: Upload Coverage Report
uses: codecov/codecov-action@v4
with:
directory: coverage
token: ${{ secrets.CODECOV_TOKEN }}

job_create_release:
name: Create GitHub Release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Test
run: npm test
env:
SKIP_COVERAGE: true
COVERAGE: SKIP

- name: Build
run: npm run build
6 changes: 4 additions & 2 deletions jest.config.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
const { COVERAGE } = process.env;

/** @type { import("jest").Config } */
const config = {
cacheDirectory: 'node_modules/.cache/jest',
preset: 'ts-jest',

collectCoverage: !process.env.SKIP_COVERAGE,
collectCoverage: COVERAGE !== 'SKIP',
collectCoverageFrom: [
'src/**/*.ts',
],
coverageDirectory: 'coverage',
coverageReporters: process.env.CI
coverageReporters: COVERAGE === 'CI'
? ['json', 'clover', 'cobertura']
: ['html', 'text'],

Expand Down

0 comments on commit 66bcc7b

Please sign in to comment.