-
Notifications
You must be signed in to change notification settings - Fork 2
217 lines (198 loc) · 6.88 KB
/
ci.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
name: CI
run-name: |
CI test (${{inputs.uno-middleware||'default'}}, ${{inputs.base-image}}, ${{inputs.build-platform}}) ${{inputs.run-unit && '[U]' || ''}}${{inputs.run-unit && '[I]' || ''}}[${{github.ref_name}}${{github.ref_type == 'branch' && '@' || ''}}${{github.ref_type == 'branch' && github.sha || ''}}]
on:
workflow_call:
inputs:
uno-middleware:
type: string
base-image:
type: string
required: true
build-platform:
type: string
required: true
run-unit:
type: boolean
default: true
run-integration:
type: boolean
default: true
test-without-license:
type: boolean
default: false
workflow_dispatch:
inputs:
uno-middleware:
description: "uno middleware plugin"
type: string
base-image:
description: "base OS image"
type: string
required: true
build-platform:
description: "linux build platform"
type: string
required: true
run-unit:
description: "run unit tests"
type: boolean
default: true
run-integration:
description: "run integration tests"
type: boolean
default: true
test-without-license:
description: "test also without an RTI license"
type: boolean
default: true
concurrency:
group: ci-build-${{ github.ref }}-${{ inputs.uno-middleware || 'default' }}-${{ inputs.build-platform }}-${{ inputs.base-image }}-${{inputs.test-without-license}}
cancel-in-progress: true
permissions:
contents: read
packages: read
jobs:
config:
runs-on: ubuntu-latest
outputs:
RUNNER: ${{ fromJson(steps.config.outputs.RUNNER) }}
TEST_ARTIFACT: ${{ steps.config.outputs.TEST_ARTIFACT }}
TEST_IMAGE: ${{ steps.config.outputs.TEST_IMAGE }}
TEST_BASE_IMAGE: ${{ steps.config.outputs.TEST_BASE_IMAGE }}
TEST_DATE: ${{ steps.config.outputs.TEST_DATE }}
TEST_ID: ${{ steps.config.outputs.TEST_ID }}
steps:
- name: Clone uno
uses: actions/checkout@v4
with:
path: src/uno
submodules: true
- name: Generate build and test configuration
id: config
run: |
case "${{github.ref_type}}" in
tag)
image_version=${{github.ref_name}}
;;
*)
sha_short=$(cd src/uno && git rev-parse --short HEAD)
image_version=${{github.ref_name}}@${sha_short}
;;
esac
image_version="$(echo ${image_version} | tr / -)"
middleware_id=$(echo ${{inputs.uno-middleware}} | sed -e 's/uno.middleware.//')
base_image_tag=$(echo "${{ inputs.base-image }}" | tr : -)
license_tag=$([ "${{ inputs.test-without-license }}" = false ] || printf -- __static)
test_base_image=ghcr.io/mentalsmash/uno-ci-base-tester:${base_image_tag}
test_image=${{ github.repository }}-test-runner:latest
test_date=$(date +%Y%m%d-%H%M%S)
test_id=ci-${middleware_id:-default}-${{ inputs.build-platform }}__${image_version}${license_tag}
test_artifact=uno-test-${test_id}__${test_date}
(
case "${{ inputs.build-platform }}" in
arm64)
case "${{inputs.test-without-license}}" in
false)
# Force full test suite to run on "beefier" rpi5 nodes
printf -- "RUNNER='%s'\n" '["self-hosted", "linux", "arm64", "rpi5"]'
;;
true)
# Other test suites can run on any arm64 node
printf -- "RUNNER='%s'\n" '["self-hosted", "linux", "arm64"]'
;;
esac
;;
amd64)
printf -- "RUNNER='%s'\n" '"ubuntu-latest"'
;;
esac
echo TEST_IMAGE=${test_image}
echo TEST_ARTIFACT=${test_artifact}
echo TEST_ID=${test_id}
echo TEST_DATE=${test_date}
echo TEST_BASE_IMAGE=${test_base_image}
echo REG_TAG=${ref_tag}
) >> ${GITHUB_OUTPUT}
build-n-test:
needs: config
runs-on: ${{ fromJson(needs.config.outputs.RUNNER) }}
env:
IN_DOCKER: y
FIX_DIR: ${{ github.workspace }}
RTI_LICENSE_FILE: ${{ github.workspace }}/src/uno/rti_license.dat
TEST_DATE: ${{ needs.config.outputs.TEST_DATE }}
TEST_ID: ${{ needs.config.outputs.TEST_ID }}
TEST_IMAGE: ${{ needs.config.outputs.TEST_IMAGE }}
UNO_MIDDLEWARE: ${{ inputs.uno-middleware }}
steps:
- name: Clone uno
uses: actions/checkout@v4
with:
path: src/uno
submodules: true
- name: Validate code
run: |
make -C src/uno code-check
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Log in to GitHub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build tester image
uses: docker/build-push-action@v5
with:
file: src/uno/docker/Dockerfile
tags: ${{ needs.config.outputs.TEST_IMAGE }}
load: true
context: src/uno
platforms: linux/${{ inputs.build-platform }}
build-args: |
TEST=y
BASE_IMAGE=${{ needs.config.outputs.TEST_BASE_IMAGE }}
UNO_MIDDLEWARE=${{ inputs.uno-middleware }}
- name: Set up integration tests
if: ${{ inputs.run-integration }}
run: |
make -C src/uno extract-license
- name: Run unit tests
if: inputs.run-unit
run: |
make -C src/uno test-unit
env:
DEBUG: ${{ runner.debug }}
- name: Run unit tests (without license)
if: inputs.run-unit && inputs.test-without-license
run: |
make -C src/uno test-unit
env:
DEBUG: ${{ runner.debug }}
NO_LICENSE: y
- name: Run integration tests
if: inputs.run-integration && !inputs.test-without-license
run: |
make -C src/uno test-integration
env:
DEBUG: ${{ runner.debug }}
- name: Run integration tests (without license)
if: inputs.run-integration && inputs.test-without-license
run: |
make -C src/uno test-integration
env:
DEBUG: ${{ runner.debug }}
NO_LICENSE: y
- name: Restore permissions changed by integration tests
if: always()
run: |
make -C src/uno fix-file-ownership
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ needs.config.outputs.TEST_ARTIFACT }}
path: src/uno/test-results/*