From 4b12462dafe16a52240c9970d02abf4e1c9debce Mon Sep 17 00:00:00 2001 From: Project516 <138796702+Project516@users.noreply.github.com> Date: Wed, 30 Sep 2026 09:55:40 -0500 Subject: [PATCH 1/4] add clang format script and CI check --- .github/workflows/format.yml | 24 ++++++++++++++++++++++++ format.sh | 6 ++++++ 2 files changed, 30 insertions(+) create mode 100644 .github/workflows/format.yml create mode 100755 format.sh diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..b2d3d04 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,24 @@ +name: Format + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + clang-format: + + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - uses: actions/checkout@v7 + + # Pinned so a new clang-format release cannot reformat the tree in CI. + - name: Install clang-format + run: sudo apt-get install -y clang-format-18 + + - name: Check formatting + run: ./format.sh --dry-run --Werror \ No newline at end of file diff --git a/format.sh b/format.sh new file mode 100755 index 0000000..bfdeb60 --- /dev/null +++ b/format.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +# Formats the shader sources with clang-format. Extra arguments go to +# clang-format, so CI can check without writing: ./format.sh --dry-run --Werror + +find shaders -type f \( -name '*.fsh' -o -name '*.vsh' -o -name '*.glsl' \) -exec clang-format "$@" -- {} + \ No newline at end of file From 5d45a55599cfb4fea7bf69574425537b5a173504 Mon Sep 17 00:00:00 2001 From: Project516 <138796702+Project516@users.noreply.github.com> Date: Wed, 30 Sep 2026 09:58:36 -0500 Subject: [PATCH 2/4] format in place by default --- .github/workflows/format.yml | 2 +- format.sh | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index b2d3d04..b7172fb 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -21,4 +21,4 @@ jobs: run: sudo apt-get install -y clang-format-18 - name: Check formatting - run: ./format.sh --dry-run --Werror \ No newline at end of file + run: ./format.sh --check \ No newline at end of file diff --git a/format.sh b/format.sh index bfdeb60..67d1a9d 100755 --- a/format.sh +++ b/format.sh @@ -1,6 +1,13 @@ #!/bin/sh -# Formats the shader sources with clang-format. Extra arguments go to -# clang-format, so CI can check without writing: ./format.sh --dry-run --Werror +# Formats the shader sources in place with clang-format. +# Pass --check to report problems without writing. + +if [ "$1" = "--check" ]; then + shift + set -- --dry-run --Werror "$@" +else + set -- -i "$@" +fi find shaders -type f \( -name '*.fsh' -o -name '*.vsh' -o -name '*.glsl' \) -exec clang-format "$@" -- {} + \ No newline at end of file From 7bab1f57f9dd37e6b5d099e9182170b2b59e05d7 Mon Sep 17 00:00:00 2001 From: Project516 <138796702+Project516@users.noreply.github.com> Date: Wed, 30 Sep 2026 10:00:39 -0500 Subject: [PATCH 3/4] let CI pick the clang-format version --- .github/workflows/format.yml | 2 ++ format.sh | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index b7172fb..75a0626 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -21,4 +21,6 @@ jobs: run: sudo apt-get install -y clang-format-18 - name: Check formatting + env: + CLANG_FORMAT: clang-format-18 run: ./format.sh --check \ No newline at end of file diff --git a/format.sh b/format.sh index 67d1a9d..de1ff6f 100755 --- a/format.sh +++ b/format.sh @@ -2,6 +2,9 @@ # Formats the shader sources in place with clang-format. # Pass --check to report problems without writing. +# Set CLANG_FORMAT to pick a version, e.g. CLANG_FORMAT=clang-format-18. + +: "${CLANG_FORMAT:=clang-format}" if [ "$1" = "--check" ]; then shift @@ -10,4 +13,4 @@ else set -- -i "$@" fi -find shaders -type f \( -name '*.fsh' -o -name '*.vsh' -o -name '*.glsl' \) -exec clang-format "$@" -- {} + \ No newline at end of file +find shaders -type f \( -name '*.fsh' -o -name '*.vsh' -o -name '*.glsl' \) -exec "$CLANG_FORMAT" "$@" -- {} + \ No newline at end of file From f48a9497bc48dcf1db58627cb66445c7146765fe Mon Sep 17 00:00:00 2001 From: Project516 <138796702+Project516@users.noreply.github.com> Date: Wed, 30 Sep 2026 10:02:16 -0500 Subject: [PATCH 4/4] add trailing newlines --- .github/workflows/format.yml | 2 +- format.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 75a0626..6d594a9 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -23,4 +23,4 @@ jobs: - name: Check formatting env: CLANG_FORMAT: clang-format-18 - run: ./format.sh --check \ No newline at end of file + run: ./format.sh --check diff --git a/format.sh b/format.sh index de1ff6f..e4eebd3 100755 --- a/format.sh +++ b/format.sh @@ -13,4 +13,4 @@ else set -- -i "$@" fi -find shaders -type f \( -name '*.fsh' -o -name '*.vsh' -o -name '*.glsl' \) -exec "$CLANG_FORMAT" "$@" -- {} + \ No newline at end of file +find shaders -type f \( -name '*.fsh' -o -name '*.vsh' -o -name '*.glsl' \) -exec "$CLANG_FORMAT" "$@" -- {} +