-
Notifications
You must be signed in to change notification settings - Fork 110
218 lines (190 loc) · 7.64 KB
/
staticbuild.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
name: Build Semi-Static Binary
on:
workflow_dispatch:
inputs:
release_type:
required: true
type: string
workflow_call:
inputs:
release_type:
required: true
type: string
secrets:
GCP_CREDENTIALS:
required: true
jobs:
build_timestamp:
name: Set Build Timestamp
runs-on: ubuntu-latest
outputs:
date: ${{ steps.build_time.outputs.date }}
steps:
- name: Build Time
id: build_time
if: inputs.release_type == 'latest'
run: echo "date=`date +%Y%m%d%H%M%S`" >> $GITHUB_OUTPUT
static:
name: Antique Build
needs: build_timestamp
strategy:
fail-fast: false
matrix:
include:
- arch: ubuntu-latest
image: ghcr.io/viamrobotics/antique2:amd64-cache
platform: linux/amd64
- arch: ubuntu-small-arm
image: ghcr.io/viamrobotics/antique2:arm64-cache
platform: linux/arm64
runs-on: ${{ matrix.arch }}
container:
image: ${{ matrix.image }}
options: --platform ${{ matrix.platform }}
timeout-minutes: 15
outputs:
date: ${{ steps.build_date.outputs.date }}
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: 'true'
steps:
- name: Check out code
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
uses: actions/checkout@v3
- name: Check out PR branch code
if: github.event_name == 'pull_request_target'
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Clean and Fix Permissions
run: |
chown -R testbot:testbot .
sudo -Hu testbot bash -lc 'make clean-all'
- name: Authorize GCP Upload
uses: google-github-actions/[email protected]
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
- name: Build (PR)
if: contains(github.event.pull_request.labels.*.name, 'static-build') || contains(github.event.pull_request.labels.*.name, 'static-ignore-tests')
run: |
sudo -Hu testbot bash -lc 'make BUILD_CHANNEL="pr-${{ github.event.pull_request.number }}" static-release'
- name: Upload Files (PR)
if: contains(github.event.pull_request.labels.*.name, 'static-build') || contains(github.event.pull_request.labels.*.name, 'static-ignore-tests')
uses: google-github-actions/[email protected]
with:
headers: "cache-control: no-cache"
path: 'etc/packaging/static/deploy/'
destination: 'packages.viam.com/apps/viam-server/'
glob: 'viam-server-*'
parent: false
gzip: false
- name: Build (Latest)
if: inputs.release_type == 'latest'
run: |
sudo -Hu testbot bash -lc 'make RELEASE_TYPE="latest" BUILD_CHANNEL="${{needs.build_timestamp.outputs.date}}" static-release'
- name: Build (Tagged)
if: inputs.release_type == 'stable' || inputs.release_type == 'rc'
run: |
sudo -Hu testbot bash -lc 'make RELEASE_TYPE="${{ inputs.release_type }}" BUILD_CHANNEL="${{ github.ref_name }}" static-release'
- name: Set Date
id: build_date
run: echo "date=`date +%F`" >> $GITHUB_OUTPUT
- name: Upload Files (Testing)
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
uses: google-github-actions/[email protected]
with:
headers: "cache-control: no-cache"
path: 'etc/packaging/static/deploy/'
destination: 'packages.viam.com/apps/viam-server/testing/static/${{ steps.build_date.outputs.date }}/${{ github.sha }}/'
glob: 'viam-server-*'
parent: false
gzip: false
- name: Upload Manifest (Testing)
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
uses: google-github-actions/[email protected]
with:
headers: "cache-control: no-cache"
path: 'etc/packaging/static/manifest/'
destination: 'packages.viam.com/apps/viam-subsystems/testing/viam-server/${{ steps.build_date.outputs.date }}/${{ github.sha }}/'
glob: 'viam-server-*'
parent: false
gzip: false
output_summary:
name: Output Summary
runs-on: ubuntu-latest
needs: static
if: contains(github.event.pull_request.labels.*.name, 'static-build') || contains(github.event.pull_request.labels.*.name, 'static-ignore-tests')
steps:
- name: Output Summary
run: |
channel="pr-${{ github.event.pull_request.number }}"
echo "### Built Static Binaries for ${channel}" >> $GITHUB_STEP_SUMMARY
echo "- arm64: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-aarch64" >> $GITHUB_STEP_SUMMARY
echo "- x86_64: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-x86_64" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
static_test:
name: Static Test
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
strategy:
fail-fast: false
matrix:
arch: [[ubuntu-latest], [ubuntu-small-arm], [pi4], [pi5]]
needs: static
runs-on: ${{ matrix.arch }}
timeout-minutes: 15
outputs:
date: ${{ needs.static.outputs.date }}
steps:
- name: Clean Workspace
run: |
shopt -s dotglob
sudo chown -R `whoami` ./
rm -rf ./*
- name: Test Static Binary
run: |
channel="${{ github.ref_name }}"
# we call our main branch releases "latest"
if [ "$channel" = "main" ]; then
channel="latest"
fi
export TEST_DIR=`mktemp -d -t test-viam-server-XXXXXX`
cd $TEST_DIR
curl -o viam-server https://storage.googleapis.com/packages.viam.com/apps/viam-server/testing/static/${{ needs.static.outputs.date }}/${{ github.sha }}/viam-server-${channel}-`uname -m`
chmod 755 viam-server
export RAND_PORT=$((30000 + $RANDOM))
echo "{\"network\": {\"bind_address\":\"localhost:${RAND_PORT}\"}}" > test.json
./viam-server -config test.json &
curl --retry 5 --retry-delay 5 --retry-connrefused localhost:$RAND_PORT
export RET1=$?
kill %%
wait $!
export RET2=$?
cd - && rm -rf $TEST_DIR
[ $RET1 == 0 ] && [ $RET1 == 0 ]
static_deploy:
name: Static Deploy
needs: static_test
runs-on: ubuntu-latest
steps:
- name: Authorize GCP
uses: google-github-actions/[email protected]
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Publish Static Binary
run: |
gsutil mv "gs://packages.viam.com/apps/viam-server/testing/static/${{ needs.static_test.outputs.date }}/${{ github.sha }}/*" "gs://packages.viam.com/apps/viam-server/"
- name: Publish Subsystem Metadata
run: |
gsutil mv "gs://packages.viam.com/apps/viam-subsystems/testing/viam-server/${{ needs.static_test.outputs.date }}/${{ github.sha }}/*" "gs://packages.viam.com/apps/viam-subsystems/"
- name: Output Summary
run: |
channel="${{ github.ref_name }}"
# we call our main branch releases "latest"
if [ "$channel" == "main" ]; then
channel="latest"
fi
echo "### Built Static Binaries for ${channel}" >> $GITHUB_STEP_SUMMARY
echo "- arm64: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-aarch64" >> $GITHUB_STEP_SUMMARY
echo "- x86_64: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-x86_64" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY