Skip to content

Commit

Permalink
Updates for noble (#53)
Browse files Browse the repository at this point in the history
* Deactivate ROSDISTRO_INDEX_URL again

* Try to use a bare ubuntu container

* Noble is now supported by setup-ros

* Add container input also for source build and pre-commit

* Cleanup

* Set it for pre-commit

* Fix pre-commit

* Test if this fixes the .git error

* Fix also auto-update

* Fix paths for autoupdate

* Fix paths

* Fix #13

* Use correct var

* Remove double env.path

* Bump version of pre-commit hooks (#58)

Co-authored-by: christophfroehlich <[email protected]>

* Harden behavior if sudo is installed or not

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: christophfroehlich <[email protected]>
  • Loading branch information
3 people authored Apr 24, 2024
1 parent 2888a81 commit b7592c8
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 33 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ jobs:
uses: ./.github/workflows/reusable-pre-commit.yml
with:
ros_distro: rolling
container: ubuntu:24.04
41 changes: 26 additions & 15 deletions .github/workflows/reusable-build-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,43 @@ on:
required: true
type: string
os_name:
description: 'On which OS to run the workflow, e.g. ubuntu-22.04'
description: 'On which runner-OS to run the workflow, e.g. ubuntu-22.04'
required: false
default: 'ubuntu-latest'
type: string
container:
description: '(optional) Docker container to run the job in, e.g. ubuntu:noble'
required: false
default: ''
type: string

jobs:
coverage:
name: coverage build ${{ inputs.ros_distro }}
runs-on: ${{ inputs.os_name }}
container: ${{ inputs.container }}
steps:
- uses: ros-tooling/[email protected]
- name: Temporary fix for rolling by setting the ROSDISTRO_INDEX_URL
# see https://docs.ros.org/en/rolling/How-To-Guides/Using-Custom-Rosdistro.html
# TODO(anyone): remove/deactivate after rolling is fixed on noble
- name: "Determine prerequisites"
id: prereq
run: |
if [[ "${{ inputs.ros_distro }}" == "rolling" ]]; then
sudo sed -i "s|ros\/rosdistro\/master|ros\/rosdistro\/rolling\/2024-02-28|" /etc/ros/rosdep/sources.list.d/20-default.list
echo "ROSDISTRO_INDEX_URL=https://raw.githubusercontent.com/ros/rosdistro/rolling/2024-02-28/index-v4.yaml" >> $GITHUB_ENV
fi
- name: Test some rosdep commands to see if the step above worked
# TODO(anyone): remove/deactivate after rolling is fixed on noble
command -v sudo >/dev/null 2>&1 || (apt update && apt install -y sudo)
DEBIAN_FRONTEND=noninteractive sudo apt update && sudo apt upgrade -y
echo "need_node=$(command -v node >/dev/null 2>&1 && echo 0 || echo 1)" >> $GITHUB_OUTPUT
# needed for github actions, and only if a bare ubuntu image is used
- uses: actions/setup-node@v4
if: ${{ steps.prereq.outputs.need_node == '1' && !env.ACT }}
- name: Install node
# Consider switching to https://github.com/actions/setup-node when it works
# https://github.com/nektos/act/issues/973
if: ${{ steps.prereq.outputs.need_node == '1' && env.ACT }}
run: |
rosdep update
echo "ROS_DISTRO: $ROS_DISTRO"
rosdep resolve test_msgs std_msgs || true
rosdep resolve test_msgs std_msgs --os=ubuntu:jammy --rosdistro=rolling
sudo apt install -y curl
curl -sS https://webi.sh/node | sh
echo ~/.local/opt/node/bin >> $GITHUB_PATH
# needed only if a non-ros image is used
- uses: ros-tooling/[email protected]
- uses: actions/checkout@v4
- id: package_list_action
uses: ros-controls/ros2_control_ci/.github/actions/set-package-list@master
Expand Down
64 changes: 52 additions & 12 deletions .github/workflows/reusable-pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,60 @@ on:
required: false
default: 'ubuntu-latest'
type: string
container:
description: '(optional) Docker container to run the job in, e.g. ubuntu:noble'
required: false
default: ''
type: string

jobs:
pre-commit:
runs-on: ${{ inputs.os_name }}
container: ${{ inputs.container }}
env:
# this will be src/{repo-owner}/{repo-name}
path: src/${{ github.repository }}
steps:
- uses: actions/checkout@v4
- uses: ros-tooling/[email protected]
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ inputs.ros_distro }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install system hooks and run pre-commit
run: |
sudo apt-get install -qq ros-${{ inputs.ros_distro }}-ament-cppcheck ros-${{ inputs.ros_distro }}-ament-cpplint ros-${{ inputs.ros_distro }}-ament-lint-cmake ros-${{ inputs.ros_distro }}-ament-copyright
source /opt/ros/${{ inputs.ros_distro }}/setup.bash
python -m pip install pre-commit
pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual
- name: "Determine prerequisites"
id: prereq
run: |
command -v sudo >/dev/null 2>&1 || (apt update && apt install -y sudo)
DEBIAN_FRONTEND=noninteractive sudo apt update && sudo apt upgrade -y
echo "need_node=$(command -v node >/dev/null 2>&1 && echo 0 || echo 1)" >> $GITHUB_OUTPUT
# needed for github actions, and only if a bare ubuntu image is used
- uses: actions/setup-node@v4
if: ${{ steps.prereq.outputs.need_node == '1' && !env.ACT }}
- name: Install node
# Consider switching to https://github.com/actions/setup-node when it works
# https://github.com/nektos/act/issues/973
if: ${{ steps.prereq.outputs.need_node == '1' && env.ACT }}
run: |
sudo apt install -y curl
curl -sS https://webi.sh/node | sh
echo ~/.local/opt/node/bin >> $GITHUB_PATH
# needed only if a non-ros image is used
- uses: ros-tooling/[email protected]
- uses: actions/checkout@v4
with:
fetch-depth: 0
path: ${{ env.path }}
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ inputs.ros_distro }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install pre-commit and system hooks
shell: bash
run: |
sudo apt-get install -qq ros-${{ inputs.ros_distro }}-ament-cppcheck ros-${{ inputs.ros_distro }}-ament-cpplint ros-${{ inputs.ros_distro }}-ament-lint-cmake ros-${{ inputs.ros_distro }}-ament-copyright python3-venv
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install pre-commit
- name: Run pre-commit
shell: bash
run: |
source .venv/bin/activate
source /opt/ros/${{ inputs.ros_distro }}/setup.bash
cd ${{ env.path }}
pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual
28 changes: 26 additions & 2 deletions .github/workflows/reusable-ros-tooling-source-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,42 @@ on:
required: false
default: 'ubuntu-latest'
type: string
container:
description: '(optional) Docker container to run the job in, e.g. ubuntu:noble'
required: false
default: ''
type: string

