-
Notifications
You must be signed in to change notification settings - Fork 1
67 lines (53 loc) · 1.62 KB
/
Copy pathpr-tests.yml
File metadata and controls
67 lines (53 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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 ./tests/... 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