Merge pull request #140 from Xvezda/release/0.13.3 #490
This file contains hidden or 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
name: Test | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
cache: 'pnpm' | |
- run: pnpm install --frozen-lockfile | |
- run: pnpm run --if-present build | |
- name: Run test | |
if: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main' }} | |
run: pnpm test | |
- name: Test coverage | |
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }} | |
run: | | |
pnpm test --experimental-test-coverage --test-coverage-exclude='**/*.test.js' --test-coverage-exclude='test-setup.js' --test-reporter=spec --test-reporter=spec --test-reporter-destination=stdout --test-reporter-destination=coverage.txt | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
node <<'EOF' | |
const fs = require('fs'); | |
const content = fs.readFileSync("./coverage.txt", "utf8"); | |
const percent = content | |
.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "") | |
.match(/all files\s+[^\d]+(\d{0,3}\.\d{0,2})/)[1] + "%"; | |
fetch("https://img.shields.io/badge/coverage-"+"X".repeat(percent.length)+"-blue") | |
.then(r => r.text()) | |
.then(t => | |
fs.writeFileSync( | |
"./coverage.svg", | |
t.replace(new RegExp("X".repeat(percent.length), "g"), percent) | |
) | |
); | |
EOF | |
rm -rf ./coverage.txt | |
git switch --orphan _tmp | |
git add coverage.svg | |
git commit -m 'Update metadata' | |
git fetch origin _meta | |
if git diff origin/_meta _tmp --quiet --exit-code; then | |
true | |
else | |
git switch _meta | |
git cherry-pick -Xtheirs _tmp | |
git push origin _meta | |
fi |