@@ -2,95 +2,147 @@ 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@v2
18- with :
19- go-version : ^1.17
20- id : go
21-
22- - name : Check out code into the Go module directory
23- uses : actions/checkout@v2
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- env :
43- COVERAGE_CONTENT : " ${{ env.COVERAGE_CONTENT }}"
44- with :
45- github-token : ${{ secrets.GITHUB_TOKEN }}
46- script : |
47- const output = `Code Coverage\n
48- \`\`\`\n
49- ${process.env.COVERAGE_CONTENT}
50- \`\`\`
51-
52- *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`;
53-
54- const response = await github.issues.listComments({
55- owner: context.repo.owner,
56- repo: context.repo.repo,
57- issue_number: context.issue.number,
58- });
59-
60- var comments = response.data;
61-
62- console.log(comments);
63-
64- if (comments.length > 0) {
65- comments = comments.filter(comment => comment.body.includes('Code Coverage') && comment.user.type === 'Bot');
66- }
67-
68- if (comments.length > 0) {
69- const comment = comments.shift();
70-
71- github.issues.updateComment({
72- issue_number: context.issue.number,
14+ - name : Set up Go 1.x
15+ uses : actions/setup-go@v2
16+ with :
17+ go-version : ^1.17
18+ id : go
19+
20+ - name : Check out code into the Go module directory
21+ uses : actions/checkout@v2
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+ env :
40+ COVERAGE_CONTENT : " ${{ env.COVERAGE_CONTENT }}"
41+ with :
42+ github-token : ${{ secrets.GITHUB_TOKEN }}
43+ script : |
44+ const output = `Code Coverage\n
45+ \`\`\`\n
46+ ${process.env.COVERAGE_CONTENT}
47+ \`\`\`
48+
49+ *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`;
50+
51+ const response = await github.issues.listComments({
7352 owner: context.repo.owner,
7453 repo: context.repo.repo,
75- comment_id: comment.id,
76- body: output
77- })
78- } else {
79- github.issues.createComment({
8054 issue_number: context.issue.number,
55+ });
56+
57+ var comments = response.data;
58+
59+ console.log(comments);
60+
61+ if (comments.length > 0) {
62+ comments = comments.filter(comment => comment.body.includes('Code Coverage') && comment.user.type === 'Bot');
63+ }
64+
65+ if (comments.length > 0) {
66+ const comment = comments.shift();
67+
68+ github.issues.updateComment({
69+ issue_number: context.issue.number,
70+ owner: context.repo.owner,
71+ repo: context.repo.repo,
72+ comment_id: comment.id,
73+ body: output
74+ })
75+ } else {
76+ github.issues.createComment({
77+ issue_number: context.issue.number,
78+ owner: context.repo.owner,
79+ repo: context.repo.repo,
80+ body: output
81+ })
82+ }
83+
84+ - name : Benchmark
85+ id : benchmark
86+ run : |
87+ go test -benchmem -bench . | tee -a benchmark.txt
88+ echo "BENCHMARK_CONTENT<<EOF" >> $GITHUB_ENV
89+ cat benchmark.txt >> $GITHUB_ENV
90+ echo "EOF" >> $GITHUB_ENV
91+
92+ - uses : actions/github-script@v4
93+ if : github.event_name == 'pull_request'
94+ env :
95+ BENCHMARK_CONTENT : " ${{ env.BENCHMARK_CONTENT }}"
96+ with :
97+ github-token : ${{ secrets.GITHUB_TOKEN }}
98+ script : |
99+ const output = `Benchmark\n
100+ \`\`\`\n
101+ ${process.env.BENCHMARK_CONTENT}
102+ \`\`\`
103+
104+ *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`;
105+
106+ const response = await github.issues.listComments({
81107 owner: context.repo.owner,
82108 repo: context.repo.repo,
83- body: output
84- })
85- }
86-
87- - name : Run golangci-lint
88- uses : golangci/golangci-lint-action@v2
89- with :
90- version : v1.41.1
91- skip-pkg-cache : true
92-
93- - name : Coveralls
94- uses : shogo82148/actions-goveralls@v1
95- with :
96- path-to-profile : coverage.out
109+ issue_number: context.issue.number,
110+ });
111+
112+ var comments = response.data;
113+
114+ console.log(comments);
115+
116+ if (comments.length > 0) {
117+ comments = comments.filter(comment => comment.body.includes('Benchmark') && comment.user.type === 'Bot');
118+ }
119+
120+ if (comments.length > 0) {
121+ const comment = comments.shift();
122+
123+ github.issues.updateComment({
124+ issue_number: context.issue.number,
125+ owner: context.repo.owner,
126+ repo: context.repo.repo,
127+ comment_id: comment.id,
128+ body: output
129+ })
130+ } else {
131+ github.issues.createComment({
132+ issue_number: context.issue.number,
133+ owner: context.repo.owner,
134+ repo: context.repo.repo,
135+ body: output
136+ })
137+ }
138+
139+ - name : Run golangci-lint
140+ uses : golangci/golangci-lint-action@v2
141+ with :
142+ version : v1.55.2
143+ skip-pkg-cache : true
144+
145+ - name : Coveralls
146+ uses : shogo82148/actions-goveralls@v1
147+ with :
148+ path-to-profile : coverage.out
0 commit comments