Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests count #76

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading