1+ name : PR Checks
2+
3+ on :
4+ pull_request :
5+ types : [opened, synchronize, reopened]
6+ branches : [ master ]
7+
8+ jobs :
9+ # Job 1: Run tests and checks
10+ test :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - name : Checkout code
15+ uses : actions/checkout@v4
16+
17+ - name : Setup Node.js
18+ uses : actions/setup-node@v4
19+ with :
20+ node-version : ' 22'
21+ cache : ' npm'
22+
23+ - name : Install dependencies
24+ run : npm ci
25+
26+ - name : Run linter
27+ run : npm run lint || echo "No lint script found"
28+ continue-on-error : true
29+
30+ - name : Run tests
31+ run : npm test -- --passWithNoTests --watchAll=false --coverage
32+
33+ - name : Build
34+ run : npm run build
35+ env :
36+ CI : true # Strict mode - fail on warnings
37+
38+ - name : Check build size
39+ run : |
40+ BUILD_SIZE=$(du -sh build | cut -f1)
41+ echo "Build size: $BUILD_SIZE"
42+ echo "BUILD_SIZE=$BUILD_SIZE" >> $GITHUB_ENV
43+
44+ - name : Upload coverage
45+ uses : actions/upload-artifact@v4
46+ with :
47+ name : coverage-report
48+ path : coverage/
49+ retention-days : 7
50+
51+ # Job 2: Comment on PR with results
52+ comment :
53+ runs-on : ubuntu-latest
54+ needs : test
55+ if : always() # Run even if test job fails
56+ permissions :
57+ pull-requests : write
58+
59+ steps :
60+ - name : Comment PR
61+ uses : actions/github-script@v7
62+ with :
63+ script : |
64+ const jobStatus = '${{ needs.test.result }}';
65+ const runUrl = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}';
66+
67+ let emoji = '✅';
68+ let message = 'All checks passed!';
69+
70+ if (jobStatus === 'failure') {
71+ emoji = '❌';
72+ message = 'Some checks failed. Please review the errors.';
73+ }
74+
75+ const comment = `## ${emoji} PR Checks ${emoji}
76+
77+ **Status:** ${jobStatus}
78+ **Build:** Completed
79+
80+ ${message}
81+
82+ 📊 [View detailed results](${runUrl})
83+
84+ ---
85+ *Automated comment by GitHub Actions*`;
86+
87+ github.rest.issues.createComment({
88+ issue_number: context.issue.number,
89+ owner: context.repo.owner,
90+ repo: context.repo.repo,
91+ body: comment
92+ });
0 commit comments