Skip to content

[SW-1106] using custom launch actions from synchros2 #1074

[SW-1106] using custom launch actions from synchros2

[SW-1106] using custom launch actions from synchros2 #1074

Workflow file for this run

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