-
Notifications
You must be signed in to change notification settings - Fork 234
225 lines (193 loc) · 6.49 KB
/
go-getter.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
name: go-getter
on:
push:
branches:
- v2
pull_request:
branches:
- v2
env:
TEST_RESULTS_PATH: /tmp/test-results
jobs:
linux-tests:
runs-on: ubuntu-latest
strategy:
matrix:
# Note: while strictly speaking quoting the versions is not necessary
# however for versions like 1.10, 1.20, 1.30, etc. without quotes, YAML
# renders these versions as floats, so the least-significant 0 gets
# dropped from the version number, so those become like 1.1, 1.2, 1.3, etc.
# To avoid the issue, we quote them systematically.
go-version:
- "1.19"
- "1.20"
- "1.21"
directory:
- s3
- gcs
- .
permissions:
id-token: write
contents: read
steps:
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
- name: Create test directory
run: |
mkdir -p ${{ env.TEST_RESULTS_PATH }}/go-getter
- name: Setup cache for go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download go modules
run: go mod download
# Check go fmt output because it does not report non-zero when there are fmt changes
- name: Run gofmt
run: |
go fmt ./...
files=$(go fmt ./...)
if [ -n "$files" ]; then
echo "The following file(s) do not conform to go fmt:"
echo "$files"
exit 1
fi
- name: Install gotestsum
run: go install gotest.tools/gotestsum@v1.8.2
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: us-east-1
role-to-assume: arn:aws:iam::388664967494:role/hc-go-getter-test
role-session-name: ${{ github.run_id }}
audience: https://github.com/hashicorp
- name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v0.4.0'
with:
workload_identity_provider: 'projects/328212837253/locations/global/workloadIdentityPools/hc-go-getter-test/providers/github-hc-go-getter-test'
service_account: hc-go-getter-test@hc-e56c0f7c21c448d2be9e7696073.iam.gserviceaccount.com
audience: https://github.com/hashicorp
- name: Run Go cmd
run: |
cd cmd/go-getter
go run . go.mod tmpdir
diff tmpdir/go.mod go.mod
- name: Run Go tests
working-directory: ${{ matrix.directory }}
run: |
PACKAGE_NAMES=$(go list ./...)
echo "Running $(echo $PACKAGE_NAMES | wc -w) packages"
echo $PACKAGE_NAMES
gotestsum --format=short-verbose --junitfile $TEST_RESULTS_PATH/go-getter/gotestsum-report.xml -- -p 2 $PACKAGE_NAMES
# Save coverage report parts
- name: Upload and save artifacts
uses: actions/upload-artifact@v3
with:
name: linux test results
path: ${{ env.TEST_RESULTS_PATH }}
windows-tests:
runs-on: windows-latest
strategy:
matrix:
go-version:
- "1.19"
- "1.20"
- "1.21"
directory:
- s3
- gcs
- .
permissions:
id-token: write
contents: read
steps:
- name: Run git config #Windows-only
run: git config --global core.autocrlf false
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
- name: Setup cache for go modules
uses: actions/cache@v3
with:
path: |
~\AppData\Local\go-build
~\go\pkg\mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download go modules
run: go mod download
- name: Install gotestsum
shell: bash
run: go install gotest.tools/gotestsum@v1.8.2
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: us-east-1
role-to-assume: arn:aws:iam::388664967494:role/hc-go-getter-test
role-session-name: ${{ github.run_id }}
audience: https://github.com/hashicorp
- name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v0.4.0'
with:
workload_identity_provider: 'projects/328212837253/locations/global/workloadIdentityPools/hc-go-getter-test/providers/github-hc-go-getter-test'
service_account: hc-go-getter-test@hc-e56c0f7c21c448d2be9e7696073.iam.gserviceaccount.com
audience: https://github.com/hashicorp
- name: Run Go cmd
run: |
cd cmd/go-getter
go run . go.mod tmpdir
diff tmpdir/go.mod go.mod
- name: Run Go tests
shell: bash
working-directory: ${{ matrix.directory }}
run: |
PACKAGE_NAMES=$(go list ./...)
echo "Running $(echo $PACKAGE_NAMES | wc -w) packages"
echo $PACKAGE_NAMES
gotestsum --format=short-verbose --junitfile $TEST_RESULTS_PATH/go-getter/gotestsum-report.xml -- -p 2 $PACKAGE_NAMES
# Save coverage report parts
- name: Upload and save artifacts
uses: actions/upload-artifact@v3
with:
name: windows test results
path: ${{ env.TEST_RESULTS_PATH }}
go-smb-tests:
runs-on: ubuntu-latest
strategy:
matrix:
go-version:
- "1.19"
- "1.20"
- "1.21"
permissions:
id-token: write
contents: read
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and start SMB server and gogetter containers
run: |
docker-compose build
docker-compose up -d
- name: Run SMB getter tests
run: docker exec -i gogetter bash -c "env ACC_SMB_TEST=1 go test -v ./... -run=TestSmb_"