Skip to content

Commit b7592c8

Browse files
Updates for noble (#53)
* 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]>
1 parent 2888a81 commit b7592c8

6 files changed

+121
-33
lines changed

.github/workflows/ci-pre-commit.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ jobs:
99
uses: ./.github/workflows/reusable-pre-commit.yml
1010
with:
1111
ros_distro: rolling
12+
container: ubuntu:24.04

.github/workflows/reusable-build-coverage.yml

+26-15
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,43 @@ on:
77
required: true
88
type: string
99
os_name:
10-
description: 'On which OS to run the workflow, e.g. ubuntu-22.04'
10+
description: 'On which runner-OS to run the workflow, e.g. ubuntu-22.04'
1111
required: false
1212
default: 'ubuntu-latest'
1313
type: string
14+
container:
15+
description: '(optional) Docker container to run the job in, e.g. ubuntu:noble'
16+
required: false
17+
default: ''
18+
type: string
1419

1520
jobs:
1621
coverage:
1722
name: coverage build ${{ inputs.ros_distro }}
1823
runs-on: ${{ inputs.os_name }}
24+
container: ${{ inputs.container }}
1925
steps:
20-
- uses: ros-tooling/[email protected]
21-
- name: Temporary fix for rolling by setting the ROSDISTRO_INDEX_URL
22-
# see https://docs.ros.org/en/rolling/How-To-Guides/Using-Custom-Rosdistro.html
23-
# TODO(anyone): remove/deactivate after rolling is fixed on noble
26+
- name: "Determine prerequisites"
27+
id: prereq
2428
run: |
25-
if [[ "${{ inputs.ros_distro }}" == "rolling" ]]; then
26-
sudo sed -i "s|ros\/rosdistro\/master|ros\/rosdistro\/rolling\/2024-02-28|" /etc/ros/rosdep/sources.list.d/20-default.list
27-
echo "ROSDISTRO_INDEX_URL=https://raw.githubusercontent.com/ros/rosdistro/rolling/2024-02-28/index-v4.yaml" >> $GITHUB_ENV
28-
fi
29-
- name: Test some rosdep commands to see if the step above worked
30-
# TODO(anyone): remove/deactivate after rolling is fixed on noble
29+
command -v sudo >/dev/null 2>&1 || (apt update && apt install -y sudo)
30+
DEBIAN_FRONTEND=noninteractive sudo apt update && sudo apt upgrade -y
31+
echo "need_node=$(command -v node >/dev/null 2>&1 && echo 0 || echo 1)" >> $GITHUB_OUTPUT
32+
33+
# needed for github actions, and only if a bare ubuntu image is used
34+
- uses: actions/setup-node@v4
35+
if: ${{ steps.prereq.outputs.need_node == '1' && !env.ACT }}
36+
- name: Install node
37+
# Consider switching to https://github.com/actions/setup-node when it works
38+
# https://github.com/nektos/act/issues/973
39+
if: ${{ steps.prereq.outputs.need_node == '1' && env.ACT }}
3140
run: |
32-
rosdep update
33-
echo "ROS_DISTRO: $ROS_DISTRO"
34-
rosdep resolve test_msgs std_msgs || true
35-
rosdep resolve test_msgs std_msgs --os=ubuntu:jammy --rosdistro=rolling
41+
sudo apt install -y curl
42+
curl -sS https://webi.sh/node | sh
43+
echo ~/.local/opt/node/bin >> $GITHUB_PATH
44+
45+
# needed only if a non-ros image is used
46+
- uses: ros-tooling/[email protected]
3647
- uses: actions/checkout@v4
3748
- id: package_list_action
3849
uses: ros-controls/ros2_control_ci/.github/actions/set-package-list@master

.github/workflows/reusable-pre-commit.yml

+52-12
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,60 @@ on:
1414
required: false
1515
default: 'ubuntu-latest'
1616
type: string
17+
container:
18+
description: '(optional) Docker container to run the job in, e.g. ubuntu:noble'
19+
required: false
20+
default: ''
21+
type: string
1722

1823
jobs:
1924
pre-commit:
2025
runs-on: ${{ inputs.os_name }}
26+
container: ${{ inputs.container }}
27+
env:
28+
# this will be src/{repo-owner}/{repo-name}
29+
path: src/${{ github.repository }}
2130
steps:
22-
- uses: actions/checkout@v4
23-
- uses: ros-tooling/[email protected]
24-
- uses: actions/cache@v4
25-
with:
26-
path: ~/.cache/pre-commit
27-
key: pre-commit-3|${{ inputs.ros_distro }}|${{ hashFiles('.pre-commit-config.yaml') }}
28-
- name: Install system hooks and run pre-commit
29-
run: |
30-
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
31-
source /opt/ros/${{ inputs.ros_distro }}/setup.bash
32-
python -m pip install pre-commit
33-
pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual
31+
- name: "Determine prerequisites"
32+
id: prereq
33+
run: |
34+
command -v sudo >/dev/null 2>&1 || (apt update && apt install -y sudo)
35+
DEBIAN_FRONTEND=noninteractive sudo apt update && sudo apt upgrade -y
36+
echo "need_node=$(command -v node >/dev/null 2>&1 && echo 0 || echo 1)" >> $GITHUB_OUTPUT
37+
38+
# needed for github actions, and only if a bare ubuntu image is used
39+
- uses: actions/setup-node@v4
40+
if: ${{ steps.prereq.outputs.need_node == '1' && !env.ACT }}
41+
- name: Install node
42+
# Consider switching to https://github.com/actions/setup-node when it works
43+
# https://github.com/nektos/act/issues/973
44+
if: ${{ steps.prereq.outputs.need_node == '1' && env.ACT }}
45+
run: |
46+
sudo apt install -y curl
47+
curl -sS https://webi.sh/node | sh
48+
echo ~/.local/opt/node/bin >> $GITHUB_PATH
49+
50+
# needed only if a non-ros image is used
51+
- uses: ros-tooling/[email protected]
52+
- uses: actions/checkout@v4
53+
with:
54+
fetch-depth: 0
55+
path: ${{ env.path }}
56+
- uses: actions/cache@v4
57+
with:
58+
path: ~/.cache/pre-commit
59+
key: pre-commit-3|${{ inputs.ros_distro }}|${{ hashFiles('.pre-commit-config.yaml') }}
60+
- name: Install pre-commit and system hooks
61+
shell: bash
62+
run: |
63+
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
64+
python3 -m venv .venv
65+
source .venv/bin/activate
66+
python3 -m pip install pre-commit
67+
- name: Run pre-commit
68+
shell: bash
69+
run: |
70+
source .venv/bin/activate
71+
source /opt/ros/${{ inputs.ros_distro }}/setup.bash
72+
cd ${{ env.path }}
73+
pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual

