From 252c00f795dcc19a9ca2992158063affce5e40ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Fern=C3=A1ndez?= Date: Wed, 13 Nov 2024 09:20:20 +0700 Subject: [PATCH] chore: Cleanup workflows --- .github/workflows/ci.yml | 23 +++++++++++++---------- .github/workflows/lint-test-build.yml | 21 +++++++++++---------- jest.config.mjs | 6 ++++-- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5adce14..ec7a90f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,9 +13,6 @@ on: workflow_dispatch: -env: - DEFAULT_NODE_VERSION: 20 - jobs: job_lint_and_test: name: Lint, Test and Build @@ -29,15 +26,17 @@ jobs: needs: job_lint_and_test steps: - - name: Checkout, Setup Node.js v${{ env.DEFAULT_NODE_VERSION }} and Install dependencies + - name: Checkout, Setup Node.js v${{ env.NODE_VERSION }} and Install dependencies uses: manferlo81/action-checkout-node-install@v0 with: - node-version: ${{ env.DEFAULT_NODE_VERSION }} + node-version: ${{ env.NODE_VERSION }} + env: + NODE_VERSION: 20.x - name: Run tests run: npm test env: - CI: true + COVERAGE: CI - name: Upload coverage uses: codecov/codecov-action@v4 @@ -56,10 +55,12 @@ jobs: contents: write steps: - - name: Checkout, Setup Node.js v${{ env.DEFAULT_NODE_VERSION }} and Install dependencies + - name: Checkout, Setup Node.js v${{ env.NODE_VERSION }} and Install dependencies uses: manferlo81/action-checkout-node-install@v0 with: - node-version: ${{ env.DEFAULT_NODE_VERSION }} + node-version: ${{ env.NODE_VERSION }} + env: + NODE_VERSION: 20.x - name: Build run: npm run build @@ -80,11 +81,13 @@ jobs: needs: job_lint_and_test steps: - - name: Checkout, Setup Node.js v${{ env.DEFAULT_NODE_VERSION }} and Install dependencies + - name: Checkout, Setup Node.js v${{ env.NODE_VERSION }} and Install dependencies uses: manferlo81/action-checkout-node-install@v0 with: - node-version: ${{ env.DEFAULT_NODE_VERSION }} + node-version: ${{ env.NODE_VERSION }} registry-url: https://registry.npmjs.org/ + env: + NODE_VERSION: 20.x - name: Build run: npm run build diff --git a/.github/workflows/lint-test-build.yml b/.github/workflows/lint-test-build.yml index 40ccf9b..b4b3ed8 100644 --- a/.github/workflows/lint-test-build.yml +++ b/.github/workflows/lint-test-build.yml @@ -3,8 +3,7 @@ name: Lint, Test and Build on: workflow_call: -env: - DEFAULT_NODE_VERSION: 20 + jobs: job_lint: @@ -13,10 +12,12 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout, Setup Node.js v${{ env.DEFAULT_NODE_VERSION }} and Install dependencies + - name: Checkout, Setup Node.js v${{ env.NODE_VERSION }} and Install dependencies uses: manferlo81/action-checkout-node-install@v0 with: - node-version: ${{ env.DEFAULT_NODE_VERSION }} + node-version: ${{ env.NODE_VERSION }} + env: + NODE_VERSION: 20.x - name: Lint code run: npm run lint @@ -29,13 +30,13 @@ jobs: machine: windows-latest - name: Ubuntu machine: ubuntu-latest - - name: MacOS + - name: macOS machine: macos-latest node-version: - - 18 - - 20 - - 21 - - 22 + - 18.x + - 20.x + - 21.x + - 22.x name: Test and Build (${{ matrix.os.name }}, NodeJS v${{ matrix.node-version }}) @@ -51,7 +52,7 @@ jobs: - name: Run tests run: npm test env: - SKIP_COVERAGE: true + COVERAGE: SKIP - name: Build run: npm run build diff --git a/jest.config.mjs b/jest.config.mjs index 4cbc065..1ca4ef5 100644 --- a/jest.config.mjs +++ b/jest.config.mjs @@ -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'],