From 27db22b96f67302710e286ec885089a3567c3f54 Mon Sep 17 00:00:00 2001 From: CptMoore <39010654+cptmoore@users.noreply.github.com> Date: Sun, 4 Feb 2024 09:35:18 +0100 Subject: [PATCH] Added build caching --- .github/workflows/build.yml | 2 ++ .github/workflows/build_language.yml | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c25feead..2f3d07f1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -169,6 +169,8 @@ jobs: with: language: ${{ matrix.language }} assemble: ${{ needs.workflow_setup.outputs.assemble_release == 'true' }} + # TODO check if English and German build faster for code changes on master, if not remove caching + build-cache-enabled: ${{ matrix.language == 'English' || matrix.language == 'German' }} # at least English and some other lang have to work continue-on-error: ${{ matrix.language != 'English' && matrix.language != 'German' }} diff --git a/.github/workflows/build_language.yml b/.github/workflows/build_language.yml index 1b7d6ee4..07684fcc 100644 --- a/.github/workflows/build_language.yml +++ b/.github/workflows/build_language.yml @@ -13,6 +13,11 @@ on: required: true default: true type: boolean + build-cache-enabled: + description: 'enable sscache' + required: true + default: false + type: boolean continue-on-error: description: 'allows a language to fail, used when building all languages' required: false @@ -27,6 +32,8 @@ jobs: fail-fast: false matrix: application: [ja2, ja2mapeditor, ja2ub, ja2ubmapeditor] + env: + SCCACHE_GHA_ENABLED: ${{ inputs.build-cache-enabled }} steps: - name: Checkout source @@ -75,9 +82,19 @@ jobs: - uses: ilammy/msvc-dev-cmd@v1 with: arch: x86 + - name: Prepare build cache + if: ${{ inputs.build-cache-enabled }} + uses: hendrikmuhs/ccache-action@v1 + with: + key: ${{ inputs.language }}_${{ matrix.application }} + save: ${{ github.ref == 'refs/heads/master' }} + variant: sccache - name: Prepare build - run: | - cmake -S . -B build -GNinja -DCMAKE_BUILD_TYPE=Release -DLanguages="$Env:JA2Language" -DApplications="$Env:JA2Application" + run: > + cmake -S . -B build -GNinja + -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache + -DCMAKE_BUILD_TYPE=Release + -DLanguages="$Env:JA2Language" -DApplications="$Env:JA2Application" - name: Build run: | cmake --build build/ -- -v