-
Notifications
You must be signed in to change notification settings - Fork 9
102 lines (91 loc) · 3.26 KB
/
ci.yml
File metadata and controls
102 lines (91 loc) · 3.26 KB
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
name: synchros2 CI
on:
pull_request:
push:
branches:
- main
defaults:
run:
shell: bash
concurrency:
group: ${{ github.repository }}-${{ github.workflow }}-${{ github.ref }}-${{ github.ref == 'refs/heads/main' && github.sha || ''}}
cancel-in-progress: true
jobs:
lint:
name: Lint synchros2 packages
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/setup-python@v3
- name: Lint sources
uses: pre-commit/action@v3.0.0
prepare_container:
name: Prepare synchros2 containers
runs-on: ubuntu-22.04
needs: lint
strategy:
matrix:
rosdistro: [humble, jazzy]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Docker buildx # to workaround: https://github.com/docker/build-push-action/issues/461
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
- name: Extract metadata (tags, labels) for Docker
uses: docker/metadata-action@v5 # https://github.com/docker/metadata-action
with:
images: ${{ github.repository }}_on_${{ matrix.rosdistro }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
id: meta
- name: Build Docker image (may be cached)
uses: docker/build-push-action@v5 # https://github.com/docker/build-push-action
with:
context: .
file: .devcontainer/Dockerfile
build-args: |
ROS_DISTRO=${{ matrix.rosdistro }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=docker,dest=/tmp/${{ matrix.rosdistro }}_docker_image.tar
push: false
- name: Upload Docker image as artifact
uses: actions/upload-artifact@v4 # https://github.com/actions/upload-artifact
with:
name: ${{ matrix.rosdistro }}_docker_image
path: /tmp/${{ matrix.rosdistro }}_docker_image.tar
retention-days: 7
build_and_test:
name: Build and test synchros2 packages
runs-on: ubuntu-22.04
needs: prepare_container
strategy:
matrix:
rosdistro: [humble, jazzy]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download Docker image artifact
uses: actions/download-artifact@v5 # https://github.com/actions/download-artifact
with:
name: ${{ matrix.rosdistro }}_docker_image
path: /tmp
- name: Load Docker image
run: |
docker load -i /tmp/${{ matrix.rosdistro }}_docker_image.tar
- name: Build and run tests
run: |
docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace \
${{ github.repository }}_on_${{ matrix.rosdistro }}:sha-${{ github.sha }} bash -c " \
source /opt/ros/${{ matrix.rosdistro }}/setup.bash; \
colcon build --symlink-install; \
source install/setup.bash; \
colcon test --event-handlers console_direct+; \
colcon test-result --all --verbose"