mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-16 05:10:40 +01:00
CI: add code style check
Introduce a GitHub Actions workflow that automatically runs devtools/format-code.sh on every pull request touching source files. If formatting changes are detected, the check fails and provides clear instructions for contributors—run the formatter locally and enable “Allow edits from maintainers” so fixes can be applied. This prevents code‑style drift and eliminates style‑only update noise.
This commit is contained in:
parent
7170e7a40f
commit
3ddd711ddb
39
.github/workflows/ci_codestyle_check.yml
vendored
Normal file
39
.github/workflows/ci_codestyle_check.yml
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
name: "Code Style Check"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
style-check:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Detect changed files
|
||||
id: code_changes
|
||||
uses: tj-actions/changed-files@v46
|
||||
with:
|
||||
files: |
|
||||
**/*.c
|
||||
**/*.h
|
||||
devtools/format-code.sh
|
||||
|
||||
- name: Enforce code style
|
||||
run: |
|
||||
if [ "${{ steps.code_changes.outputs.any_changed }}" != "true" ]; then
|
||||
echo "No code changes detected; skipping style check."
|
||||
exit 0
|
||||
fi
|
||||
chmod +x devtools/format-code.sh
|
||||
./devtools/format-code.sh
|
||||
if ! git diff --exit-code; then
|
||||
echo "::error ::Code style violations detected."
|
||||
echo "Contributors: to fix this, run './devtools/format-code.sh' locally"
|
||||
echo "and push the updated commit to your branch."
|
||||
echo "Ensure 'Allow edits from maintainers' is enabled on this PR so maintainers"
|
||||
echo "can help apply formatting fixes if needed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user