From 46f03ca93ddd6f148e9d11277e19e90397f8babd Mon Sep 17 00:00:00 2001 From: someone2639 Date: Tue, 18 Feb 2025 22:13:12 -0500 Subject: [PATCH] Explicitly use clang-format 19 in CI, reintroduce auto format checks for include/ (#7) * test clang v19 * require clang-format 19 * Try outputting patch as an artifact * test CI * actually set the correct filename * only upload on failure * try a more descriptive name * remove intentional test change --------- Co-authored-by: someone2639 --- .github/workflows/ci_gcc.yml | 10 +++++++++- format.py | 4 ++-- tools/check_format.py | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci_gcc.yml b/.github/workflows/ci_gcc.yml index a50d779..448b933 100644 --- a/.github/workflows/ci_gcc.yml +++ b/.github/workflows/ci_gcc.yml @@ -23,7 +23,7 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - name: Install package requirements - run: sudo apt-get install -y clang-tools clang-format clang-tidy gcc-mips-linux-gnu binutils-mips-linux-gnu build-essential python3 + run: sudo apt-get install -y clang-tools-19 clang-format-19 clang-tidy-19 gcc-mips-linux-gnu binutils-mips-linux-gnu build-essential python3 - name: Verify formatting on all files run: python3 tools/check_format.py --verbose @@ -33,3 +33,11 @@ jobs: - name: Build libgultra${{ matrix.suffix }} ${{ matrix.version }} run: make -j $(nproc) TARGET=libgultra${{ matrix.suffix }} VERSION=${{ matrix.version }} + + - name: 'Upload Artifact' + uses: actions/upload-artifact@v4 + if: failure() + with: + name: 'Changes to Apply' + path: changes.patch + retention-days: 5 diff --git a/format.py b/format.py index f958853..744b874 100644 --- a/format.py +++ b/format.py @@ -16,7 +16,7 @@ from typing import List # clang-format, clang-tidy and clang-apply-replacements default version # This specific version is used when available, for more consistency between contributors -CLANG_VER = 14 +CLANG_VER = 19 # Clang-Format options (see .clang-format for rules applied) FORMAT_OPTS = "-i -style=file" @@ -122,7 +122,7 @@ def format_files(src_files: List[str], extra_files: List[str], nb_jobs: int): print("Formatting files with a single job (consider using -j to make this faster)") # Format files in chunks to improve performance while still utilizing jobs - file_chunks = list(list_chunks(src_files, (len(src_files) // nb_jobs) + 1)) + file_chunks = list(list_chunks(src_files + extra_files, (len(src_files + extra_files) // nb_jobs) + 1)) print("Running clang-format...") # clang-format only applies changes in the given files, so it's safe to run in parallel diff --git a/tools/check_format.py b/tools/check_format.py index 0db12a0..bc3e8ff 100644 --- a/tools/check_format.py +++ b/tools/check_format.py @@ -74,7 +74,8 @@ def main(): ): print(l) - print(subprocess.check_output("git diff".split(), text=True)) + with open("changes.patch", "w+") as patchf: + patchf.write(subprocess.check_output("git diff".split(), text=True)) exit(1)