diff --git a/.github/workflows/reusable-pre-commit.yml b/.github/workflows/reusable-pre-commit.yml index 9af56f5..7126d3c 100644 --- a/.github/workflows/reusable-pre-commit.yml +++ b/.github/workflows/reusable-pre-commit.yml @@ -51,9 +51,16 @@ jobs: 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 + - 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 + 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 - python -m pip install pre-commit pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual diff --git a/.github/workflows/reusable-update-pre-commit.yml b/.github/workflows/reusable-update-pre-commit.yml index 552ba10..fd0dd9e 100644 --- a/.github/workflows/reusable-update-pre-commit.yml +++ b/.github/workflows/reusable-update-pre-commit.yml @@ -23,10 +23,14 @@ jobs: - 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 pre-commit autoupdate || true # Ignoring errors - name: Check for changes