Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build workflow #275

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 31 additions & 43 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ on:
type: string
default: ''
required: false
use-cached:
type: boolean
default: true
required: false
cache-build:
type: boolean
default: true
Expand Down Expand Up @@ -69,11 +65,6 @@ on:
- standalone
- bundled
- homebrew
use-cached:
type: boolean
default: true
required: false
description: Reuse cached build artifacts if available
cache-build:
type: boolean
default: true
Expand All @@ -94,82 +85,74 @@ jobs:
deps:
runs-on: ${{ inputs.build-os }}
outputs:
deps-restore-key: ${{ steps.caching.outputs.DEPS_RESTORE_KEY }}
build-restore-key: ${{ steps.caching.outputs.BUILD_RESTORE_KEY }}
deps-key: ${{ steps.keys.outputs.deps-key }}
build-key: ${{ steps.keys.outputs.build-key }}
steps:
- name: Use Xcode Command Line Tools
run: sudo xcode-select --switch /Library/Developer/CommandLineTools
- name: Checkout
uses: actions/checkout@v4
- name: Get Make recipes for caching
- name: Prepare caching
run: |
make deps --dry-run ${{ env.MAKE_VARS }} > make_deps.txt
make build --dry-run ${{ env.MAKE_VARS }} > make_build.txt
- name: Generate cache restore keys
id: caching
brew bundle list | xargs -I {} sh -c 'brew info {} | head -n 1' > brew_versions.txt
brew deps --union $(brew bundle list) | xargs -I {} sh -c 'brew info {} | head -n 1' >> brew_versions.txt
sort -u -o brew_versions.txt brew_versions.txt
cat brew_versions.txt
- name: Generate caching keys
id: keys
run: |
DEPS_RESTORE_KEY="build-${{ env.OPENFOAM }}-${{ inputs.build-os }}-${{ hashFiles('make_deps.txt', 'Brewfile', 'scripts/bundle_deps.py') }}"
BUILD_RESTORE_KEY="$DEPS_RESTORE_KEY-${{ hashFiles('make_build.txt', 'scripts/configure.sh', 'scripts/relativize_install_names.py') }}"
echo "DEPS_RESTORE_KEY=$DEPS_RESTORE_KEY" >> "$GITHUB_OUTPUT"
echo "BUILD_RESTORE_KEY=$BUILD_RESTORE_KEY" >> "$GITHUB_OUTPUT"
DEPS_KEY="build-${{ env.OPENFOAM }}-${{ inputs.build-os }}-${{ hashFiles('make_deps.txt', 'Brewfile', 'scripts/bundle_deps.py', 'brew_versions.txt') }}"
BUILD_KEY="$DEPS_KEY-${{ hashFiles('make_build.txt', 'scripts/configure.sh', 'scripts/relativize_install_names.py') }}"
echo "deps-key=$DEPS_KEY" >> "$GITHUB_OUTPUT"
echo "build-key=$BUILD_KEY" >> "$GITHUB_OUTPUT"
- name: Look up cached deps
id: cache_deps
if: inputs.use-cached
id: cache
uses: actions/cache/restore@v4
with:
path: build/*.sparsebundle
key: ignore
restore-keys: |
${{ steps.caching.outputs.DEPS_RESTORE_KEY }}
key: ${{ steps.keys.outputs.build-key }}
restore-keys: ${{ steps.keys.outputs.deps-key }}
lookup-only: true
- name: Make deps
if: steps.cache_deps.outputs.cache-matched-key == ''
if: steps.cache.outputs.cache-matched-key == ''
run: |
make deps ${{ env.MAKE_VARS }}
- name: Save deps to cache
if: steps.cache_deps.outputs.cache-matched-key == ''
if: steps.cache.outputs.cache-matched-key == ''
uses: actions/cache/save@v4
with:
path: build/*.sparsebundle
key: ${{ steps.caching.outputs.DEPS_RESTORE_KEY }}-${{ github.run_id }}
key: ${{ steps.keys.outputs.deps-key }}

build:
needs: deps
runs-on: ${{ inputs.build-os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore cached build if available
if: inputs.use-cached
id: cache_build
uses: actions/cache/restore@v4
with:
path: build/*.sparsebundle
key: ignore
restore-keys: |
${{ needs.deps.outputs.build-restore-key }}
- name: Restore cached deps
if: steps.cache_build.outputs.cache-matched-key == ''
id: cache_deps
- name: Restore cached build or deps
id: cache
uses: actions/cache/restore@v4
with:
path: build/*.sparsebundle
key: ignore
key: ${{ needs.deps.outputs.build-key }}
restore-keys: |
${{ needs.deps.outputs.deps-restore-key }}
${{ needs.deps.outputs.deps-key }}
fail-on-cache-miss: true
- name: Build
if: steps.cache_build.outputs.cache-matched-key == ''
if: steps.cache.outputs.cache-hit != 'true'
run: |
hdiutil attach build/*.sparsebundle
make --touch deps ${{ env.MAKE_VARS }}
make build ${{ env.MAKE_VARS }}
- name: Save build to cache
if: steps.cache_build.outputs.cache-matched-key == '' && inputs.cache-build
if: steps.cache.outputs.cache-hit != 'true' && inputs.cache-build
uses: actions/cache/save@v4
with:
path: build/*.sparsebundle
key: ${{ needs.deps.outputs.build-restore-key }}-${{ github.run_id }}
key: ${{ needs.deps.outputs.build-key }}
- name: Make app
run: |
hdiutil attach build/*.sparsebundle
Expand All @@ -196,6 +179,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
cache: pip
- name: Install Homebrew dependencies
if: inputs.deps-kind == 'homebrew'
run: |
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ on:
required: true
workflow_dispatch:
inputs:
use-cached:
type: boolean
default: false
required: false
description: Reuse cached build artifacts if available
deps-kind:
type: choice
required: false
Expand Down Expand Up @@ -49,5 +44,4 @@ jobs:
openfoam-version: ${{ matrix.openfoam-version }}
app-version: ${{ inputs.app-version }}
deps-kind: ${{ inputs.deps-kind }}
use-cached: ${{ github.event_name == 'workflow_dispatch' && inputs.use-cached || github.event_name != 'workflow_dispatch' && github.event_name != 'schedule' }}
cache-build: ${{ github.event_name != 'workflow_dispatch' && inputs.cache-build || github.event_name != 'workflow_dispatch' }}
cache-build: ${{ github.event_name == 'workflow_dispatch' && inputs.cache-build || github.event_name != 'workflow_dispatch' }}
1 change: 0 additions & 1 deletion .github/workflows/openfoam-dev-branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ jobs:
app-version: ${{ matrix.openfoam-git-branch }}
openfoam-git-branch: ${{ matrix.openfoam-git-branch }}
deps-kind: ${{ inputs.deps-kind }}
use-cached: false
cache-build: false
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
get-version:
runs-on: ubuntu-latest
outputs:
app-version: ${{ steps.get_version.outputs.VERSION_WITHOUT_V }}
app-version: ${{ steps.get_version.outputs.version-without-v }}
steps:
- name: Extract version from tag
id: get_version
run:
echo "VERSION_WITHOUT_V=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
echo "version-without-v=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"

build:
needs: get-version
Expand Down
Loading