-
Notifications
You must be signed in to change notification settings - Fork 28
194 lines (184 loc) · 6.27 KB
/
build.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
name: build
on:
push:
# Publish `master` as Docker `latest` image. Run only when the docker subdirectory is modified.
branches:
- master
# Run tests for any PRs that have changed a file in the docker subdirectory.
pull_request:
jobs:
check-docker:
runs-on: ubuntu-22.04
outputs:
docker: ${{ steps.filter.outputs.docker }}
steps:
- uses: actions/checkout@v3
- name: Check if docker directory has changed
uses: dorny/[email protected]
id: filter
with:
filters: |
docker:
- 'docker/**'
- '.github/workflows/**'
core-docker:
runs-on: ubuntu-22.04
needs: check-docker
if: needs.check-docker.outputs.docker == 'true'
strategy:
matrix:
arch: [arm64, amd64]
fail-fast: false
env:
IMAGE_NAME: 'dukerobotics/robosub-ros:core-${{ matrix.arch }}'
TARGETPLATFORM: 'linux/${{ matrix.arch }}'
SERVICE_NAME: core
BASE_IMAGE: dukerobotics/robosub-ros:base
FILE_NAME: '${{ matrix.arch }}-core.tar.gz'
CUDA: ${{ matrix.arch == 'arm64' }}
steps:
- uses: actions/checkout@v3
- name: Setup environment and build
run: |
./.github/workflows/build.sh
- name: Push image to dockerhub
if: github.event_name == 'push'
run: |
echo "${{ secrets.DOCKER_BOT_TOKEN }}" | docker login -u dukeroboticsbot --password-stdin
docker push ${IMAGE_NAME}
- name: Save image
run: |
docker save ${IMAGE_NAME} | gzip > ${FILE_NAME}
- name: Create artifact from image
uses: actions/upload-artifact@v3
with:
name: core
path: ${{ env.FILE_NAME }}
onboard-docker:
runs-on: ubuntu-22.04
needs: core-docker
strategy:
matrix:
arch: [arm64, amd64]
fail-fast: false
env:
IMAGE_NAME: 'dukerobotics/robosub-ros:onboard-${{ matrix.arch }}'
TARGETPLATFORM: 'linux/${{ matrix.arch }}'
SERVICE_NAME: onboard
BASE_IMAGE: 'dukerobotics/robosub-ros:core-${{ matrix.arch }}'
FILE_NAME: '${{ matrix.arch }}-core.tar.gz'
CUDA: ${{ matrix.arch == 'arm64' }}
steps:
- uses: actions/checkout@v3
- name: Get core image
uses: actions/download-artifact@v3
with:
name: core
path: core_im
- name: Load core image
run: |
docker load < ./core_im/${FILE_NAME}
rm -rf core_im
- name: Setup environment and build docker image
run: ./.github/workflows/build.sh
- name: Start containers
run: |
docker tag ${IMAGE_NAME} dukerobotics/robosub-ros:onboard
docker-compose up -d
- name: Test build
run: docker exec ${SERVICE_NAME} ./build.sh
- name: Test Arduino build
if: matrix.arch == 'amd64'
run: docker exec ${SERVICE_NAME} ./.github/workflows/test_arduino.sh
- name: Test ROS launchfiles
if: matrix.arch == 'amd64'
run: docker exec -t ${SERVICE_NAME} bash -lc "python ./scripts/test-launch.py"
- name: Push image to dockerhub
if: github.event_name == 'push'
run: |
echo "${{ secrets.DOCKER_BOT_TOKEN }}" | docker login -u dukeroboticsbot --password-stdin
docker push ${IMAGE_NAME}
push-docker:
runs-on: ubuntu-22.04
needs: [onboard-docker, landside-docker]
steps:
- uses: actions/checkout@v3
- name: Push images to latest on dockerhub
if: github.event_name == 'push'
run: |
./.github/workflows/setup.sh
echo "${{ secrets.DOCKER_BOT_TOKEN }}" | docker login -u dukeroboticsbot --password-stdin
docker buildx imagetools create --tag dukerobotics/robosub-ros:core dukerobotics/robosub-ros:core-amd64 dukerobotics/robosub-ros:core-arm64
docker buildx imagetools create --tag dukerobotics/robosub-ros:onboard dukerobotics/robosub-ros:onboard-amd64 dukerobotics/robosub-ros:onboard-arm64
cleanup-docker:
runs-on: ubuntu-22.04
needs: [check-docker, push-docker]
if: always() && (needs.check-docker.outputs.docker == 'true')
steps:
- uses: actions/checkout@v3
- name: Cleanup artifacts
uses: geekyeggo/delete-artifact@v2
with:
name: core
landside-docker:
runs-on: ubuntu-22.04
needs: core-docker
env:
IMAGE_NAME: dukerobotics/robosub-ros:landside
BASE_IMAGE: dukerobotics/robosub-ros:core-amd64
SERVICE_NAME: landside
steps:
- uses: actions/checkout@v3
- name: Get core image
uses: actions/download-artifact@v3
with:
name: core
path: core_im
- name: Load core image
run: |
docker load < ./core_im/amd64-core.tar.gz
rm -rf core_im
- name: Setup environment and build docker image
run: |
cd docker/${SERVICE_NAME}
docker build --build-arg BASE_IMAGE=${BASE_IMAGE} -t ${IMAGE_NAME} .
- name: Start containers
run: docker-compose up -d
- name: Test build
run: docker exec ${SERVICE_NAME} ./build.sh
- name: Test ROS launchfiles
run: docker exec -t ${SERVICE_NAME} bash -lc "python ./scripts/test-launch.py"
- name: Push image to dockerhub
if: github.event_name == 'push'
run: |
echo "${{ secrets.DOCKER_BOT_TOKEN }}" | docker login -u dukeroboticsbot --password-stdin
docker push ${IMAGE_NAME}
build-without-docker:
runs-on: ubuntu-22.04
needs: check-docker
if: needs.check-docker.outputs.docker == 'false'
strategy:
matrix:
workspace: [onboard, landside]
fail-fast: false
container: dukerobotics/robosub-ros:${{ matrix.workspace }}
steps:
- uses: actions/checkout@v3
- name: Test build
run: ./build.sh
- name: Test Arduino build
if: matrix.workspace == 'onboard'
run: ./.github/workflows/test_arduino.sh
- name: Test ROS launchfiles
shell: bash -elo pipefail {0}
run: |
source ${{ matrix.workspace }}/catkin_ws/devel/setup.bash
./scripts/test-launch.py
build-foxglove:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Build all Foxglove extensions
run: |
cd foxglove
./foxglove.py install -e