135 lines (117 loc) · 3.97 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
name: Test
on:
workflow_dispatch:
workflow_call:
secrets:
REPO_READ_TOKEN:
required: true
GIT_ACCESS_TOKEN:
required: true
ARTIFACT_READ_ONLY_GCP_CREDENTIALS:
required: true
env:
GOPRIVATE: "github.com/viamrobotics/*,go.viam.com/*"
GOOGLE_APPLICATION_CREDENTIALS_FILENAME: "google-credentials.json"
jobs:
build_and_test:
name: Build and Test
strategy:
matrix:
include:
- arch: [x64, qemu-host]
image: ghcr.io/viamrobotics/canon:amd64-cache
platform: linux/amd64
build_lint: 'make build lint'
- arch: [arm64, qemu-host]
image: ghcr.io/viamrobotics/canon:arm64-cache
platform: linux/arm64
build_lint: 'make build-go lint-go'
runs-on: ${{ matrix.arch }}
container:
image: ${{ matrix.image }}
options: --platform ${{ matrix.platform }}
timeout-minutes: 30
steps:
- name: Check out code in rdk directory
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Create GCP Credential File from secret
run: |
GOOGLE_APPLICATION_CREDENTIALS=`pwd`/${GOOGLE_APPLICATION_CREDENTIALS_FILENAME}
echo "${{ secrets.ARTIFACT_READ_ONLY_GCP_CREDENTIALS }}" >> ${GOOGLE_APPLICATION_CREDENTIALS}
echo "GOOGLE_APPLICATION_CREDENTIALS=${GOOGLE_APPLICATION_CREDENTIALS}" >> $GITHUB_ENV
- name: Configure git for private repos
run: |
sudo -u testbot bash -lc 'echo "machine github.com login viambot password ${{ secrets.REPO_READ_TOKEN }}" > ~/.netrc'
- name: Verify no uncommitted changes from "${{ matrix.build_lint }}"
run: |
git init
git add .
chown -R testbot .
sudo -u testbot bash -lc '${{ matrix.build_lint }}'
GEN_DIFF=$(git status -s)
if [ -n "$GEN_DIFF" ]; then
echo '"make build lint" resulted in changes not in git' 1>&2
git status
exit 1
fi
- name: Test
if: matrix.platform == 'linux/amd64'
run: |
sudo --preserve-env=GOOGLE_APPLICATION_CREDENTIALS -u testbot bash -lc 'make cover test-web'
- name: Code Coverage Summary Report
if: matrix.platform == 'linux/amd64'
uses: edaniels/CodeCoverageSummary@v1.2.3
with:
filename: coverage.xml
badge: true
fail_below_min: false
format: markdown
hide_branch_rate: true
hide_complexity: true
indicators: true
output: both
thresholds: '50 70'
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2.2.0
if: matrix.platform == 'linux/amd64' && github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md
GITHUB_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }}
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 ./*
- name: Check out code in rdk directory
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Create GCP Credential File from secret
run: |
GOOGLE_APPLICATION_CREDENTIALS=`pwd`/${GOOGLE_APPLICATION_CREDENTIALS_FILENAME}
echo "${{ secrets.ARTIFACT_READ_ONLY_GCP_CREDENTIALS }}" >> ${GOOGLE_APPLICATION_CREDENTIALS}
echo "GOOGLE_APPLICATION_CREDENTIALS=${GOOGLE_APPLICATION_CREDENTIALS}" >> $GITHUB_ENV
- name: Clean
run: make clean-all
- name: Test
run: make test-pi
test_passing:
name: All Tests Passing
needs: [test_pi, build_and_test]
runs-on: [x64, qemu-host]
if: always()
steps:
- name: Check Results
run: |
echo Test Pi: ${{ needs.test_pi.result }}
echo Main Tests: ${{ needs.build_and_test.result }}
[ "${{ needs.test_pi.result }}" == "success" ] && \
[ "${{ needs.build_and_test.result }}" == "success" ]