forked from locusrobotics/fuse
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df2c89d
commit d21ceda
Showing
2 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
name: CI | ||
|
||
on: | ||
# Run if someone manually presses the button in the GitHub Actions UI | ||
workflow_dispatch: | ||
# Run when a PR is opened or updated | ||
pull_request: | ||
# Run when a commit is pushed to main | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
# Allow reading the source code | ||
contents: read | ||
# Allow writing built containers to GitHub Package Registry | ||
packages: write | ||
|
||
jobs: | ||
build-ws: | ||
name: Build colcon workspace | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout source | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
# Log into GitHub Container Registry so we can push an image | ||
- name: Log in to GHCR | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Build the Dockerfile and push the image to the private GitHub Container Registry on this repo | ||
- name: Build workspace | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
# run_id is unique to a particular run of this workflow so shouldn't clobber | ||
tags: ghcr.io/picknikrobotics/ros2_mujoco:${{ github.run_id }} | ||
push: true | ||
# This project is small enough that caching to GitHub Actions should be fine (it has a 10GB cache limit) | ||
cache-to: type=gha,mode=max | ||
cache-from: type=gha | ||
|
||
test-ws: | ||
name: Test colcon workspace | ||
needs: | ||
# Ensure the test job runs after the build job finishes instead of attempting to run in parallel | ||
- build-ws | ||
runs-on: ubuntu-22.04 | ||
container: | ||
# Run on the Docker image we tagged and pushed to a private repo in the job above | ||
image: ghcr.io/picknikrobotics/ros2_mujoco:${{ github.run_id }} | ||
steps: | ||
- name: Unit test workspace | ||
run: | | ||
. /opt/ros/humble/setup.sh | ||
. /colcon_ws/install/local_setup.sh | ||
# Create virtual framebuffer to allow GLFW to render in MuJoCo tests | ||
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & | ||
colcon test --event-handlers console_direct+ --retest-until-pass 3 | ||
working-directory: /colcon_ws | ||
|
||
# `colcon test` does not actually error on failure - run `colcon test-result` to generate a summary and an error code. | ||
- name: Display colcon test results | ||
# Run this step even if a previous step failed | ||
if: always() | ||
run: colcon test-result --verbose | ||
working-directory: /colcon_ws | ||
|
||
- name: Convert GTest code coverage to SonarQube format | ||
if: always() | ||
run: | | ||
python3 -m pip install gcovr | ||
python3 -m gcovr --sonarqube gcovr.xml --gcov-ignore-parse-errors=negative_hits.warn_once_per_file | ||
working-directory: /colcon_ws | ||
|
||
- name: Install sonar-scanner dependencies not present in the ROS Humble baseline | ||
if: always() | ||
run: sudo apt-get update && sudo apt-get install -yyq unzip | ||
|
||
- name: Install sonar-scanner | ||
if: always() | ||
uses: SonarSource/sonarcloud-github-c-cpp@v2 | ||
|
||
- name: Run sonar-scanner | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
if: always() | ||
run: sonar-scanner | ||
working-directory: /colcon_ws |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# see https://github.com/pre-commit/action | ||
|
||
name: pre-commit | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
pre-commit: | ||
name: Format | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
- name: Install clang-format-14 | ||
run: sudo apt-get install clang-format-14 | ||
- uses: pre-commit/[email protected] | ||
id: precommit | ||
- name: Upload pre-commit changes | ||
if: failure() && steps.precommit.outcome == 'failure' | ||
uses: rhaschke/upload-git-patch-action@main | ||
with: | ||
name: pre-commit |