Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 37 additions & 113 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
name: CI
name: spot_ros2 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:
Expand All @@ -42,21 +29,12 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.config.python }}

- name: Lint sources
uses: pre-commit/action@v3.0.1
prepare_container:
name: Prepare Humble container for tests
name: Prepare spot_ros2 Humble container for tests
runs-on: ubuntu-22.04
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
Expand All @@ -65,117 +43,63 @@ jobs:

- 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 }}
images: ${{ github.repository }}_humble
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
id: meta
- name: Build and push Docker image (may be cached)

- 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
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:
outputs: type=docker,dest=/tmp/humble_docker_image.tar
push: false

- name: Upload Docker image as artifact
uses: actions/upload-artifact@v4 # https://github.com/actions/upload-artifact
with:
name: humble_docker_image
path: /tmp/humble_docker_image.tar
retention-days: 7
build_and_test:
name: Build and test spot_ros2 packages
runs-on: ubuntu-22.04
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 spot_common --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 spot_common
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: Test spot_ros2_control
run: |
source install/setup.bash
colcon test --event-handlers console_direct+ --packages-select spot_ros2_control
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
- name: Download Docker image artifact
uses: actions/download-artifact@v5 # https://github.com/actions/download-artifact
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fail-on-error: true
flag-name: unittests-cpp
debug: true
files: ../../coverage_spot_driver.info
format: lcov
name: humble_docker_image
path: /tmp

- 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: Load Docker image
run: |
docker load -i /tmp/humble_docker_image.tar

- name: Build packages documentation
- name: Build and run tests
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
docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace \
${{ github.repository }}_humble:sha-${{ github.sha }} bash -c " \
source /opt/ros/humble/setup.bash; \
colcon build --symlink-install --packages-up-to spot_driver spot_examples spot_ros2_control; \
source install/setup.bash; \
colcon test --event-handlers console_direct+ --packages-select spot_examples spot_common spot_driver spot_ros2_control; \
colcon test-result --all --verbose"
26 changes: 0 additions & 26 deletions .github/workflows/maintenance.yml

This file was deleted.

Loading