-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (82 loc) · 3.2 KB
/
Copy pathpr.yml
File metadata and controls
100 lines (82 loc) · 3.2 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Pull Request
on:
pull_request:
branches: [ main, develop ]
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linting
id: lint
run: npm run lint
continue-on-error: true
- name: Run tests
id: test
run: |
npx vitest run --reporter=verbose > test-results.txt 2>&1
echo "exit_code=$?" >> $GITHUB_OUTPUT
continue-on-error: true
- name: Run build
id: build
run: npm run build
continue-on-error: true
- name: Read test results
id: test-results
if: always()
run: |
if [ -f test-results.txt ]; then
echo "test_output<<EOF" >> $GITHUB_OUTPUT
cat test-results.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
- name: Comment PR with results
uses: thollander/actions-comment-pull-request@v2
if: always()
with:
message: |
## 📊 Pull Request Check Results
| Check | Status | Details |
|-------|--------|---------|
| Linting | ${{ steps.lint.outcome == 'success' && '✅ Passed' || '❌ Failed' }} | ${{ steps.lint.outcome == 'success' && 'No linting errors' || 'Linting errors found' }} |
| Tests | ${{ steps.test.outcome == 'success' && '✅ Passed' || '❌ Failed' }} | ${{ steps.test.outcome == 'success' && 'All tests passed' || 'Some tests failed' }} |
| Build | ${{ steps.build.outcome == 'success' && '✅ Passed' || '❌ Failed' }} | ${{ steps.build.outcome == 'success' && 'Build successful' || 'Build failed' }} |
${{ steps.test.outcome == 'failure' && format('
<details>
<summary>🔍 Test Output (Click to expand)</summary>
```
{0}
```
</details>', steps.test-results.outputs.test_output) || '' }}
${{ (steps.lint.outcome == 'failure' || steps.test.outcome == 'failure' || steps.build.outcome == 'failure') && '
### ❌ Some checks failed
Please fix the issues above before merging. You can run the following commands locally:
- `npm run lint` - Check for linting errors
- `npm test` - Run tests
- `npm run build` - Test the build
' || '
### ✅ All checks passed!
Great work! This PR is ready for review. 🚀
' }}
---
<sub>🤖 Automated check by GitHub Actions</sub>
comment_tag: pr-check
- name: Fail workflow if any check failed
if: steps.lint.outcome == 'failure' || steps.test.outcome == 'failure' || steps.build.outcome == 'failure'
run: |
echo "❌ One or more checks failed"
echo "Lint: ${{ steps.lint.outcome }}"
echo "Test: ${{ steps.test.outcome }}"
echo "Build: ${{ steps.build.outcome }}"
exit 1