-
Notifications
You must be signed in to change notification settings - Fork 110
279 lines (239 loc) · 10.4 KB
/
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
name: Test
on:
workflow_dispatch:
workflow_call:
secrets:
MONGODB_TEST_OUTPUT_URI:
required: true
DOCKER_PUBLIC_READONLY_PAT:
required: true
env:
MONGODB_TEST_OUTPUT_URI: ${{ secrets.MONGODB_TEST_OUTPUT_URI }}
jobs:
# test_go:
# # note: we have automations that match on platform_name. be careful changing this.
# name: ${{ matrix.platform_name }} Go Unit Tests
# strategy:
# fail-fast: false
# matrix:
# include:
# - arch: ubuntu-large
# image: ghcr.io/viamrobotics/rdk-devenv:amd64-cache
# platform: linux/amd64
# platform_name: linux-amd64
# - arch: ubuntu-large-arm
# image: ghcr.io/viamrobotics/rdk-devenv:arm64-cache
# platform: linux/arm64
# platform_name: linux-arm64
# runs-on: ${{ matrix.arch }}
# container:
# image: ${{ matrix.image }}
# options: --platform ${{ matrix.platform }}
# timeout-minutes: 30
# steps:
# - uses: actions/checkout@v3
# with:
# ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.event.ref }}
# - uses: actions/setup-python@v5
# with:
# cache: 'pip'
# - name: Set main env vars
# if: github.event_name != 'pull_request_target'
# run: |
# echo "GITHUB_X_HEAD_SHA=${GITHUB_SHA}" >> $GITHUB_ENV
# echo "GITHUB_X_HEAD_REF=${GITHUB_REF_NAME}" >> $GITHUB_ENV
# - name: Set PR env vars
# if: github.event_name == 'pull_request_target'
# env:
# GITHUB_HEAD_REF_SAN: ${{ github.event.pull_request.head.label }}
# run: |
# echo "GITHUB_X_HEAD_SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
# echo "GITHUB_X_HEAD_REF=${GITHUB_HEAD_REF_SAN}" >> $GITHUB_ENV
# echo "GITHUB_X_PR_BASE_SHA=${{ github.event.pull_request.base.sha }}" >> $GITHUB_ENV
# echo "GITHUB_X_PR_BASE_REF=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV
# - name: Chown
# run: chown -R testbot:testbot .
# - name: Run go unit tests
# run: |
# chmod -R a+rwx . # temporary fix for arm runners
# sudo apt update
# sudo apt install -y python3.11-venv
# sudo --preserve-env=MONGODB_TEST_OUTPUT_URI,GITHUB_SHA,GITHUB_RUN_ID,GITHUB_RUN_NUMBER,GITHUB_RUN_ATTEMPT,GITHUB_X_PR_BASE_SHA,GITHUB_X_PR_BASE_REF,GITHUB_X_HEAD_REF,GITHUB_X_HEAD_SHA,GITHUB_REPOSITORY -Hu testbot bash -lc 'make test-go'
# - name: Upload test.json
# if: always()
# uses: actions/upload-artifact@v3
# with:
# name: test-${{ matrix.platform_name }}.json
# path: json.log
# retention-days: 30
# test_coverage:
# name: Go Coverage Tests
# if: false # toggle this off, delete after 3/1/24 if nobody misses it
# # note: we split 'test_go' and 'test_coverage' steps because running race-detection + covprofile simultaneously is slow enough to cause flakes
# strategy:
# fail-fast: false
# matrix:
# include:
# - arch: ubuntu-large
# image: ghcr.io/viamrobotics/rdk-devenv:amd64-cache
# platform: linux/amd64
# platform_name: linux-amd64
# - arch: ubuntu-large-arm
# image: ghcr.io/viamrobotics/rdk-devenv:arm64-cache
# platform: linux/arm64
# platform_name: linux-arm64
# runs-on: ${{ matrix.arch }}
# container:
# image: ${{ matrix.image }}
# options: --platform ${{ matrix.platform }}
# timeout-minutes: 30
# steps:
# - uses: actions/checkout@v3
# with:
# ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.event.ref }}
# fetch-depth: ${{ github.event_name == 'pull_request_target' && '0' || '1' }} # 0 aka full history, so we can analyze history for coverage
# - name: Set main env vars
# if: github.event_name != 'pull_request_target'
# run: |
# echo "GITHUB_X_HEAD_SHA=${GITHUB_SHA}" >> $GITHUB_ENV
# echo "GITHUB_X_HEAD_REF=${GITHUB_REF_NAME}" >> $GITHUB_ENV
# - name: Set PR env vars
# if: github.event_name == 'pull_request_target'
# env:
# GITHUB_HEAD_REF_SAN: ${{ github.event.pull_request.head.label }}
# run: |
# echo "GITHUB_X_HEAD_SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
# echo "GITHUB_X_HEAD_REF=${GITHUB_HEAD_REF_SAN}" >> $GITHUB_ENV
# echo "GITHUB_X_PR_BASE_SHA=${{ github.event.pull_request.base.sha }}" >> $GITHUB_ENV
# echo "GITHUB_X_PR_BASE_REF=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV
# - name: chown
# run: chown -R testbot:testbot .
# - name: Verify no uncommitted changes from "make build-go lint-go generate-go"
# run: |
# sudo -Hu testbot bash -lc 'git init && git add . && make build-go lint-go generate-go'
# GEN_DIFF=$(git status -s)
# if [ -n "$GEN_DIFF" ]; then
# echo '"make build-go lint-go generate-go" resulted in changes not in git' 1>&2
# git status
# exit 1
# fi
# - name: Run go coverage tests
# run: |
# sudo --preserve-env=MONGODB_TEST_OUTPUT_URI,GITHUB_SHA,GITHUB_RUN_ID,GITHUB_RUN_NUMBER,GITHUB_RUN_ATTEMPT,GITHUB_X_PR_BASE_SHA,GITHUB_X_PR_BASE_REF,GITHUB_X_HEAD_REF,GITHUB_X_HEAD_SHA,GITHUB_REPOSITORY -Hu testbot bash -lc 'make cover-only'
# - name: Upload code coverage
# uses: actions/upload-artifact@v3
# with:
# name: pr-code-coverage
# path: |
# pr.env
# code-coverage-results.md
# retention-days: 1
test32:
name: Go 32-bit Unit Tests
runs-on: ubuntu-large-arm
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }}
- uses: docker/login-action@v2
with:
username: viambuild
password: ${{ secrets.DOCKER_PUBLIC_READONLY_PAT }}
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Run go unit tests
run: |
chmod -R a+rwx . # temporary fix for arm runners
docker run \
--platform linux/arm/v7 \
-v `pwd`:/rdk \
ghcr.io/viamrobotics/rdk-devenv:armhf-cache \
sudo -Hu testbot bash -lc 'apt update && apt install -y python3.11-venv && cd /rdk && go test -v -tags=no_tflite ./...'
# test_pi:
# name: Test Raspberry Pi Code
# runs-on: pi4
# timeout-minutes: 5
# steps:
# - name: Clean workspace
# run: |
# shopt -s dotglob
# sudo chown -R `whoami` ./
# rm -rf ./*
# - uses: actions/checkout@v3
# with:
# ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }}
# - name: Run go unit tests on Pi
# run: make test-pi
# motion_tests:
# name: Test Longer-running Motion Plans if affected
# uses: viamrobotics/rdk/.github/workflows/motion-tests.yml@main
# jsonschema:
# name: Test meta.json jsonschema
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-go@v5
# - uses: actions/setup-python@v5
# with:
# cache-dependency-path: cli/test-requirements.txt
# - run: |
# go run ./cli/viam/ module create --local-only --name schematest --public-namespace ns
# cat meta.json | jq '.models = [{"api": "x:y:z", "model": "x:y:z"}]' > meta2.json
# pip install -r cli/test-requirements.txt
# check-jsonschema --schemafile ./cli/module.schema.json meta2.json
# test_web_e2e:
# name: Test End-to-End and Web
# runs-on: ubuntu-latest
# container: ghcr.io/viamrobotics/rdk-devenv:amd64-cache
# timeout-minutes: 15
# steps:
# - uses: actions/checkout@v3
# with:
# ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }}
# - name: Chown
# run: chown -R testbot:testbot .
# - name: Verify no uncommitted changes from "make build-web lint-web"
# run: |
# sudo -Hu testbot bash -lc 'git init && git add . && make build-web lint-web'
# GEN_DIFF=$(git status -s)
# if [ -n "$GEN_DIFF" ]; then
# echo '"make build-web lint-web" resulted in changes not in git' 1>&2
# git status
# exit 1
# fi
# - name: Install dependencies
# run: |
# apt-get update && apt-get -qy install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb netcat-openbsd lsof
# - name: Run web tests
# run: sudo -Hu testbot bash -lc 'make test-web'
# - name: Run e2e tests
# run: sudo -Hu testbot bash -lc 'make test-e2e E2E_ARGS="-k"'
# test_passing:
# name: All Tests Passing
# needs: [test_go, test_web_e2e, test_pi, test32, motion_tests]
# runs-on: [ubuntu-latest]
# if: always()
# steps:
# - name: Check Results
# run: |
# echo Go Unit Tests: ${{ needs.test_go.result }}
# echo Go 32-bit Tests: ${{ needs.test32.result }}
# echo Go Pi Tests: ${{ needs.test_pi.result }}
# echo Web/E2E Tests: ${{ needs.test_web_e2e.result }}
# echo Motion Tests: ${{ needs.motion_tests.result }}
# [ "${{ needs.test_go.result }}" == "success" ] && \
# [ "${{ needs.test32.result }}" == "success" ] && \
# [ "${{ needs.test_pi.result }}" == "success" ] && \
# [ "${{ needs.test_web_e2e.result }}" == "success" ] && \
# [ "${{ needs.motion_tests.result }}" == "success" ]
# # Now that RDK is public, can't directly comment without token having full read/write access
# # code-coverage-comment.yml will trigger seperately and post the actual comments
# - name: Prepare code comment
# run: echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> pr.env
# - name: Mark appimage label
# if: contains(github.event.pull_request.labels.*.name, 'appimage') || contains(github.event.pull_request.labels.*.name, 'appimage-ignore-tests')
# run: echo "APPIMAGE=true" >> pr.env
# - name: Mark static label
# if: contains(github.event.pull_request.labels.*.name, 'static-build') || contains(github.event.pull_request.labels.*.name, 'static-ignore-tests')
# run: echo "STATIC=true" >> pr.env