.github/workflows/reusable-ros-tooling-source-build.yml

+26-2
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,42 @@ on:
2323
required: false
2424
default: 'ubuntu-latest'
2525
type: string
26+
container:
27+
description: '(optional) Docker container to run the job in, e.g. ubuntu:noble'
28+
required: false
29+
default: ''
30+
type: string
2631

2732
jobs:
2833
reusable_ros_tooling_source_build:
2934
name: ${{ inputs.ros_distro }} ${{ inputs.os_name }}
3035
runs-on: ${{ inputs.os_name }}
36+
container: ${{ inputs.container }}
3137
env:
3238
# this will be src/{repo-owner}/{repo-name}
3339
path: src/${{ github.repository }}
3440
steps:
41+
- name: "Determine prerequisites"
42+
id: prereq
43+
run: |
44+
command -v sudo >/dev/null 2>&1 || (apt update && apt install -y sudo)
45+
DEBIAN_FRONTEND=noninteractive sudo apt update && sudo apt upgrade -y
46+
echo "need_node=$(command -v node >/dev/null 2>&1 && echo 0 || echo 1)" >> $GITHUB_OUTPUT
47+
48+
# needed for github actions, and only if a bare ubuntu image is used
49+
- uses: actions/setup-node@v4
50+
if: ${{ steps.prereq.outputs.need_node == '1' && !env.ACT }}
51+
- name: Install node
52+
# Consider switching to https://github.com/actions/setup-node when it works
53+
# https://github.com/nektos/act/issues/973
54+
if: ${{ steps.prereq.outputs.need_node == '1' && env.ACT }}
55+
run: |
56+
sudo apt install -y curl
57+
curl -sS https://webi.sh/node | sh
58+
echo ~/.local/opt/node/bin >> $GITHUB_PATH
59+
60+
# needed only if a non-ros image is used
3561
- uses: ros-tooling/[email protected]
36-
with:
37-
required-ros-distributions: ${{ inputs.ros_distro }}
3862
- uses: actions/checkout@v4
3963
with:
4064
ref: ${{ inputs.ref }}

.github/workflows/reusable-update-pre-commit.yml

+15-3
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,41 @@ on:
1414
jobs:
1515
auto_update_and_create_pr:
1616
runs-on: ubuntu-latest
17+
env:
18+
# this will be src/{repo-owner}/{repo-name}
19+
path: src/${{ github.repository }}
1720

1821
steps:
1922
- name: Checkout code
2023
uses: actions/checkout@v4
2124
with:
25+
fetch-depth: 0
26+
path: ${{ env.path }}
2227
ref: ${{ github.event.inputs.ref_for_scheduled_build }}
2328

2429
- name: Install pre-commit
2530
run: |
26-
pip install pre-commit
31+
sudo apt-get install -qq python3-venv
32+
python3 -m venv .venv
33+
source .venv/bin/activate
34+
python3 -m pip install pre-commit
2735
2836
- name: Auto-update with pre-commit
2937
run: |
38+
source .venv/bin/activate
39+
cd ${{ env.path }}
3040
pre-commit autoupdate || true # Ignoring errors
3141
3242
- name: Check for changes
3343
id: git_status
3444
run: |
35-
git diff --quiet && echo "::set-output name=changed::false" || echo "::set-output name=changed::true"
45+
cd ${{ env.path }}
46+
git diff --quiet && echo "changed=false" >> $GITHUB_OUTPUT || echo "changed=true" >> $GITHUB_OUTPUT
3647
3748
- name: There are changes
3849
if: steps.git_status.outputs.changed == 'true'
3950
run: |
40-
echo "Files have changed"
51+
cd ${{ env.path }}
4152
git diff --exit-code || true
4253
4354
- name: No changes!
@@ -56,3 +67,4 @@ jobs:
5667
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.
5768
delete-branch: true
5869
draft: true
70+
path: ${{ env.path }}

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ repos:
6262

6363
# CPP hooks
6464
- repo: https://github.com/pre-commit/mirrors-clang-format
65-
rev: v18.1.3
65+
rev: v18.1.4
6666
hooks:
6767
- id: clang-format
6868
args: ['-fallback-style=none', '-i']

0 commit comments

Comments
 (0)