Skip to content

Add comprehensive test suite for ~100% coverage #7

Add comprehensive test suite for ~100% coverage

Add comprehensive test suite for ~100% coverage #7

Workflow file for this run

name: PR Tests
on:
pull_request:
branches:
- main
permissions:
contents: read
pull-requests: write
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.25'
- name: Download dependencies
run: go mod download
- name: Run tests
id: test
run: |
go test -v ./... 2>&1 | tee test-output.txt
echo "test_exit_code=${PIPESTATUS[0]}" >> $GITHUB_OUTPUT
- name: Comment PR with test results
uses: actions/github-script@v7
if: always()
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const testOutput = fs.readFileSync('test-output.txt', 'utf8');
const testPassed = ${{ steps.test.outputs.test_exit_code }} === 0;
const emoji = testPassed ? '✅' : '❌';
const status = testPassed ? 'PASSED' : 'FAILED';
const body = `## ${emoji} Test Results: ${status}
<details>
<summary>Test Output</summary>
\`\`\`
${testOutput}
\`\`\`
</details>`;
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
- name: Fail if tests failed
if: steps.test.outputs.test_exit_code != '0'
run: exit 1