-
Notifications
You must be signed in to change notification settings - Fork 63
175 lines (152 loc) · 5.89 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
name: CI
on:
pull_request:
push:
branches:
- main
workflow_call:
secrets:
CODECOV_TOKEN:
required: true
permissions:
contents: write
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: bdaiinstitute/spot_ros2_jammy_humble
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 spot_ros2 packages
runs-on: ubuntu-latest
strategy:
matrix:
config:
- { python: "3.10" }
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.config.python }}
- name: Lint sources
uses: pre-commit/[email protected]
prepare_container:
name: Prepare Humble container for tests
runs-on: ubuntu-latest
needs: lint
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
outputs:
image: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Docker buildx # to workaround: https://github.com/docker/build-push-action/issues/461
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3 # https://github.com/docker/login-action
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
uses: docker/metadata-action@v5 # https://github.com/docker/metadata-action
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
id: meta
- name: Build and push Docker image (may be cached)
uses: docker/build-push-action@v5 # https://github.com/docker/build-push-action
with:
context: .
file: .devcontainer/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build_and_test_package_and_docs:
name: Build and test spot_ros2 packages
runs-on: ubuntu-latest
needs: prepare_container
container:
image: ${{ needs.prepare_container.outputs.image }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- run: git config --global --add safe.directory $GITHUB_WORKSPACE
- name: Build packages
run: |
source /opt/ros/$ROS_DISTRO/setup.bash
colcon build --symlink-install --packages-up-to spot_driver spot_description spot_msgs spot_examples spot_ros2_control --cmake-args -DCMAKE_CXX_FLAGS="--coverage"
working-directory: ${{ github.workspace }}/../../
- name: Test non-spot-driver packages
run: |
source install/setup.bash
colcon test --event-handlers console_direct+ --packages-select spot_description spot_examples spot_msgs
working-directory: ${{ github.workspace }}/../../
# 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
- name: Test python part of spot-driver package
run: |
source install/setup.bash
pytest -n auto --cov-report xml --cov-config=$GITHUB_WORKSPACE/.coveragerc --cov-report term --cov=spot_driver $GITHUB_WORKSPACE/spot_driver/test/pytests/
working-directory: ${{ github.workspace }}/../../
- name: Test c++ part of spot-driver packages
run: |
source install/setup.bash
colcon test --event-handlers console_direct+ --packages-select spot_driver
working-directory: ${{ github.workspace }}/../../
- name: Generate coverage report
run: lcov -c -d build/spot_driver/ -o coverage_spot_driver.info --include "*/spot_driver/*" --exclude "*/test/*"
working-directory: ${{ github.workspace }}/../../
- name: Upload python coverage to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fail-on-error: true
flag-name: unittests-python
parallel: true
debug: true
files: $(find ../../ -name "coverage.xml" -type f)
- name: Upload cpp coverage to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fail-on-error: true
flag-name: unittests-cpp
debug: true
files: ../../coverage_spot_driver.info
format: lcov
- name: Aggregate coverage
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
carryforward: "unittests-python, unittests-cpp"
- if: always()
name: Report on test results
run: colcon test-result --all --verbose
working-directory: ${{ github.workspace }}/../../
- name: Build packages documentation
run: |
source /opt/ros/$ROS_DISTRO/setup.bash
pip install -r docs/requirements.txt
# go to documentation folder and build the .rst files
cd docs
# we don't use the --implicit-namespaces flag
sphinx-apidoc -f -o source/ ../ ../*setup* ../examples ../*launch.py ../*command_spot_driver.py
cd ..
sphinx-build docs _build -v