mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-17 01:00:40 +01:00
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.
40 lines
1.1 KiB
YAML
40 lines
1.1 KiB
YAML
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
|
|
|