From d03916eeeb9aa81f7d39cf4c25c6188c2a6a1b54 Mon Sep 17 00:00:00 2001 From: Fritz Lin Date: Tue, 23 Jan 2024 10:09:52 +0800 Subject: [PATCH] fix nyc coverage report with node8 ci https://github.com/Jayin/jsonmerge/pull/4 https://github.com/istanbuljs/nyc/issues/865 https://github.com/istanbuljs/istanbuljs/pull/733 https://github.com/istanbuljs/istanbuljs/pull/731 https://github.com/sindresorhus/make-dir/pull/32 https://github.com/npm/node-semver/pull/448 --- .github/workflows/unit-test copy.yml | 77 ---------------------------- .github/workflows/unit-test.yml | 9 +++- 2 files changed, 8 insertions(+), 78 deletions(-) delete mode 100644 .github/workflows/unit-test copy.yml diff --git a/.github/workflows/unit-test copy.yml b/.github/workflows/unit-test copy.yml deleted file mode 100644 index ab7e008..0000000 --- a/.github/workflows/unit-test copy.yml +++ /dev/null @@ -1,77 +0,0 @@ -name: unit test copy - -on: - push: - branches: [master, dev, ci/**] - pull_request: - branches: [master, dev, ci/**] - workflow_dispatch: - # Keep this to allow for triggering manually - -jobs: - unit-test: - strategy: - matrix: - node-version: - # currently devDependencies require node>=8.9 - # - 8 # skip - # - 10 # skip - # - 12 # skip - # - 14 # skip - # - 16 # skip - - 18 - os: - - windows-latest - - ubuntu-latest - - macos-latest - - runs-on: ${{ matrix.os }} - - outputs: - coverage: ${{ steps.coverage-value.outputs.coverage }} - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - name: Install - run: npm install - - name: Test - run: npm test - - - name: Coverage Value - id: coverage-value - if: ${{ matrix.os == 'ubuntu-latest' && matrix.node-version == 18 }} - run: | - COV=$(node -p 't=require(`./coverage/coverage-summary.json`).total,Math.min(...`lines|statements|functions|branches`.split(`|`).map(k=>t[k].pct))') - echo "coverage=$COV" >> $GITHUB_OUTPUT - - badges: - needs: [unit-test] - runs-on: ubuntu-latest - steps: - - name: Checkout gh-pages - uses: actions/checkout@v3 - with: - ref: gh-pages - - name: Use Node.js - uses: actions/setup-node@v3 - - - name: Create Badges - run: | - npm i -g badgen-cli - export COV=${{ needs.unit-test.outputs.coverage }} - COLOR=$(node -p '+process.env.COV >= 95 ? `green` : `orange`') - mkdir -p site_tmp/badges - badgen -j coverage -s $COV% -c $COLOR > site_tmp/badges/coverage.svg - - - name: Deploy Badges - run: | - cp -r site_tmp/* . - rm -rf site_tmp - - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: Update badges [skip ci] - branch: gh-pages diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 51b7535..8c81d1f 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -15,7 +15,7 @@ jobs: node-version: # currently devDependencies require node>=8.9 - 8 - # - 10 # skip + - 10 # - 12 # skip # - 14 # skip # - 16 # skip @@ -35,6 +35,13 @@ jobs: node-version: ${{ matrix.node-version }} - name: Install run: npm install + - name: Fix nyc coverage report with node8 + run: > + npm install --no-save + istanbul-lib-coverage@3.2.0 + istanbul-lib-instrument@5.2.1 + istanbul-lib-report@3.0.0 + istanbul-reports@3.1.5 - name: Test run: npm test