-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
tmp | ||
.nyc_output | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters