1
1
name : code coverage
2
2
3
- on :
3
+ on :
4
4
pull_request :
5
5
branches :
6
- - main
6
+ - main
7
7
8
8
jobs :
9
9
comment-forge-coverage :
@@ -13,77 +13,77 @@ jobs:
13
13
pull-requests : write
14
14
15
15
steps :
16
- - name : Checkout code
17
- uses : actions/checkout@v3
18
- with :
19
- token : ${{ secrets.GITHUB_TOKEN }}
16
+ - name : Checkout code
17
+ uses : actions/checkout@v3
18
+ with :
19
+ token : ${{ secrets.GITHUB_TOKEN }}
20
20
21
- - name : Install foundry
22
- uses : foundry-rs/foundry-toolchain@v1
23
- with :
21
+ - name : Install foundry
22
+ uses : foundry-rs/foundry-toolchain@v1
23
+ with :
24
24
version : nightly
25
- - name : Run Forge build
26
- run : |
25
+ - name : Run Forge build
26
+ run : |
27
27
forge --version
28
28
forge build --sizes
29
- id : build
30
- - name : Run forge coverage
31
- id : coverage
32
- run : |
33
- {
34
- echo 'COVERAGE<<EOF'
35
- forge coverage | grep '^|' | grep -v 'test/'
36
- echo EOF
37
- } >> "$GITHUB_OUTPUT"
38
- env :
39
- FOUNDRY_RPC_URL : ' ${{ secrets.RPC_URL }}'
40
-
41
- - name : Check coverage is updated
42
- uses : actions/github-script@v5
43
- with :
44
- github-token : ${{ secrets.GITHUB_TOKEN }}
45
- script : |
46
- const fs = require('fs');
47
- const file = "coverage.txt"
48
- if(!fs.existsSync(file)) {
49
- console.log("Nothing to check");
50
- return
51
- }
52
- const currentCoverage = fs.readFileSync(file, "utf8").trim();
53
- const newCoverage = (`${{ steps.coverage.outputs.COVERAGE }}`).trim();
54
- if (newCoverage != currentCoverage) {
55
- core.setFailed(`Code coverage not updated. Run : forge coverage | grep '^|' | grep -v 'test/' > coverage.txt`);
56
- }
29
+ id : build
30
+ - name : Run forge coverage
31
+ id : coverage
32
+ run : |
33
+ {
34
+ echo 'COVERAGE<<EOF'
35
+ forge coverage | grep '^|' | grep -v 'test/'
36
+ echo EOF
37
+ } >> "$GITHUB_OUTPUT"
38
+ env :
39
+ FOUNDRY_RPC_URL : " ${{ secrets.RPC_URL }}"
57
40
58
- - name : Comment on PR
59
- id : comment
60
- uses : actions/github-script@v5
61
- with :
62
- github-token : ${{ secrets.GITHUB_TOKEN }}
63
- script : |
64
- const {data: comments} = await github.rest.issues.listComments({
65
- owner: context.repo.owner,
66
- repo: context.repo.repo,
67
- issue_number: context.issue.number,
68
- })
41
+ - name : Check coverage is updated
42
+ uses : actions/github-script@v5
43
+ with :
44
+ github-token : ${{ secrets.GITHUB_TOKEN }}
45
+ script : |
46
+ const fs = require('fs');
47
+ const file = "coverage.txt"
48
+ if(!fs.existsSync(file)) {
49
+ console.log("Nothing to check");
50
+ return
51
+ }
52
+ const currentCoverage = fs.readFileSync(file, "utf8").trim();
53
+ const newCoverage = (`${{ steps.coverage.outputs.COVERAGE }}`).trim();
54
+ if (newCoverage != currentCoverage) {
55
+ core.setFailed(`Code coverage not updated. Run : forge coverage | grep '^|' | grep -v 'test/' > coverage.txt`);
56
+ }
69
57
70
- const botComment = comments.find(comment => comment.user.id === 41898282)
58
+ - name : Comment on PR
59
+ id : comment
60
+ uses : actions/github-script@v5
61
+ with :
62
+ github-token : ${{ secrets.GITHUB_TOKEN }}
63
+ script : |
64
+ const {data: comments} = await github.rest.issues.listComments({
65
+ owner: context.repo.owner,
66
+ repo: context.repo.repo,
67
+ issue_number: context.issue.number,
68
+ })
71
69
72
- const output = `${{ steps.coverage.outputs.COVERAGE }}`;
73
- const commentBody = `Forge code coverage:\n${output}\n`;
70
+ const botComment = comments.find(comment => comment.user.id === 41898282)
74
71
75
- if (botComment) {
76
- github.rest.issues.updateComment({
77
- owner: context.repo.owner,
78
- repo: context.repo.repo,
79
- comment_id: botComment.id,
80
- body: commentBody
81
- })
82
- } else {
83
- github.rest.issues.createComment({
84
- issue_number: context.issue.number,
85
- owner: context.repo.owner,
86
- repo: context.repo.repo,
87
- body: commentBody
88
- });
89
- }
72
+ const output = `${{ steps.coverage.outputs.COVERAGE }}`;
73
+ const commentBody = `Forge code coverage:\n${output}\n`;
74
+
75
+ if (botComment) {
76
+ github.rest.issues.updateComment({
77
+ owner: context.repo.owner,
78
+ repo: context.repo.repo,
79
+ comment_id: botComment.id,
80
+ body: commentBody
81
+ })
82
+ } else {
83
+ github.rest.issues.createComment({
84
+ issue_number: context.issue.number,
85
+ owner: context.repo.owner,
86
+ repo: context.repo.repo,
87
+ body: commentBody
88
+ });
89
+ }
0 commit comments