-
Notifications
You must be signed in to change notification settings - Fork 1
262 lines (230 loc) · 9.56 KB
/
build-s3-migration.yaml
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
name: build-s3-migration
concurrency:
group: "publish-${{ github.ref }}"
cancel-in-progress: true
on:
push:
branches: [ master, staging, sprint* ]
tags:
- 'v*.*.*'
pull_request:
workflow_dispatch:
jobs:
build-linux:
name: Build-linux
runs-on: [self-hosted, arc-runner]
steps:
- name: Setup go 1.20
uses: actions/setup-go@v3
with:
go-version: '1.20' # The Go version to download (if necessary) and use.
- name: Checkout
uses: actions/checkout@v2
- name: Get Branch
id: get_branch
run: |
BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//-/g')
echo ::set-output name=BRANCH::${BRANCH}
echo $BRANCH
- name: Set GITHUB_ENV
run: |
echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
if [[ "${{github.base_ref}}" == "master" || "${{github.ref}}" == "refs/heads/master" ]]; then
echo "TAG=v0.0.0-master" >> $GITHUB_ENV
elif [[ "${{github.base_ref}}" == "dev" || "${{github.ref}}" == "refs/heads/dev" ]]; then
echo "TAG=v0.0.0-dev" >> $GITHUB_ENV
elif [[ "${{github.base_ref}}" == "staging" || "${{github.ref}}" == "refs/heads/staging" ]]; then
echo "TAG=v0.0.0-staging" >> $GITHUB_ENV
else
echo "TAG=v0.0.0-${{github.base_ref}}" >> $GITHUB_ENV
fi
- name: add dependencies
run: |
sudo apt update -y
sudo apt -y install build-essential nghttp2 libnghttp2-dev libssl-dev wget unzip containerd docker.io
- name: Install
run: |
docker run --rm -v $PWD:/s3mgrt --workdir=/s3mgrt golang:1.20.4 make build
# - name: Zip release
# run: tar -czvf s3mgrt-linux.tar.gz ./s3mgrt
# - name: Upload binaries to release
# uses: svenstaro/upload-release-action@v2
# with:
# repo_token: ${{ secrets.GITHUB_TOKEN }}
# file: s3mgrt-linux.tar.gz
# tag: ${{ env.TAG }}
# overwrite: true
# file_glob: true
- name: Install AWS
if: github.ref == 'refs/heads/staging'
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
- name: Set AWS credentials
if: github.ref == 'refs/heads/staging'
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.S3_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.S3_SECRET_KEY }}
aws-region: us-east-2
- name: Push to AWS S3
if: github.ref == 'refs/heads/staging'
run: |
aws s3 cp s3mgrt s3://${{ secrets.S3_MGRT_BINARY_BUCKET }}/s3mgrt
- name: 'Upload Artifact'
uses: actions/upload-artifact@v2
with:
name: s3mgrt-linux
path: s3mgrt
retention-days: 5
# build-windows:
# name: Build-windows
# runs-on: windows-latest
# steps:
# - name: Setup go 1.18
# uses: actions/setup-go@v2
# with:
# go-version: '1.18' # The Go version to download (if necessary) and use.
# - name: Checkout
# uses: actions/checkout@v2
# - name: Set GITHUB_ENV
# run: |
# IF ( "${{github.base_ref}}" -eq "master" -OR "${{github.ref}}" -eq "refs/heads/master" ){
# echo "TAG=v0.0.0-master" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
# } ElseIf ( "${{github.base_ref}}" -eq "dev" -OR "${{github.ref}}" -eq "refs/heads/dev" ){
# echo "TAG=v0.0.0-dev" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
# } ElseIf ( "${{github.base_ref}}" -eq "staging" -OR "${{github.ref}}" -eq "refs/heads/staging" ){
# echo "TAG=v0.0.0-staging" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
# } ELSE {
# echo "TAG=v0.0.0-${{github.base_ref}}" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
# }
# - name: Install
# run: make build
# # - name: Zip Release
# # run: |
# # copy s3mgrt s3mgrt.exe
# # 7z a s3mgrt-windows.zip s3mgrt.exe
# # - name: Upload binaries to release
# # uses: svenstaro/upload-release-action@v2
# # with:
# # repo_token: ${{ secrets.GITHUB_TOKEN }}
# # file: s3mgrt-windows.zip
# # tag: ${{ env.TAG }}
# # overwrite: true
# # file_glob: true
# - name: 'Upload Artifact'
# uses: actions/upload-artifact@v2
# with:
# name: s3mgrt-windows
# path: s3mgrt
# retention-days: 5
# build-macos:
# name: Build-macos
# runs-on: macos-runner
# steps:
# - name: Setup go 1.18
# uses: actions/setup-go@v2
# with:
# go-version: '1.18' # The Go version to download (if necessary) and use.
# - name: Checkout
# uses: actions/checkout@v2
# - name: Set GITHUB_ENV
# run: |
# echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
# if [[ "${{github.base_ref}}" == "master" || "${{github.ref}}" == "refs/heads/master" ]]; then
# echo "TAG=v0.0.0-master" >> $GITHUB_ENV
# elif [[ "${{github.base_ref}}" == "dev" || "${{github.ref}}" == "refs/heads/dev" ]]; then
# echo "TAG=v0.0.0-dev" >> $GITHUB_ENV
# elif [[ "${{github.base_ref}}" == "staging" || "${{github.ref}}" == "refs/heads/staging" ]]; then
# echo "TAG=v0.0.0-staging" >> $GITHUB_ENV
# else
# echo "TAG=v0.0.0-${{github.base_ref}}" >> $GITHUB_ENV
# fi
# - name: Install
# run: make build
# # - name: Zip release
# # run: tar -czvf s3mgrt-macos.tar.gz ./s3mgrt
# # - name: Upload binaries to release
# # uses: svenstaro/upload-release-action@v2
# # with:
# # repo_token: ${{ secrets.GITHUB_TOKEN }}
# # file: s3mgrt-macos.tar.gz
# # tag: ${{ env.TAG }}
# # overwrite: true
# # file_glob: true
# - name: 'Upload Artifact'
# uses: actions/upload-artifact@v2
# with:
# name: s3mgrt-macos
# path: s3mgrt
# retention-days: 5
system-tests:
if: github.event_name != 'workflow_dispatch'
needs: build-linux
runs-on: [ tests-suite ]
timeout-minutes: 120
steps:
- name: "Get current PR"
uses: jwalton/gh-find-current-pr@v1
id: findPr
with:
github-token: ${{ github.token }}
- name: "Setup Test Run"
run: |
echo "NETWORK_URL=$(echo dev-${RUNNER_NAME:(-1)}.devnet-0chain.net)" >> $GITHUB_ENV
echo "RUNNER_NUMBER=${RUNNER_NAME:(-1)}" >> $GITHUB_ENV
echo "CURRENT_BRANCH=$(echo $(([ -z '${{ github.head_ref }}' ] && echo ${GITHUB_REF#refs/*/}) || echo '${{ github.head_ref }}'))" >> $GITHUB_ENV
- name: "Set PR status as pending"
uses: 0chain/actions/set-pr-status@master
if: steps.findPr.outputs.number
with:
pr_number: ${{ steps.findPr.outputs.pr }}
description: "System tests running with default config..."
state: "pending"
repository: ${{ github.repository }}
status_name: "0Chain System Tests"
target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
github_token: ${{ github.token }}
- name: "Deploy 0Chain"
uses: 0chain/actions/deploy-0chain@master
with:
repo_snapshots_branch: "<CURRENT BRANCH WITH FALLBACK TO CURRENT_SPRINT>"
kube_config: ${{ secrets[format('DEV{0}KC', env.RUNNER_NUMBER)] }}
svc_account_secret: ${{ secrets.SVC_ACCOUNT_SECRET }}
teardown_condition: "TESTS_PASSED"
SUBGRAPH_API_URL: ${{ secrets.SUBGRAPH_API_URL }}
TENDERLY_FORK_ID: ${{ secrets.TENDERLY_FORK_ID }}
graphnode_sc: ${{ secrets.GRAPHNODE_SC }}
graphnode_network: ${{ secrets.GRAPHNODE_NETWORK }}
graphnode_ethereum_node_url: https://rpc.tenderly.co/fork/${{ secrets.TENDERLY_FORK_ID }}
- name: "Run System tests"
uses: 0chain/actions/run-system-tests@master
with:
repo_snapshots_branch: "<CURRENT BRANCH WITH FALLBACK TO CURRENT_SPRINT>"
network: ${{ env.NETWORK_URL }}
svc_account_secret: ${{ secrets.SVC_ACCOUNT_SECRET }}
deploy_report_page: false
archive_results: true
run_flaky_tests: false
run_smoke_tests: false
retry_failures: true
TENDERLY_FORK_ID: ${{ secrets.TENDERLY_FORK_ID }}
DEVOPS_CHANNEL_WEBHOOK_URL: ${{ secrets.DEVOPS_CHANNEL_WEBHOOK_URL }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}
s3_migration_cli_branch: ${{ env.CURRENT_BRANCH }}
run_api_system_tests: false
run_cli_system_tests: false
run_s3mgrt_system_tests: true
- name: "Set PR status as ${{ job.status }}"
if: ${{ (success() || failure()) && steps.findPr.outputs.number }}
uses: 0chain/actions/set-pr-status@master
with:
pr_number: ${{ steps.findPr.outputs.pr }}
description: "System tests with default config ${{ job.status }}"
state: ${{ job.status }}
repository: ${{ github.repository }}
status_name: "0Chain System Tests"
target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
github_token: ${{ github.token }}