From 9bc15c5794b83d5a3733a9b53046461f18141547 Mon Sep 17 00:00:00 2001 From: Gabriel Gerlero Date: Wed, 5 Jul 2023 10:27:07 -0300 Subject: [PATCH] Update build workflow --- .github/workflows/build-test.yml | 36 ++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index eafb5df..64b9f9e 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -49,28 +49,36 @@ env: ${{ inputs.openfoam-git-branch != '' && format('OPENFOAM_GIT_BRANCH={0}', inputs.openfoam-git-branch) || '' }} OPENFOAM: ${{ inputs.openfoam-version || inputs.openfoam-git-branch }} - - BUILD_OS: ${{ inputs.build-os || 'macos-11' }} jobs: deps: runs-on: ${{ inputs.build-os || 'macos-11' }} + env: + BUILD_OS: ${{ inputs.build-os || 'macos-11' }} + outputs: + deps-restore-key: ${{ steps.caching.outputs.DEPS_RESTORE_KEY }} + build-restore-key: ${{ steps.caching.outputs.BUILD_RESTORE_KEY }} steps: - name: Checkout uses: actions/checkout@v3 - name: Get Make recipes for caching + id: caching run: | make deps --dry-run $MAKE_VARS > make_deps.txt + DEPS_RESTORE_KEY="deps-${{ env.OPENFOAM }}-${{ env.BUILD_OS }}-${{ hashFiles('make_deps.txt', 'Brewfile') }}-" make build --dry-run $MAKE_VARS > make_build.txt + BUILD_RESTORE_KEY="build-${{ env.OPENFOAM }}-${{ env.BUILD_OS }}-${{ hashFiles('make_build.txt', 'Brewfile', format('OpenFOAM-v${0}.tgz.sha256', inputs.openfoam-version), 'configure.sh') }}-" + echo "DEPS_RESTORE_KEY=$DEPS_RESTORE_KEY" >> "$GITHUB_OUTPUT" + echo "BUILD_RESTORE_KEY=$BUILD_RESTORE_KEY" >> "$GITHUB_OUTPUT" - name: Look up cached build if: inputs.use-cached id: cache_build uses: actions/cache/restore@v3 with: path: build/*-build.sparsebundle - key: ignore + key: ${{ steps.caching.outputs.BUILD_RESTORE_KEY }}${{ github.run_id }} restore-keys: - build-${{ env.OPENFOAM }}-${{ env.BUILD_OS }}-${{ hashFiles('make_build.txt', 'Brewfile', format('OpenFOAM-v${0}.tgz.sha256', inputs.openfoam-version), 'configure.sh') }}- + ${{ steps.caching.outputs.BUILD_RESTORE_KEY }} lookup-only: true - name: Look up cached deps if: inputs.use-cached && steps.cache_build.outputs.cache-matched-key == '' @@ -78,9 +86,9 @@ jobs: uses: actions/cache/restore@v3 with: path: build/*-deps.sparsebundle - key: ignore + key: ${{ steps.caching.outputs.DEPS_RESTORE_KEY }}${{ github.run_id }} restore-keys: - deps-${{ env.OPENFOAM }}-${{ env.BUILD_OS }}-${{ hashFiles('make_deps.txt', 'Brewfile') }}- + ${{ steps.caching.outputs.DEPS_RESTORE_KEY }} lookup-only: true - name: Make deps if: steps.cache_build.outputs.cache-matched-key == '' && steps.cache_deps.outputs.cache-matched-key == '' @@ -91,7 +99,7 @@ jobs: uses: actions/cache/save@v3 with: path: build/*-deps.sparsebundle - key: deps-${{ env.OPENFOAM }}-${{ env.BUILD_OS }}-${{ hashFiles('make_deps.txt', 'Brewfile') }}-${{ github.run_id }} + key: ${{ steps.caching.outputs.DEPS_RESTORE_KEY }}${{ github.run_id }} build: needs: deps @@ -99,28 +107,24 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Get Make recipes for caching - run: | - make deps --dry-run $MAKE_VARS > make_deps.txt - make build --dry-run $MAKE_VARS > make_build.txt - name: Restore cached build if available if: inputs.use-cached id: cache_build uses: actions/cache/restore@v3 with: path: build/*-build.sparsebundle - key: ignore + key: ${{ needs.deps.outputs.build-restore-key }}${{ github.run_id }} restore-keys: - build-${{ env.OPENFOAM }}-${{ env.BUILD_OS }}-${{ hashFiles('make_build.txt', 'Brewfile', format('OpenFOAM-v${0}.tgz.sha256', inputs.openfoam-version), 'configure.sh') }}- + ${{ needs.deps.outputs.build-restore-key }} - name: Restore cached deps if: steps.cache_build.outputs.cache-matched-key == '' id: cache_deps uses: actions/cache/restore@v3 with: path: build/*-deps.sparsebundle - key: ignore + key: ${{ needs.deps.outputs.deps-restore-key }}${{ github.run_id }} restore-keys: - deps-${{ env.OPENFOAM }}-${{ env.BUILD_OS }}-${{ hashFiles('make_deps.txt', 'Brewfile') }}- + ${{ needs.deps.outputs.deps-restore-key }} fail-on-cache-miss: true - name: Reuse cached build or deps run: | @@ -135,7 +139,7 @@ jobs: uses: actions/cache/save@v3 with: path: build/*-build.sparsebundle - key: build-${{ env.OPENFOAM }}-${{ env.BUILD_OS }}-${{ hashFiles('make_build.txt', 'Brewfile', format('OpenFOAM-v${0}.tgz.sha256', inputs.openfoam-version), 'configure.sh') }}-${{ github.run_id }} + key: ${{ needs.deps.outputs.build-restore-key }}${{ github.run_id }} - name: Make app run: | make zip $MAKE_VARS