jobs:
reusable_ros_tooling_source_build:
name: ${{ inputs.ros_distro }} ${{ inputs.os_name }}
runs-on: ${{ inputs.os_name }}
container: ${{ inputs.container }}
env:
# this will be src/{repo-owner}/{repo-name}
path: src/${{ github.repository }}
steps:
- name: "Determine prerequisites"
id: prereq
run: |
command -v sudo >/dev/null 2>&1 || (apt update && apt install -y sudo)
DEBIAN_FRONTEND=noninteractive sudo apt update && sudo apt upgrade -y
echo "need_node=$(command -v node >/dev/null 2>&1 && echo 0 || echo 1)" >> $GITHUB_OUTPUT
# needed for github actions, and only if a bare ubuntu image is used
- uses: actions/setup-node@v4
if: ${{ steps.prereq.outputs.need_node == '1' && !env.ACT }}
- name: Install node
# Consider switching to https://github.com/actions/setup-node when it works
# https://github.com/nektos/act/issues/973
if: ${{ steps.prereq.outputs.need_node == '1' && env.ACT }}
run: |
sudo apt install -y curl
curl -sS https://webi.sh/node | sh
echo ~/.local/opt/node/bin >> $GITHUB_PATH
# needed only if a non-ros image is used
- uses: ros-tooling/[email protected]
with:
required-ros-distributions: ${{ inputs.ros_distro }}
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
Expand Down
18 changes: 15 additions & 3 deletions .github/workflows/reusable-update-pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,41 @@ on:
jobs:
auto_update_and_create_pr:
runs-on: ubuntu-latest
env:
# this will be src/{repo-owner}/{repo-name}
path: src/${{ github.repository }}

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
path: ${{ env.path }}
ref: ${{ github.event.inputs.ref_for_scheduled_build }}

- name: Install pre-commit
run: |
pip install pre-commit
sudo apt-get install -qq python3-venv
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install pre-commit
- name: Auto-update with pre-commit
run: |
source .venv/bin/activate
cd ${{ env.path }}
pre-commit autoupdate || true # Ignoring errors
- name: Check for changes
id: git_status
run: |
git diff --quiet && echo "::set-output name=changed::false" || echo "::set-output name=changed::true"
cd ${{ env.path }}
git diff --quiet && echo "changed=false" >> $GITHUB_OUTPUT || echo "changed=true" >> $GITHUB_OUTPUT
- name: There are changes
if: steps.git_status.outputs.changed == 'true'
run: |
echo "Files have changed"
cd ${{ env.path }}
git diff --exit-code || true
- name: No changes!
Expand All @@ -56,3 +67,4 @@ jobs:
body: This pull request contains auto-updated files of the pre-commit config. @ros-controls/ros2-maintainers please run the pre-commit workflow manually on the branch `auto-update-${{ github.event.inputs.ref_for_scheduled_build }}` before merging.
delete-branch: true
draft: true
path: ${{ env.path }}
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ repos:

# CPP hooks
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.3
rev: v18.1.4
hooks:
- id: clang-format
args: ['-fallback-style=none', '-i']
Expand Down

0 comments on commit b7592c8

Please sign in to comment.