-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create
reusable-pre-commit.yml
and add workflow for it (#10)
Co-authored-by: Felix Exner (fexner) <exner@fzi.de>
- Loading branch information
1 parent
3dfe127
commit ec7c2ac
Showing
7 changed files
with
124 additions
and
15 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,11 @@ | ||
name: Format | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
|
||
jobs: | ||
pre-commit: | ||
uses: ./.github/workflows/reusable-pre-commit.yml | ||
with: | ||
ros_distro: rolling |
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,33 @@ | ||
name: Pre-commit | ||
# The pre-commit configuration is in .pre-commit-config.yaml | ||
# we don't use the pre-commit action because it doesn't support local hooks in its virtual environment | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
ros_distro: | ||
description: 'ROS2 distribution name' | ||
required: true | ||
type: string | ||
os_name: | ||
description: 'On which OS to run the linter' | ||
required: false | ||
default: 'ubuntu-latest' | ||
type: string | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ${{ inputs.os_name }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ros-tooling/setup-ros@0.7.1 | ||
- 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 |
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
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,49 @@ | ||
name: Update pre-commit | ||
# Update pre-commit config and create PR if changes are detected | ||
# author: Christoph Fröhlich <christoph.froehlich@ait.ac.at> | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
auto_update_and_create_pr: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install pre-commit | ||
run: | | ||
pip install pre-commit | ||
- name: Auto-update with pre-commit | ||
run: | | ||
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" | ||
- name: There are changes | ||
if: steps.git_status.outputs.changed == 'true' | ||
run: | | ||
echo "Files have changed" | ||
git diff --exit-code || true | ||
- name: No changes! | ||
if: steps.git_status.outputs.changed == 'false' | ||
run: | | ||
echo "No changes detected" | ||
- name: Create Pull Request | ||
if: steps.git_status.outputs.changed == 'true' | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: auto-update | ||
commit-message: Auto-update with pre-commit | ||
title: Bump version of pre-commit hooks | ||
body: This pull request contains auto-updated files of pre-commit config. | ||
delete-branch: true |
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,12 @@ | ||
name: Auto Update pre-commit | ||
# Update pre-commit config and create PR if changes are detected | ||
# author: Christoph Fröhlich <christoph.froehlich@ait.ac.at> | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 0 * * 0' # Run every Sunday at midnight | ||
|
||
jobs: | ||
auto_update_and_create_pr: | ||
uses: ./.github/workflows/reusable-update-pre-commit.yml |
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
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