From beb34aed386460786569be4ff455b27b79951b78 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Sat, 24 Feb 2024 12:20:03 +0100 Subject: [PATCH] ci: cache PR build results based on git tree hash --- .github/workflows/main.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 56649bcf5..e55e90203 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,24 +26,41 @@ jobs: - name: Check out repository code uses: actions/checkout@v4 + - name: Get git tree hash + id: get-tree-hash + run: | + git rev-parse HEAD^{tree} > .tree-hash + echo "hash=$(cat .tree-hash)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v4 + id: result-cache + with: + path: .tree-hash + key: success-${{ steps.get-tree-hash.outputs.hash }}-${{ matrix.partition }} + - name: Run sccache-cache + if: steps.result-cache.outputs.cache-hit != 'true' uses: mozilla-actions/sccache-action@v0.0.4 - name: Install toolchain + if: steps.result-cache.outputs.cache-hit != 'true' uses: dtolnay/rust-toolchain@nightly with: targets: thumbv6m-none-eabi,thumbv7m-none-eabi,thumbv7em-none-eabi - name: rust cache + if: steps.result-cache.outputs.cache-hit != 'true' uses: Swatinem/rust-cache@v2 with: key: "${{ matrix.partition }}" - uses: taiki-e/install-action@v2 + if: steps.result-cache.outputs.cache-hit != 'true' with: tool: cargo-binstall - name: "installing prerequisites" + if: steps.result-cache.outputs.cache-hit != 'true' run: | git config --global init.defaultBranch main git config --global user.email "ci@riot-labs.de" @@ -53,6 +70,7 @@ jobs: sudo apt-get install ninja-build - name: "riot-rs compilation test" + if: steps.result-cache.outputs.cache-hit != 'true' run: | sccache --start-server || true # work around https://github.com/ninja-build/ninja/issues/2052