-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
2 changed files
with
28 additions
and
9 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Run Mocha Tests | ||
name: Tests | ||
|
||
on: | ||
push: | ||
|
@@ -7,8 +7,7 @@ on: | |
pull_request: | ||
branches: | ||
- main | ||
|
||
workflow_dispatch: # Enable manual trigger via workflow_dispatch | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
|
@@ -26,14 +25,34 @@ jobs: | |
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
# Install pnpm | ||
- name: Install pnpm | ||
run: npm install -g pnpm | ||
|
||
# Install dependencies using pnpm | ||
- run: pnpm install | ||
|
||
# Run tests using pnpm | ||
- run: pnpm test | ||
# Run tests and output results to a file | ||
- name: Run tests and capture output | ||
run: | | ||
pnpm test > test-output.txt | ||
env: | ||
CI: true | ||
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 |
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