@@ -2,96 +2,93 @@ name: Go
22
33on :
44 push :
5- branches : [ master ]
5+ branches : [master]
66 pull_request :
7- branches : [ master ]
7+ branches : [master]
88
99jobs :
10-
1110 build :
1211 name : Build
1312 runs-on : ubuntu-latest
1413 steps :
15-
16- - name : Set up Go 1.x
17- uses : actions/setup-go@v5
18- with :
19- go-version : " 1.x"
20- id : go
21-
22- - name : Check out code into the Go module directory
23- uses : actions/checkout@v4
24-
25- - name : Build
26- run : go build -race -v ./...
27-
28- - name : Test
29- run : go test -race -cover -coverprofile ./coverage.out ./...
30-
31- - name : Coverage
32- id : coverage
33- run : |
34- go tool cover -func ./coverage.out | tee -a coverage.txt
35- echo "COVERAGE_CONTENT<<EOF" >> $GITHUB_ENV
36- cat coverage.txt >> $GITHUB_ENV
37- echo "EOF" >> $GITHUB_ENV
38-
39-
40- - uses : actions/github-script@v4
41- if : github.event_name == 'pull_request'
42- continue-on-error : true
43- env :
44- COVERAGE_CONTENT : " ${{ env.COVERAGE_CONTENT }}"
45- with :
46- github-token : ${{ secrets.GITHUB_TOKEN }}
47- script : |
48- const output = `Code Coverage\n
49- \`\`\`\n
50- ${process.env.COVERAGE_CONTENT}
51- \`\`\`
52-
53- *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`;
54-
55- const response = await github.issues.listComments({
56- owner: context.repo.owner,
57- repo: context.repo.repo,
58- issue_number: context.issue.number,
59- });
60-
61- var comments = response.data;
62-
63- console.log(comments);
64-
65- if (comments.length > 0) {
66- comments = comments.filter(comment => comment.body.includes('Code Coverage') && comment.user.type === 'Bot');
67- }
68-
69- if (comments.length > 0) {
70- const comment = comments.shift();
71-
72- github.issues.updateComment({
73- issue_number: context.issue.number,
14+ - name : Set up Go 1.x
15+ uses : actions/setup-go@v5
16+ with :
17+ go-version : " 1.x"
18+ id : go
19+
20+ - name : Check out code into the Go module directory
21+ uses : actions/checkout@v4
22+
23+ - name : Build
24+ run : go build -race -v ./...
25+
26+ - name : Test
27+ run : go test -race -cover -coverprofile ./coverage.out ./...
28+
29+ - name : Coverage
30+ id : coverage
31+ run : |
32+ go tool cover -func ./coverage.out | tee -a coverage.txt
33+ echo "COVERAGE_CONTENT<<EOF" >> $GITHUB_ENV
34+ cat coverage.txt >> $GITHUB_ENV
35+ echo "EOF" >> $GITHUB_ENV
36+
37+ - uses : actions/github-script@v4
38+ if : github.event_name == 'pull_request'
39+ continue-on-error : true
40+ env :
41+ COVERAGE_CONTENT : " ${{ env.COVERAGE_CONTENT }}"
42+ with :
43+ github-token : ${{ secrets.GITHUB_TOKEN }}
44+ script : |
45+ const output = `Code Coverage\n
46+ \`\`\`\n
47+ ${process.env.COVERAGE_CONTENT}
48+ \`\`\`
49+
50+ *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`;
51+
52+ const response = await github.issues.listComments({
7453 owner: context.repo.owner,
7554 repo: context.repo.repo,
76- comment_id: comment.id,
77- body: output
78- })
79- } else {
80- github.issues.createComment({
8155 issue_number: context.issue.number,
82- owner: context.repo.owner,
83- repo: context.repo.repo,
84- body: output
85- })
86- }
87-
88- - name : Run golangci-lint
89- uses : golangci/golangci-lint-action@v4
90- with :
91- version : v1.52.2
92- skip-pkg-cache : true
93-
94- - name : Coveralls
95- uses : shogo82148/actions-goveralls@v1
96- with :
97- path-to-profile : coverage.out
56+ });
57+
58+ var comments = response.data;
59+
60+ console.log(comments);
61+
62+ if (comments.length > 0) {
63+ comments = comments.filter(comment => comment.body.includes('Code Coverage') && comment.user.type === 'Bot');
64+ }
65+
66+ if (comments.length > 0) {
67+ const comment = comments.shift();
68+
69+ github.issues.updateComment({
70+ issue_number: context.issue.number,
71+ owner: context.repo.owner,
72+ repo: context.repo.repo,
73+ comment_id: comment.id,
74+ body: output
75+ })
76+ } else {
77+ github.issues.createComment({
78+ issue_number: context.issue.number,
79+ owner: context.repo.owner,
80+ repo: context.repo.repo,
81+ body: output
82+ })
83+ }
84+
85+ - name : Run golangci-lint
86+ uses : golangci/golangci-lint-action@v4
87+ with :
88+ version : v1.55.2
89+ skip-cache : true
90+
91+ - name : Coveralls
92+ uses : shogo82148/actions-goveralls@v1
93+ with :
94+ path-to-profile : coverage.out
0 commit comments