-
Notifications
You must be signed in to change notification settings - Fork 1
291 lines (289 loc) · 10.9 KB
/
ci.yaml
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
280
281
282
283
284
285
286
287
288
289
290
291
name: Robocar Docker + ROS2 Build and Test Workflow
on:
workflow_dispatch:
pull_request:
branches:
- stable
push:
branches:
- stable
jobs:
build-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
strategy:
fail-fast: false
matrix:
include:
- SAVE_NAME: robocar_foxy_cpu
BASE_IMAGE: ubuntu:20.04
ROS_DISTRO: foxy
ROS_SOURCE: foxy
ROS_INSTALL: ros-install.sh
SKIP_KEYS: skip-keys
APT_FILE: apt-packages
APT_GPU_FILE: empty-deps
PIP_FILE: pip3-packages
PIP_GPU_FILE: empty-deps
PYTORCH_FILE: pytorch-cpu
EXPORTS_SCRIPT: exports.sh
EXPORTS_GPU_SCRIPT: empty-script.sh
VCS_IMPORTS_SCRIPT: vcs-imports-foxy.sh
CUSTOM_INSTALL_FILE: custom-installs.sh
CYCLONEDDS_SCRIPT: cyclonedds-foxy.xml
outputs:
image_name: ${{ steps.save_image_name.outputs.image_name }}
cache_name: ${{ steps.save_image_name.outputs.cache_name }}
tag_name: ${{ steps.save_image_name.outputs.tag_name }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Setup SSH
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
install: true
- name: Get the Ref
id: get-ref
uses: sisaha9/ref-to-tag-action@v2
with:
ref: ${{ github.ref }}
head_ref: ${{ github.head_ref }}
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@v1.3.1
with:
tool-cache: true
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache-${{ matrix.SAVE_NAME }}
key: ${{ runner.os }}-buildx-dev-${{ matrix.SAVE_NAME }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-dev-${{ matrix.SAVE_NAME }}
${{ runner.os }}-buildx-dev
- name: Build and Push Docker image
id: docker_build_push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64
context: .
file: tools/image/Dockerfile
pull: true
push: true
tags: |
ghcr.io/triton-ai/${{ matrix.SAVE_NAME }}:${{ steps.get-ref.outputs.tag }}
ssh: |
default=${{ env.SSH_AUTH_SOCK }}
cache-from: type=local,src=/tmp/.buildx-cache-${{ matrix.SAVE_NAME }}
cache-to: type=local,dest=/tmp/.buildx-cache-new-${{ matrix.SAVE_NAME }},mode=max
build-args: |
BASE_IMAGE=${{ matrix.BASE_IMAGE }}
ROS_DISTRO=${{ matrix.ROS_DISTRO }}
ROS_SOURCE=${{ matrix.ROS_SOURCE }}
ROS_INSTALL=${{ matrix.ROS_INSTALL }}
SKIP_KEYS=${{ matrix.SKIP_KEYS }}
APT_FILE=${{ matrix.APT_FILE }}
APT_GPU_FILE=${{ matrix.APT_GPU_FILE }}
PIP_FILE=${{ matrix.PIP_FILE }}
PIP_GPU_FILE=${{ matrix.PIP_GPU_FILE }}
PYTORCH_FILE=${{ matrix.PYTORCH_FILE }}
EXPORTS_SCRIPT=${{ matrix.EXPORTS_SCRIPT }}
EXPORTS_GPU_SCRIPT=${{ matrix.EXPORTS_GPU_SCRIPT }}
VCS_IMPORTS_SCRIPT=${{ matrix.VCS_IMPORTS_SCRIPT }}
CUSTOM_INSTALL_FILE=${{ matrix.CUSTOM_INSTALL_FILE }}
CYCLONEDDS_SCRIPT=${{ matrix.CYCLONEDDS_SCRIPT }}
target: robocar_image
- name: Delete old cache
run: |
rm -rf /tmp/.buildx-cache-${{ matrix.SAVE_NAME }}
mv /tmp/.buildx-cache-new-${{ matrix.SAVE_NAME }} /tmp/.buildx-cache-${{ matrix.SAVE_NAME }}
- name: Save image name to Github Output
id: save_image_name
run: |
echo "image_name=ghcr.io/triton-ai/${{ matrix.SAVE_NAME }}:${{ steps.get-ref.outputs.tag }}" >> $GITHUB_OUTPUT
echo "cache_name=${{ matrix.SAVE_NAME }}" >> $GITHUB_OUTPUT
echo "tag_name=${{ steps.get-ref.outputs.tag }}" >> $GITHUB_OUTPUT
build-test:
runs-on: ubuntu-latest
needs: build-push
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
container:
image: ${{ needs.build-push.outputs.image_name }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Setup SSH
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Import External Repos
run: |
bash -c 'make vcs-import VCS_FILE=robocar.${ROS_DISTRO}.repos; \
make vcs-import VCS_FILE=drivers.${ROS_DISTRO}.repos'
- name: Ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ needs.build-push.outputs.cache_name }}-ccache
max-size: "500M"
- name: Restore build artifacts
uses: actions/cache/restore@v4
with:
path: |
install
build
key: ${{ needs.build-push.outputs.cache_name }}-ros2-artifacts--${{ github.sha }}
restore-keys: |
${{ needs.build-push.outputs.cache_name }}-ros2-artifacts
- name: Build Workspace
run: |
bash -ic 'make build-ci'
- name: Save build artifacts
uses: actions/cache/save@v4
with:
path: |
install
build
key: ${{ needs.build-push.outputs.cache_name }}-ros2-artifacts--${{ github.sha }}
- name: Run Tests
run: |
bash -ic 'make test-ci'
- name: Clean tests
run: |
bash -ic 'make clean-test'
# build-push-jetpack:
# runs-on: ubuntu-latest
# permissions:
# contents: read
# packages: write
# # This is used to complete the identity challenge
# # with sigstore/fulcio when running outside of PRs.
# id-token: write
# strategy:
# fail-fast: false
# matrix:
# include:
# - SAVE_NAME: robocar_foxy_gpu_jetpack5
# BASE_IMAGE: nvcr.io/nvidia/l4t-jetpack:r35.4.1
# ROS_DISTRO: foxy
# ROS_SOURCE: foxy
# ROS_INSTALL: ros-install.sh
# SKIP_KEYS: skip-keys
# APT_FILE: apt-packages-jetson
# APT_GPU_FILE: empty-deps
# PIP_FILE: pip3-packages-jetson
# PIP_GPU_FILE: empty-deps
# PYTORCH_FILE: pytorch-gpu-jetson
# EXPORTS_SCRIPT: exports-jetson.sh
# EXPORTS_GPU_SCRIPT: empty-script.sh
# VCS_IMPORTS_SCRIPT: vcs-imports-foxy-jetson.sh
# CUSTOM_INSTALL_FILE: custom-installs-jetson.sh
# CYCLONEDDS_SCRIPT: cyclonedds-foxy.xml
# outputs:
# image_name: ${{ steps.save_image_name.outputs.image_name }}
# cache_name: ${{ steps.save_image_name.outputs.cache_name }}
# tag_name: ${{ steps.save_image_name.outputs.tag_name }}
# steps:
# - name: Check out the repo
# uses: actions/checkout@v4
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
# with:
# platforms: linux/arm64/v8
# - name: Setup SSH
# uses: webfactory/ssh-agent@v0.9.0
# with:
# ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
# - name: Login to GitHub Container Registry
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: Set up Docker Buildx
# id: buildx
# uses: docker/setup-buildx-action@v3
# with:
# install: true
# - name: Get the Ref
# id: get-ref
# uses: sisaha9/ref-to-tag-action@v2
# with:
# ref: ${{ github.ref }}
# head_ref: ${{ github.head_ref }}
# - name: Free Disk Space (Ubuntu)
# uses: jlumbroso/free-disk-space@v1.3.1
# with:
# tool-cache: true
# - name: Cache Docker layers
# uses: actions/cache@v4
# with:
# path: /tmp/.buildx-cache-${{ matrix.SAVE_NAME }}
# key: ${{ runner.os }}-buildx-dev-${{ matrix.SAVE_NAME }}-${{ github.sha }}
# restore-keys: |
# ${{ runner.os }}-buildx-dev-${{ matrix.SAVE_NAME }}
# ${{ runner.os }}-buildx-dev
# - name: Build and Push Docker image
# id: docker_build_push
# uses: docker/build-push-action@v6
# with:
# platforms: linux/arm64/v8
# context: .
# file: tools/image/Dockerfile
# pull: true
# push: true
# tags: |
# ghcr.io/triton-ai/${{ matrix.SAVE_NAME }}:${{ steps.get-ref.outputs.tag }}
# ssh: |
# default=${{ env.SSH_AUTH_SOCK }}
# cache-from: type=local,src=/tmp/.buildx-cache-${{ matrix.SAVE_NAME }}
# cache-to: type=local,dest=/tmp/.buildx-cache-new-${{ matrix.SAVE_NAME }},mode=max
# build-args: |
# BASE_IMAGE=${{ matrix.BASE_IMAGE }}
# ROS_DISTRO=${{ matrix.ROS_DISTRO }}
# ROS_SOURCE=${{ matrix.ROS_SOURCE }}
# ROS_INSTALL=${{ matrix.ROS_INSTALL }}
# SKIP_KEYS=${{ matrix.SKIP_KEYS }}
# APT_FILE=${{ matrix.APT_FILE }}
# APT_GPU_FILE=${{ matrix.APT_GPU_FILE }}
# PIP_FILE=${{ matrix.PIP_FILE }}
# PIP_GPU_FILE=${{ matrix.PIP_GPU_FILE }}
# PYTORCH_FILE=${{ matrix.PYTORCH_FILE }}
# EXPORTS_SCRIPT=${{ matrix.EXPORTS_SCRIPT }}
# EXPORTS_GPU_SCRIPT=${{ matrix.EXPORTS_GPU_SCRIPT }}
# VCS_IMPORTS_SCRIPT=${{ matrix.VCS_IMPORTS_SCRIPT }}
# CUSTOM_INSTALL_FILE=${{ matrix.CUSTOM_INSTALL_FILE }}
# CYCLONEDDS_SCRIPT=${{ matrix.CYCLONEDDS_SCRIPT }}
# target: robocar_image
# - name: Delete old cache
# run: |
# rm -rf /tmp/.buildx-cache-${{ matrix.SAVE_NAME }}
# mv /tmp/.buildx-cache-new-${{ matrix.SAVE_NAME }} /tmp/.buildx-cache-${{ matrix.SAVE_NAME }}
# - name: Save image name to Github Output
# id: save_image_name
# run: |
# echo "image_name=ghcr.io/triton-ai/${{ matrix.SAVE_NAME }}:${{ steps.get-ref.outputs.tag }}" >> $GITHUB_OUTPUT
# echo "cache_name=${{ matrix.SAVE_NAME }}" >> $GITHUB_OUTPUT
# echo "tag_name=${{ steps.get-ref.outputs.tag }}" >> $GITHUB_OUTPUT