Skip to content

Commit

Permalink
Update build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
gerlero committed Jul 5, 2023
1 parent fe13d2d commit 9bc15c5
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,38 +49,46 @@ 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 == ''
id: cache_deps
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 == ''
Expand All @@ -91,36 +99,32 @@ 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
runs-on: ${{ inputs.build-os || 'macos-11' }}
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: |
Expand All @@ -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
Expand Down

0 comments on commit 9bc15c5

Please sign in to comment.