-
Notifications
You must be signed in to change notification settings - Fork 0
237 lines (206 loc) · 7.69 KB
/
unit-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
name: Unit-Tests
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
inputs:
manual:
description: 'Manual Run'
type: boolean
required: true
default: true
jobs:
linux-unit-test:
name: Build and Test on Linux
runs-on: ubuntu-latest
env:
go: '1.20'
cgo: ''
containerName: 'test-cnt-ubn'
AWS_ENDPOINT: http://localhost:4566
AWS_REGION: us-east-1
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
AWS_BUCKET_NAME: test
# Using default test credentials for Azurite
BLOB_ENDPOINT: http://127.0.0.1:10000/devstoreaccount1
BLOB_ACCOUNT: devstoreaccount1
BLOB_KEY: Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.go }}
check-latest: true
- run: go version
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Set CGO
shell: bash
run: |
if [[ "${{ env.cgo }}" != "" ]]; then echo 'CGO_ENABLED=${{ env.cgo }}' >> $GITHUB_ENV ; fi
- name: Install libfuse on Linux
shell: bash
run: |
sudo apt-get install fuse3 libfuse-dev rpm pkg-config
- name: Build
run: |
./build.sh
- name: Create Azure Configuration File on Linux
run: |-
cnfFile=$HOME/azuretest.json
echo $cnfFile
touch $cnfFile
echo "{" > $cnfFile
echo "\"block-acct\"": "\"${{ env.BLOB_ACCOUNT }}\"", >> $cnfFile
echo "\"block-key\"": "\"${{ env.BLOB_KEY }}\"", >> $cnfFile
echo "\"endpoint\"": "\"${{ env.BLOB_ENDPOINT }}\"", >> $cnfFile
echo "\"skip-msi\"": "true", >> $cnfFile
echo "\"proxy-address\"": "\"\"" >> $cnfFile
echo "}" >> $cnfFile
- name: Create S3 Configuration File on Linux
run: |-
cnfFile=$HOME/s3test.json
echo $cnfFile
touch $cnfFile
echo "{" > $cnfFile
echo "\"bucket-name\"": "\"${{ env.AWS_BUCKET_NAME }}\"", >> $cnfFile
echo "\"access-key\"": "\"${{ env.AWS_ACCESS_KEY_ID }}\"", >> $cnfFile
echo "\"secret-key\"": "\"${{ env.AWS_SECRET_ACCESS_KEY }}\"", >> $cnfFile
echo "\"endpoint\"": "\"${{ env.AWS_ENDPOINT }}\"", >> $cnfFile
echo "\"region\"": "\"${{ env.AWS_REGION }}\"", >> $cnfFile
echo "\"use-path-style\"": true\ >> $cnfFile
echo "}" >> $cnfFile
- name: Start LocalStack
run: |
pip install localstack awscli-local[ver1] # install LocalStack cli and awslocal
docker pull localstack/localstack # Make sure to pull the latest version of the image
localstack start -d # Start LocalStack in the background
echo "Waiting for LocalStack startup..." # Wait 20 seconds for the LocalStack container
localstack wait -t 20 # to become ready before timing out
echo "Startup complete"
- name: Install Azurite
run: npm install -g azurite
- name: Start Azurite
run: azurite --silent &
- name: Run some Tests against LocalStack
run: |
awslocal s3 mb s3://test
awslocal s3 ls
- name: Run unit tests
run: go test -v -timeout=1h ./... --tags=unittest,azurite
test:
name: Build and Test on Windows
runs-on: windows-latest
env:
go: '1.20'
cgo: '0'
containerName: 'test-cnt-win'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.go }}
check-latest: true
- run: go version
- name: Set CGO
shell: bash
run: |
if [[ "${{ env.cgo }}" != "" ]]; then echo 'CGO_ENABLED=${{ env.cgo }}' >> $GITHUB_ENV ; fi
- name: Build
run: |
./build.sh
- name: Create Azure Configuration File on Windows
run: |-
$cnfFile="~\azuretest.json"
Write-Host $cnfFile
$content = @"
{
"block-acct": "${{ secrets.AZTEST_BLOCK_ACC_NAME }}",
"adls-acct": "${{ secrets.AZTEST_ADLS_ACC_NAME }}",
"block-cont": "${{ env.containerName }}",
"adls-cont": "${{ env.containerName }}",
"block-key": "${{ secrets.AZTEST_BLOCK_KEY }}",
"adls-key": "${{ secrets.AZTEST_ADLS_KEY }}",
"block-sas": "${{ secrets.AZTEST_BLOCK_SAS }}",
"block-cont-sas-ubn-18": "${{ secrets.AZTEST_BLOCK_CONT_SAS_UBN_18 }}",
"block-cont-sas-ubn-20": "${{ secrets.AZTEST_BLOCK_CONT_SAS_UBN_20 }}",
"adls-sas": "${{ secrets.AZTEST_ADLS_SAS }}",
"msi-appid": "${{ secrets.AZTEST_APP_ID }}",
"msi-resid": "${{ secrets.AZTEST_RES_ID }}",
"msi-objid": "${{ secrets.AZTEST_OBJ_ID }}",
"spn-client": "${{ secrets.AZTEST_CLIENT }}",
"spn-tenant": "${{ secrets.AZTEST_TENANT }}",
"spn-secret": "${{ secrets.AZTEST_SECRET }}",
"skip-msi": true,
"proxy-address": ""
}
"@
$content | Out-File -FilePath $cnfFile -Encoding Ascii
shell: powershell
- name: Create S3 Configuration File on Windows
run: |-
$cnfFile="~\s3test.json"
Write-Host $cnfFile
$content = @"
{
"bucket-name": "${{ secrets.S3TEST_BUCKET_NAME }}",
"access-key": "${{ secrets.S3TEST_ACCESS_KEY }}",
"secret-key": "${{ secrets.S3TEST_SECRET_KEY }}",
"endpoint": "${{ secrets.S3TEST_ENDPOINT }}",
"region": "${{ secrets.S3TEST_REGION }}"
}
"@
$content | Out-File -FilePath $cnfFile -Encoding Ascii
shell: powershell
- name: Run unit tests
run: go test -v -timeout=1h ./... --tags=unittest
lint:
name: Lint
runs-on: ubuntu-latest
env:
go: '1.20'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.go }}
check-latest: true
- run: go version
- name: Set CGO
shell: bash
run: |
if [[ "${{ env.go }}" != "" ]]; then echo 'CGO_ENABLED=${{ env.go }}' >> $GITHUB_ENV ; fi
- name: Install libfuse on Linux
shell: bash
run: |
sudo apt-get install libfuse-dev
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: latest
# Optional: golangci-lint command line arguments.
args: --tests=false --timeout=5m --skip-dirs test,common/stats_collector,common/stats_monitor --skip-files component/libfuse/libfuse2_handler_test_wrapper.go --out-format=github-actions
- name: Notice file check
run: |
./notices_fix.sh
result=$(git diff NOTICE | wc -l)
if [ $result -ne 0 ]; then
echo "Notices needs a fix. Run ./notices_fix.sh and commit NOTICE file."
exit 1
else
echo "Notices are up to date."
fi