diff --git a/.github/workflows/ci-pre-commit.yml b/.github/workflows/ci-pre-commit.yml index fc012c8..c29a062 100644 --- a/.github/workflows/ci-pre-commit.yml +++ b/.github/workflows/ci-pre-commit.yml @@ -9,3 +9,4 @@ jobs: uses: ./.github/workflows/reusable-pre-commit.yml with: ros_distro: rolling + container: ubuntu:24.04 diff --git a/.github/workflows/reusable-build-coverage.yml b/.github/workflows/reusable-build-coverage.yml index 06e6ab2..a93c79d 100644 --- a/.github/workflows/reusable-build-coverage.yml +++ b/.github/workflows/reusable-build-coverage.yml @@ -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/setup-ros@0.7.2 - - 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/setup-ros@0.7.2 - uses: actions/checkout@v4 - id: package_list_action uses: ros-controls/ros2_control_ci/.github/actions/set-package-list@master diff --git a/.github/workflows/reusable-pre-commit.yml b/.github/workflows/reusable-pre-commit.yml index 71ccb3c..ff3d77c 100644 --- a/.github/workflows/reusable-pre-commit.yml +++ b/.github/workflows/reusable-pre-commit.yml @@ -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/setup-ros@0.7.2 - - 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/setup-ros@0.7.2 + - 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 diff --git a/.github/workflows/reusable-ros-tooling-source-build.yml b/.github/workflows/reusable-ros-tooling-source-build.yml index 3ec7f03..049a703 100644 --- a/.github/workflows/reusable-ros-tooling-source-build.yml +++ b/.github/workflows/reusable-ros-tooling-source-build.yml @@ -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/setup-ros@0.7.2 - with: - required-ros-distributions: ${{ inputs.ros_distro }} - uses: actions/checkout@v4 with: ref: ${{ inputs.ref }} diff --git a/.github/workflows/reusable-update-pre-commit.yml b/.github/workflows/reusable-update-pre-commit.yml index 552ba10..2b5bdc2 100644 --- a/.github/workflows/reusable-update-pre-commit.yml +++ b/.github/workflows/reusable-update-pre-commit.yml @@ -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! @@ -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 }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c6de5ef..66c0f0f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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']