mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-20 09:57:10 +00:00
update format workflow
This commit is contained in:
parent
43908b1de5
commit
39ebddbafc
49
.github/workflows/clang-format.yml
vendored
49
.github/workflows/clang-format.yml
vendored
|
|
@ -1,4 +1,4 @@
|
||||||
name: Format Check (Linux, x86-64)
|
name: Format
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
paths:
|
paths:
|
||||||
|
|
@ -11,23 +11,42 @@ on: [push, pull_request]
|
||||||
- '**.hpp'
|
- '**.hpp'
|
||||||
- '**.hxx'
|
- '**.hxx'
|
||||||
- '**.inl'
|
- '**.inl'
|
||||||
- "**meson.build"
|
- '.clang-format'
|
||||||
- "flake.nix"
|
- '.github/workflows/clang-format.yml'
|
||||||
- ".clang-format"
|
- '.github/scripts/check-clang-format.sh'
|
||||||
- '.github/workflows/build-linux.yml'
|
|
||||||
- ".github/scripts/check-clang-format.sh"
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
formatting-check:
|
clang-format:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
concurrency:
|
||||||
|
group: clang-format-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Run clang-format style check
|
- name: Install clang-format
|
||||||
uses: jidicula/clang-format-action@v4.18.0
|
run: |
|
||||||
with:
|
sudo apt-get update
|
||||||
# keep this in line with the flake
|
sudo apt-get install -y clang-format-21
|
||||||
clang-format-version: "21"
|
|
||||||
|
- name: Check changed files
|
||||||
|
env:
|
||||||
|
CLANG_FORMAT_BIN: clang-format
|
||||||
|
EVENT_NAME: ${{ github.event_name }}
|
||||||
|
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
|
||||||
|
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||||
|
BEFORE_SHA: ${{ github.event.before }}
|
||||||
|
CURRENT_SHA: ${{ github.sha }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
BASE_SHA=""
|
||||||
|
if [ "$EVENT_NAME" = "pull_request" ]; then
|
||||||
|
git fetch --no-tags origin "$PR_BASE_REF"
|
||||||
|
BASE_SHA="$(git merge-base "origin/$PR_BASE_REF" "$CURRENT_SHA")"
|
||||||
|
elif [ -n "$BEFORE_SHA" ] && [ "$BEFORE_SHA" != "0000000000000000000000000000000000000000" ]; then
|
||||||
|
BASE_SHA="$BEFORE_SHA"
|
||||||
|
fi
|
||||||
|
|
||||||
|
bash ./.github/scripts/check-clang-format.sh "$BASE_SHA" "$CURRENT_SHA"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue