From b475d1ce87c099ea93f2cb6028fa97b884b99359 Mon Sep 17 00:00:00 2001 From: Trevor Edris Date: Mon, 16 Mar 2026 03:50:49 -0400 Subject: [PATCH] Parallelize CI jobs and cache build tools (#9528) --- .github/workflows/build.yml | 203 +++++++++++++++++++++++++++++++----- 1 file changed, 175 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3b4a1ea13f..a37a6e49e9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,69 +7,217 @@ on: - upcoming pull_request: +env: + GAME_REVISION: 0 + GAME_LANGUAGE: ENGLISH + COMPARE: 0 + UNUSED_ERROR: 1 + DEPRECATED_ERROR: 1 + jobs: - build: + build-emerald: if: github.actor != 'allcontributors[bot]' runs-on: ubuntu-latest - env: - GAME_REVISION: 0 - GAME_LANGUAGE: ENGLISH - COMPARE: 0 - UNUSED_ERROR: 1 - DEPRECATED_ERROR: 1 steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install binutils run: | - sudo apt update - sudo apt install -y binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi libpng-dev python3 - # build-essential and git are already installed + sudo apt-get update + sudo apt-get install -y binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi libpng-dev python3 + + - name: Cache build tools + uses: actions/cache@v4 + with: + path: | + tools/bin2c/bin2c + tools/gbafix/gbafix + tools/gbagfx/gbagfx + tools/jsonproc/jsonproc + tools/mapjson/mapjson + tools/mid2agb/mid2agb + tools/preproc/preproc + tools/ramscrgen/ramscrgen + tools/rsfont/rsfont + tools/scaninc/scaninc + tools/trainerproc/trainerproc + tools/compresSmol/compresSmol + tools/compresSmol/compresSmolTilemap + tools/wav2agb/wav2agb + key: tools-${{ runner.os }}-${{ hashFiles('tools/*/Makefile', 'tools/**/*.c', 'tools/**/*.cpp', 'tools/**/*.h') }} - name: ROM (Emerald) env: - COMPARE: 0 GAME_VERSION: EMERALD - run: make -j${nproc} -O all + run: make -j$(nproc) -O all + + build-firered: + if: github.actor != 'allcontributors[bot]' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install binutils + run: | + sudo apt-get update + sudo apt-get install -y binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi libpng-dev python3 + + - name: Cache build tools + uses: actions/cache@v4 + with: + path: | + tools/bin2c/bin2c + tools/gbafix/gbafix + tools/gbagfx/gbagfx + tools/jsonproc/jsonproc + tools/mapjson/mapjson + tools/mid2agb/mid2agb + tools/preproc/preproc + tools/ramscrgen/ramscrgen + tools/rsfont/rsfont + tools/scaninc/scaninc + tools/trainerproc/trainerproc + tools/compresSmol/compresSmol + tools/compresSmol/compresSmolTilemap + tools/wav2agb/wav2agb + key: tools-${{ runner.os }}-${{ hashFiles('tools/*/Makefile', 'tools/**/*.c', 'tools/**/*.cpp', 'tools/**/*.h') }} - name: ROM (Firered) - env: - COMPARE: 0 + run: make firered -j$(nproc) -O + + build-leafgreen: + if: github.actor != 'allcontributors[bot]' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install binutils run: | - make firered -j${nproc} -O + sudo apt-get update + sudo apt-get install -y binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi libpng-dev python3 + + - name: Cache build tools + uses: actions/cache@v4 + with: + path: | + tools/bin2c/bin2c + tools/gbafix/gbafix + tools/gbagfx/gbagfx + tools/jsonproc/jsonproc + tools/mapjson/mapjson + tools/mid2agb/mid2agb + tools/preproc/preproc + tools/ramscrgen/ramscrgen + tools/rsfont/rsfont + tools/scaninc/scaninc + tools/trainerproc/trainerproc + tools/compresSmol/compresSmol + tools/compresSmol/compresSmolTilemap + tools/wav2agb/wav2agb + key: tools-${{ runner.os }}-${{ hashFiles('tools/*/Makefile', 'tools/**/*.c', 'tools/**/*.cpp', 'tools/**/*.h') }} - name: ROM (Leafgreen) - env: - COMPARE: 0 + run: make leafgreen -j$(nproc) -O + + release: + if: github.actor != 'allcontributors[bot]' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install binutils run: | - make leafgreen -j${nproc} -O + sudo apt-get update + sudo apt-get install -y binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi libpng-dev python3 + + - name: Cache build tools + uses: actions/cache@v4 + with: + path: | + tools/bin2c/bin2c + tools/gbafix/gbafix + tools/gbagfx/gbagfx + tools/jsonproc/jsonproc + tools/mapjson/mapjson + tools/mid2agb/mid2agb + tools/preproc/preproc + tools/ramscrgen/ramscrgen + tools/rsfont/rsfont + tools/scaninc/scaninc + tools/trainerproc/trainerproc + tools/compresSmol/compresSmol + tools/compresSmol/compresSmolTilemap + tools/wav2agb/wav2agb + key: tools-${{ runner.os }}-${{ hashFiles('tools/*/Makefile', 'tools/**/*.c', 'tools/**/*.cpp', 'tools/**/*.h') }} - name: Release env: GAME_VERSION: EMERALD + run: make -j$(nproc) release + + test: + if: github.actor != 'allcontributors[bot]' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install binutils run: | - make tidy - make -j${nproc} release - # make tidy to purge previous build + sudo apt-get update + sudo apt-get install -y binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi libpng-dev python3 + + - name: Cache build tools + uses: actions/cache@v4 + with: + path: | + tools/bin2c/bin2c + tools/gbafix/gbafix + tools/gbagfx/gbagfx + tools/jsonproc/jsonproc + tools/mapjson/mapjson + tools/mid2agb/mid2agb + tools/preproc/preproc + tools/ramscrgen/ramscrgen + tools/rsfont/rsfont + tools/scaninc/scaninc + tools/trainerproc/trainerproc + tools/compresSmol/compresSmol + tools/compresSmol/compresSmolTilemap + tools/wav2agb/wav2agb + tools/patchelf/patchelf + tools/mgba-rom-test-hydra/mgba-rom-test-hydra + key: tools-check-${{ runner.os }}-${{ hashFiles('tools/*/Makefile', 'tools/**/*.c', 'tools/**/*.cpp', 'tools/**/*.h') }} - name: Test env: GAME_VERSION: EMERALD TEST: 1 - run: | - make -j${nproc} check + run: make -j$(nproc) check + + # Gate job: satisfies the "build" branch protection rule. + # Passes only when all parallel build/test jobs succeed. + build: + if: github.actor != 'allcontributors[bot]' + runs-on: ubuntu-latest + needs: [build-emerald, build-firered, build-leafgreen, release, test] + steps: + - name: All builds passed + run: echo "All builds and tests passed." docs_validate: if: github.actor != 'allcontributors[bot]' runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Check that SUMMARY.md includes markdown doc files - run: | - .github/docs_validate/inclusive_summary.py + run: .github/docs_validate/inclusive_summary.py allcontributors: if: github.actor == 'allcontributors[bot]' @@ -78,4 +226,3 @@ jobs: steps: - name: Automatically pass for allcontributors run: echo "CI automatically passes for allcontributors" && exit 0 -