-
Notifications
You must be signed in to change notification settings - Fork 111
160 lines (140 loc) · 6 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
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 }}
- 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 the following untracked changes:' 1>&2
git diff
echo '"make build-go lint-go generate-go" resulted in changes not in git' 1>&2
git status
exit 1
fi
- name: Run go unit tests
run: |
chmod -R a+rwx . # temporary fix for arm runners
sudo apt-get install -y python3-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@v4
with:
name: test-${{ matrix.platform_name }}.json
path: json.log
retention-days: 30
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 'sudo apt-get install -y python3-venv && cd /rdk && go test -v ./...'
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
python -m venv .venv
source .venv/bin/activate
pip install -r cli/test-requirements.txt
check-jsonschema --schemafile ./cli/module.schema.json meta2.json
test_passing:
name: All Tests Passing
needs: [test_go, 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 Motion Tests: ${{ needs.motion_tests.result }}
[ "${{ needs.test_go.result }}" == "success" ] && \
[ "${{ needs.test32.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