diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..ed62ae0 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,33 @@ +name: Format + +on: [ push, pull_request ] + +permissions: + contents: read # to fetch code (actions/checkout) + +env: + CCACHE_DIR: "${{ github.workspace }}/.ccache" + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + format: + name: Check formatting + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + environment: [lint] + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: prefix-dev/setup-pixi@92815284c57faa15cd896c4d5cfb2d59f32dc43d # v0.8.3 + with: + pixi-version: v0.48.2 + cache: true + environments: ${{ matrix.environment }} + - name: Check for formatting violations + run: | + pixi run format-dry-error + echo "Please execute 'pixi run format' to fix any errors." diff --git a/pixi.toml b/pixi.toml index 3782888..3cb973b 100644 --- a/pixi.toml +++ b/pixi.toml @@ -74,6 +74,7 @@ clang-format = "*" [feature.clang-format.tasks] format = "git ls-files '*.cpp' '*.h' | xargs clang-format -i --style=file" +format-dry-error = "git ls-files '*.cpp' '*.h' | xargs clang-format --style=file --Werror --dry-run" ## Coverage