Rework CI to ensure up-to-date containers prior to builds #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
shell: bash | |
jobs: | |
lint: | |
name: Lint spot_ros2 packages | |
runs-on: ubuntu-latest | |
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 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@v3 | |
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@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c # 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@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 # 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@ac9327eae2b366085ac7f6a2d02df8aa8ead720a # 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@v3 | |
with: | |
submodules: recursive | |
path: src/spot_ros2 | |
- name: Build packages | |
run: | | |
source /opt/ros/$ROS_DISTRO/setup.bash | |
colcon build --symlink-install --packages-skip-regex proto2ros | |
- name: Test packages | |
run: | | |
source install/setup.bash | |
colcon test --python-testing pytest --pytest-with-coverage --event-handlers console_direct+ --packages-skip-regex bdai_ros2_wrappers proto2ros | |
- name: Upload test coverage to Coveralls | |
uses: coverallsapp/github-action@v2 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
fail-on-error: true | |
flag-name: unittests | |
debug: true | |
files: $(find . -name "coverage.xml" -type f) | |
- name: Report on test results | |
run: colcon test-result --all --verbose | |
if: always() | |
- 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 | |
working-directory: ${{ github.workspace }}/src/spot_ros2 |