Skip to content

Commit

Permalink
Tests count (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
surfinzap authored Sep 21, 2024
1 parent c471dc3 commit 9744799
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
35 changes: 27 additions & 8 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run Mocha Tests
name: Tests

on:
push:
Expand All @@ -7,8 +7,7 @@ on:
pull_request:
branches:
- main

workflow_dispatch: # Enable manual trigger via workflow_dispatch
workflow_dispatch:

jobs:
test:
Expand All @@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
![GitHub package.json version](https://img.shields.io/github/package-json/v/surfinzap/typopo?color=7b00cb&style=flat)
![GitHub](https://img.shields.io/github/license/surfinzap/typopo?color=7b00cb&style=flat)
![Tests](https://github.com/surfinzap/typopo/actions/workflows/run-tests.yml/badge.svg)
![Tests](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/surfinzap/typopo/main/tests-status.json)


## Links
Expand Down

0 comments on commit 9744799

Please sign in to comment.