forked from magma/magma
-
Notifications
You must be signed in to change notification settings - Fork 0
239 lines (231 loc) · 9 KB
/
golang-build-test.yml
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# Copyright 2022 The Magma Authors.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: AGW Build & Test Experimental Go Code
on:
push:
branches:
- master
- 'v1.*'
pull_request:
branches:
- master
- 'v1.*'
types:
- opened
- reopened
- synchronize
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
check_go_version:
runs-on: ubuntu-latest
env:
MAGMA_ROOT: "${{ github.workspace }}"
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
- name: Run golang_check_version.sh script
run: ./.github/workflows/scripts/golang_check_version.sh
pre_job_src_go_determinator:
runs-on: ubuntu-latest
outputs:
should_not_skip: ${{ steps.changes.outputs.filesChanged }}
steps:
# Need to get git on push event
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
if: github.event_name == 'push'
- uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # [email protected]
id: changes
with:
filters: |
filesChanged:
- [".github/workflows/golang-build-test.yml", "src/go/**"]
- name: Save should_not_skip output
if: always()
run: |
mkdir -p ./pr
echo -n ${{ steps.changes.outputs.filesChanged == 'false' }} > ./pr/skipped
- uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # pin@v3
if: always()
with:
name: pr
path: pr/
build_src_go:
needs: pre_job_src_go_determinator
if: ${{ needs.pre_job_src_go_determinator.outputs.should_not_skip == 'true' }}
strategy:
matrix:
go-version: [1.19.3]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # [email protected]
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
- name: Test
run: |
cd src/go/
go build ./...
- name: Extract commit title
id: commit
if: failure() && github.event_name == 'push'
run: |
str="$(jq '.head_commit.message' $GITHUB_EVENT_PATH)" # get the head_commit message
echo ::set-output name=title::${str%%\\n*} | tr -d '"'
- name: Notify failure to slack
if: failure() && github.event_name == 'push'
uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 # [email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_CI }}
SLACK_TITLE: "build_src_go tests failed"
SLACK_MESSAGE: "${{ steps.commit.outputs.title}}"
SLACK_USERNAME: ${{ github.workflow }}
SLACK_ICON_EMOJI: ":boom:"
SLACK_COLOR: "#FF0000"
SLACK_FOOTER: ' '
test_src_go:
needs: pre_job_src_go_determinator
if: ${{ needs.pre_job_src_go_determinator.outputs.should_not_skip == 'true' }}
strategy:
matrix:
go-version: [1.19.3]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # [email protected]
with:
go-version: ${{ matrix.go-version }}
- name: Setup gotestsum
uses: autero1/action-gotestsum@2e48af62f5248bd3b014f598cd1aa69a01dd36e3 # [email protected]
with:
gotestsum_version: 1.7.0
- name: Checkout code
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
- name: Test
run: |
cd src/go/
gotestsum --format=testname --junitfile test_src_go.xml -- -race ./...
- name: Upload Test Results
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # pin@v3
with:
name: Unit Test Results
path: "${{ github.workspace }}/src/go/test_src_go.xml"
- name: Extract commit title
id: commit
if: failure() && github.event_name == 'push'
run: |
str="$(jq '.head_commit.message' $GITHUB_EVENT_PATH)" # get the head_commit message
echo ::set-output name=title::${str%%\\n*} | tr -d '"'
- name: Notify failure to slack
if: failure() && github.event_name == 'push'
uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 # [email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_CI }}
SLACK_TITLE: "test_src_go tests failed"
SLACK_MESSAGE: "${{ steps.commit.outputs.title}}"
SLACK_USERNAME: ${{ github.workflow }}
SLACK_ICON_EMOJI: ":boom:"
SLACK_COLOR: "#FF0000"
SLACK_FOOTER: ' '
test_src_go_qemu:
needs: pre_job_src_go_determinator
if: ${{ needs.pre_job_src_go_determinator.outputs.should_not_skip == 'true' }}
strategy:
matrix:
go-version: [1.19.3]
arch: [386, arm, arm64]
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # [email protected]
with:
go-version: ${{ matrix.go-version }}
- name: Install QEMU
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # [email protected]
- name: Setup gotestsum
uses: autero1/action-gotestsum@2e48af62f5248bd3b014f598cd1aa69a01dd36e3 # [email protected]
with:
gotestsum_version: 1.7.0
- name: Checkout code
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
- name: Run tests via qemu/binfmt
run: |
cd src/go/
gotestsum --format=testname --junitfile test_src_go.xml -- ./...
env:
GOARCH: ${{ matrix.arch }}
# TODO: Upload this test result as a comment on PR
- name: Upload Test Results
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # pin@v3
with:
name: Unit Test Results arm64
path: "${{ github.workspace }}/src/go/test_src_go.xml"
- name: Extract commit title
id: commit
if: failure() && github.event_name == 'push'
run: |
str="$(jq '.head_commit.message' $GITHUB_EVENT_PATH)" # get the head_commit message
echo ::set-output name=title::${str%%\\n*} | tr -d '"'
- name: Notify failure to slack
if: failure() && github.event_name == 'push'
uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 # [email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_CI }}
SLACK_TITLE: "test_src_go_qemu tests failed"
SLACK_MESSAGE: "${{ steps.commit.outputs.title}}"
SLACK_USERNAME: ${{ github.workflow }}
SLACK_ICON_EMOJI: ":boom:"
SLACK_COLOR: "#FF0000"
SLACK_FOOTER: ' '
codecov_src_go:
needs: pre_job_src_go_determinator
if: ${{ needs.pre_job_src_go_determinator.outputs.should_not_skip == 'true' }}
strategy:
matrix:
go-version: [1.19.3]
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # [email protected]
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
- name: Test
run: |
cd src/go/
go test -race -coverprofile=coverage.txt -covermode=atomic ./...
- name: Codecov.io Upload
uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # [email protected]
with:
flags: src_go
verbose: true
- name: Extract commit title
id: commit
if: failure() && github.event_name == 'push'
run: |
str="$(jq '.head_commit.message' $GITHUB_EVENT_PATH)" # get the head_commit message
echo ::set-output name=title::${str%%\\n*} | tr -d '"'
- name: Notify failure to slack
if: failure() && github.event_name == 'push'
uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 # [email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_CI }}
SLACK_TITLE: "codecov_src_go tests failed"
SLACK_MESSAGE: "${{ steps.commit.outputs.title}}"
SLACK_USERNAME: ${{ github.workflow }}
SLACK_ICON_EMOJI: ":boom:"
SLACK_COLOR: "#FF0000"
SLACK_FOOTER: ' '