Bump packages (#83) #150
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
name: Tests | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install pnpm | |
run: npm install -g pnpm | |
- run: pnpm install | |
# Run tests and output results to a file | |
- name: Run tests and capture output | |
run: | | |
pnpm test > test-result.txt | |
env: | |
CI: true | |
# Sanitize the test-result.txt by removing non-printable characters | |
- name: Sanitize test output | |
run: | | |
tr -cd '\11\12\15\40-\176' < test-result.txt > sanitized-test-result.txt | |
# Extract passing test count from the sanitized output | |
- name: Parse passing test count | |
id: test_count | |
run: | | |
PASSING_TESTS=$(grep -Eo '[0-9]+ passing' sanitized-test-result.txt | grep -Eo '[0-9]+') | |
echo "Passing tests: $PASSING_TESTS" | |
# Create JSON file with the test count | |
echo "{ \"schemaVersion\": 1, \"label\": \"tests\", \"message\": \"$PASSING_TESTS tests passing\", \"color\": \"green\" }" > tests-status.json | |
# Commit the updated JSON file back to the repo | |
- name: Commit test count JSON | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "[email protected]" | |
git add tests-status.json | |
git commit -m "Update test count" | |
git push origin main | |
# Prevents workflow from failing if no changes are made | |
continue-on-error: true |