Skip to content

ci: make actions incremental and using docker image #140

ci: make actions incremental and using docker image

ci: make actions incremental and using docker image #140

Workflow file for this run

# yamllint disable rule:line-length
---
name: Clang-Format
on: # yamllint disable-line rule:truthy
pull_request:
branches: ['*']
jobs:
clang-format:
runs-on: ubuntu-latest
container:
image: dtors/base-cpp:latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure Git Safe Directory
run: |
git config --global --add safe.directory $(pwd)
- name: Find affected files
run: |
git fetch origin ${{ github.base_ref }} --depth=1
git diff --name-only origin/${{ github.base_ref }} > affected_files.txt
echo "Affected files:"
cat affected_files.txt
- name: Find affected cpp files
run: |
> affected_cpp_files.txt
while read file; do
if [[ "$file" == *.cpp || "$file" == *.h || "$file" == *.hpp || "$file" == *.cc || "$file" == *.cxx || "$file" == *.hxx ]]; then
echo "$file" >> affected_cpp_files.txt
fi
done < affected_files.txt
sort -u affected_cpp_files.txt -o affected_cpp_files.txt
echo "Affected cpp files:"
cat affected_cpp_files.txt
echo "cpp_files=$(cat affected_cpp_files.txt | tr '\n' ' ')" >> $GITHUB_ENV
shell: bash
- name: Running Clang-Format
if: env.cpp_files != ''
run: |
echo "Running: clang-format --dry-run --Werror ${cpp_files}"
clang-format --dry-run --Werror ${cpp_files}
- name: Skip Clang-Format
if: env.cpp_files == ''
run: echo "No affected cpp files found. Skipping Clang-Tidy."
- name: Show failure message
if: failure()
run: |-
echo -e "To automatically apply suggested fixes, run the following command:
======================================================================================
1. Run clang-format:
find . -name \"*.cpp\" -o -name \"*.h\" -o -name \"*.hpp\" -o -name \"*.cc\" -o -name \"*.cxx\" -o -name \"*.hxx\" | xargs clang-format -i
======================================================================================"