Skip to content

fix: arch version and reduce docker image size and caching #347

fix: arch version and reduce docker image size and caching

fix: arch version and reduce docker image size and caching #347

Workflow file for this run

name: Format Check
on:
pull_request:
branches: [main]
jobs:
changes:
name: Detect source changes
runs-on: ubuntu-latest
outputs:
relevant: ${{ steps.filter.outputs.relevant }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Detect relevant file changes
id: filter
shell: bash
run: |
if [ "${{ github.event_name }}" != "pull_request" ]; then
echo "relevant=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q '^src/'; then
echo "relevant=true" >> "$GITHUB_OUTPUT"
else
echo "relevant=false" >> "$GITHUB_OUTPUT"
fi
clang-format:
name: clang-format
needs: changes
if: needs.changes.outputs.relevant == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Install clang-format
run: sudo apt-get update && sudo apt-get install -y clang-format
- name: Check formatting
run: |
FAILED=0
FILES=$(find src/ -type f \( -name "*.cpp" -o -name "*.hpp" -o -name "*.h" \))
for file in $FILES; do
# Generate the diff between current and formatted versions
DIFF=$(clang-format "$file" | diff -u "$file" - || true)
if [ -n "$DIFF" ]; then
echo "::error file=$file::File is not formatted according to .clang-format"
echo "$DIFF"
echo ""
FAILED=1
fi
done
if [ "$FAILED" -eq 1 ]; then
echo ""
echo "Some files are not properly formatted."
echo ""
echo "Fix locally with:"
echo ' find src/ -type f \( -name "*.cpp" -o -name "*.hpp" -o -name "*.h" \) | xargs clang-format -i'
exit 1
fi
echo "All files are properly formatted."