Skip to content

Run tests for 18 only #121

Run tests for 18 only

Run tests for 18 only #121

Workflow file for this run

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-output.txt
env:
CI: true
# Extract passing test count from the output
- name: Parse passing test count
id: test_count
run: |
PASSING_TESTS=$(grep -Po '\d+ passing' test-output.txt | grep -Po '\d+')
echo "Passing tests: $PASSING_TESTS"
# Create JSON file with the test count
echo "{ \"schemaVersion\": 1, \"label\": \"Tests\", \"message\": \"$PASSING_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