1- name : CI
1+ name : spot_ros2 CI
22
33on :
44 pull_request :
55 push :
66 branches :
77 - main
8- workflow_call :
9- secrets :
10- CODECOV_TOKEN :
11- required : true
12-
13- permissions :
14- contents : write
15-
16- env :
17- # Use docker.io for Docker Hub if empty
18- REGISTRY : ghcr.io
19- # github.repository as <account>/<repo>
20- IMAGE_NAME : bdaiinstitute/spot_ros2_jammy_humble
218
229defaults :
2310 run :
@@ -42,21 +29,12 @@ jobs:
4229 - uses : actions/setup-python@v5
4330 with :
4431 python-version : ${{ matrix.config.python }}
45-
4632 - name : Lint sources
4733 uses : pre-commit/action@v3.0.1
4834 prepare_container :
49- name : Prepare Humble container for tests
35+ name : Prepare spot_ros2 Humble container for tests
5036 runs-on : ubuntu-22.04
5137 needs : lint
52- permissions :
53- contents : read
54- packages : write
55- # This is used to complete the identity challenge
56- # with sigstore/fulcio when running outside of PRs.
57- id-token : write
58- outputs :
59- image : ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
6038 steps :
6139 - name : Checkout repository
6240 uses : actions/checkout@v4
@@ -65,118 +43,63 @@ jobs:
6543
6644 - name : Setup Docker buildx # to workaround: https://github.com/docker/build-push-action/issues/461
6745 uses : docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
68-
69- - name : Log into registry ${{ env.REGISTRY }}
70- uses : docker/login-action@v3 # https://github.com/docker/login-action
71- with :
72- registry : ${{ env.REGISTRY }}
73- username : ${{ github.actor }}
74- password : ${{ secrets.GITHUB_TOKEN }}
75-
46+
7647 - name : Extract metadata (tags, labels) for Docker
7748 uses : docker/metadata-action@v5 # https://github.com/docker/metadata-action
7849 with :
79- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
50+ images : ${{ github.repository }}_humble
51+ tags : |
52+ type=schedule
53+ type=ref,event=branch
54+ type=ref,event=tag
55+ type=ref,event=pr
56+ type=sha,format=long
8057 id : meta
81-
82- - name : Build and push Docker image (may be cached)
58+
59+ - name : Build Docker image (may be cached)
8360 uses : docker/build-push-action@v5 # https://github.com/docker/build-push-action
8461 with :
8562 context : .
8663 file : .devcontainer/Dockerfile
87- push : true
8864 tags : ${{ steps.meta.outputs.tags }}
8965 labels : ${{ steps.meta.outputs.labels }}
9066 cache-from : type=gha
9167 cache-to : type=gha,mode=max
92- build_and_test_package_and_docs :
68+ outputs : type=docker,dest=/tmp/humble_docker_image.tar
69+ push : false
70+
71+ - name : Upload Docker image as artifact
72+ uses : actions/upload-artifact@v4 # https://github.com/actions/upload-artifact
73+ with :
74+ name : humble_docker_image
75+ path : /tmp/humble_docker_image.tar
76+ retention-days : 7
77+ build_and_test :
9378 name : Build and test spot_ros2 packages
9479 runs-on : ubuntu-22.04
9580 needs : prepare_container
96- container :
97- image : ${{ needs.prepare_container.outputs.image }}
9881 steps :
9982 - name : Checkout repository
10083 uses : actions/checkout@v4
10184 with :
10285 submodules : recursive
10386
104- - run : git config --global --add safe.directory $GITHUB_WORKSPACE
105-
106- - name : Build packages
107- run : |
108- source /opt/ros/$ROS_DISTRO/setup.bash
109- colcon build --symlink-install --packages-up-to spot_driver spot_description spot_msgs spot_examples spot_ros2_control spot_common spot_controllers --cmake-args -DCMAKE_CXX_FLAGS="--coverage"
110- working-directory : ${{ github.workspace }}/../../
111-
112- - name : Test non-spot-driver packages
113- run : |
114- source install/setup.bash
115- colcon test --event-handlers console_direct+ --packages-select spot_description spot_examples spot_msgs spot_common
116- working-directory : ${{ github.workspace }}/../../
117-
118- # Per https://github.com/colcon/colcon-ros/issues/151, `pytest-args` cannot be used in an ament_cmake package, so in order to pass arguments to pytest we have to run pytest directly
119- - name : Test python part of spot-driver package
120- run : |
121- source install/setup.bash
122- pytest -n auto --cov-report xml --cov-config=$GITHUB_WORKSPACE/.coveragerc --cov-report term --cov=spot_driver $GITHUB_WORKSPACE/spot_driver/test/pytests/
123- working-directory : ${{ github.workspace }}/../../
124-
125- - name : Test c++ part of spot-driver packages
126- run : |
127- source install/setup.bash
128- colcon test --event-handlers console_direct+ --packages-select spot_driver
129- working-directory : ${{ github.workspace }}/../../
130-
131- - name : Test spot_ros2_control
132- run : |
133- source install/setup.bash
134- colcon test --event-handlers console_direct+ --packages-select spot_ros2_control
135- working-directory : ${{ github.workspace }}/../../
136-
137- - name : Generate coverage report
138- run : lcov -c -d build/spot_driver/ -o coverage_spot_driver.info --include "*/spot_driver/*" --exclude "*/test/*"
139- working-directory : ${{ github.workspace }}/../../
140-
141- - name : Upload python coverage to Coveralls
142- uses : coverallsapp/github-action@v2
143- with :
144- github-token : ${{ secrets.GITHUB_TOKEN }}
145- fail-on-error : false
146- flag-name : unittests-python
147- parallel : true
148- debug : true
149- files : $(find ../../ -name "coverage.xml" -type f)
150-
151- - name : Upload cpp coverage to Coveralls
152- uses : coverallsapp/github-action@v2
87+ - name : Download Docker image artifact
88+ uses : actions/download-artifact@v5 # https://github.com/actions/download-artifact
15389 with :
154- github-token : ${{ secrets.GITHUB_TOKEN }}
155- fail-on-error : false
156- flag-name : unittests-cpp
157- debug : true
158- files : ../../coverage_spot_driver.info
159- format : lcov
90+ name : humble_docker_image
91+ path : /tmp
16092
161- - name : Aggregate coverage
162- uses : coverallsapp/github-action@v2
163- with :
164- parallel-finished : true
165- fail-on-error : false
166- carryforward : " unittests-python, unittests-cpp"
167-
168- - if : always()
169- name : Report on test results
170- run : colcon test-result --all --verbose
171- working-directory : ${{ github.workspace }}/../../
93+ - name : Load Docker image
94+ run : |
95+ docker load -i /tmp/humble_docker_image.tar
17296
173- - name : Build packages documentation
97+ - name : Build and run tests
17498 run : |
175- source /opt/ros/$ROS_DISTRO/setup.bash
176- pip install -r docs/requirements.txt
177- # go to documentation folder and build the .rst files
178- cd docs
179- # we don't use the --implicit-namespaces flag
180- sphinx-apidoc -f -o source/ ../ ../*setup* ../examples ../*launch.py ../*command_spot_driver.py
181- cd ..
182- sphinx-build docs _build -v
99+ docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace \
100+ ${{ github.repository }}_humble:sha-${{ github.sha }} bash -c " \
101+ source /opt/ros/humble/setup.bash; \
102+ colcon build --symlink-install --packages-up-to spot_driver spot_examples spot_ros2_control; \
103+ source install/setup.bash; \
104+ colcon test --event-handlers console_direct+ --packages-select spot_examples spot_common spot_driver spot_ros2_control; \
105+ colcon test-result --all --verbose"
0 commit comments