diff --git a/.github/workflows/unit-test copy.yml b/.github/workflows/unit-test copy.yml
new file mode 100644
index 0000000..ab7e008
--- /dev/null
+++ b/.github/workflows/unit-test copy.yml
@@ -0,0 +1,77 @@
+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 2bf233b..51b7535 100644
--- a/.github/workflows/unit-test.yml
+++ b/.github/workflows/unit-test.yml
@@ -37,3 +37,7 @@ jobs:
run: npm install
- name: Test
run: npm test
+
+ - name: Update Coverage Badge
+ if: ${{ matrix.os == 'ubuntu-latest' && matrix.node-version == 8 }}
+ uses: we-cli/coverage-badge-action@main
diff --git a/.gitignore b/.gitignore
index 72e4d95..5113ef5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
node_modules
tmp
.nyc_output
+coverage
diff --git a/README.md b/README.md
index de8a02c..b5cdf4b 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
# jayin
- [![unit](https://github.com/fritx/jayin/actions/workflows/unit-test.yml/badge.svg)](https://github.com/fritx/jayin/actions/workflows/unit-test.yml) [![e2e](https://github.com/fritx/jayin/actions/workflows/e2e-test.yml/badge.svg)](https://github.com/fritx/jayin/actions/workflows/e2e-test.yml)
+ [![cov](https://we-cli.github.io/jayin/badges/coverage.svg)](https://github.com/fritx/jayin/actions/workflows/unit-test.yml)
+ [![unit](https://github.com/fritx/jayin/actions/workflows/unit-test.yml/badge.svg)](https://github.com/fritx/jayin/actions/workflows/unit-test.yml) [![e2e](https://github.com/fritx/jayin/actions/workflows/e2e-test.yml/badge.svg)](https://github.com/fritx/jayin/actions/workflows/e2e-test.yml)
Let's say you have a gitignore-like file:
diff --git a/package.json b/package.json
index ae070b7..00abb06 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,7 @@
"jayin": "index.js"
},
"scripts": {
- "test": "nyc mocha --timeout 5000"
+ "test": "nyc -r text -r json-summary mocha --timeout 5000"
},
"devDependencies": {
"bufferhelper": "^0.2.1",