-
Notifications
You must be signed in to change notification settings - Fork 9
229 lines (222 loc) · 6.98 KB
/
build-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
name: Build and test
on:
workflow_call:
inputs:
openfoam-version:
type: string
default: ''
required: false
app-version:
type: string
default: ''
required: false
app-name:
type: string
default: ''
required: false
openfoam-git-branch:
type: string
default: ''
required: false
deps-kind:
type: string
default: ''
required: false
build-os:
type: string
default: ''
required: false
use-cached:
type: boolean
default: true
required: false
cache-build:
type: boolean
default: true
required: false
release:
type: boolean
default: false
required: false
workflow_dispatch:
inputs:
build-os:
type: string
required: true
description: Build using this macOS image
openfoam-version:
type: string
default: ''
required: false
description: Build this OpenFOAM version
app-name:
type: string
default: ''
required: false
description: Override app name
openfoam-git-branch:
type: string
default: ''
required: false
description: Build this OpenFOAM Git branch
deps-kind:
type: choice
required: false
description: Bundle dependencies in this manner
options:
- ''
- standalone
- bundled
- homebrew
use-cached:
type: boolean
default: true
required: false
description: Reuse cached build artifacts if available
cache-build:
type: boolean
default: true
required: false
description: Cache build artifacts for later reuse
env:
MAKE_VARS: >
${{ inputs.openfoam-version != '' && format('OPENFOAM_VERSION={0}', inputs.openfoam-version) || '' }}
${{ inputs.app-version != '' && format('APP_VERSION={0}', inputs.app-version) || '' }}
${{ inputs.app-name != '' && format('APP_NAME={0}', inputs.app-name) || '' }}
${{ inputs.openfoam-git-branch != '' && format('OPENFOAM_GIT_BRANCH={0}', inputs.openfoam-git-branch) || '' }}
${{ inputs.deps-kind != '' && format('DEPS_KIND={0}', inputs.deps-kind) || '' }}
OPENFOAM: ${{ inputs.openfoam-version || inputs.openfoam-git-branch }}
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 }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Make recipes for 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
run: |
DEPS_RESTORE_KEY="build-${{ env.OPENFOAM }}-${{ inputs.build-os }}-${{ inputs.deps-kind }}-${{ 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"
- name: Look up cached deps
id: cache_deps
if: inputs.use-cached
uses: actions/cache/restore@v4
with:
path: build/*.sparsebundle
key: ignore
restore-keys: |
${{ steps.caching.outputs.DEPS_RESTORE_KEY }}
lookup-only: true
- name: Make deps
if: steps.cache_deps.outputs.cache-matched-key == ''
run: |
make deps ${{ env.MAKE_VARS }}
- name: Save deps to cache
if: steps.cache_deps.outputs.cache-matched-key == ''
uses: actions/cache/save@v4
with:
path: build/*.sparsebundle
key: ${{ steps.caching.outputs.DEPS_RESTORE_KEY }}-${{ github.run_id }}
build:
needs: deps
runs-on: ${{ inputs.build-os }}
outputs:
arch: ${{ runner.arch }}
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
uses: actions/cache/restore@v4
with:
path: build/*.sparsebundle
key: ignore
restore-keys: |
${{ needs.deps.outputs.deps-restore-key }}
fail-on-cache-miss: true
- name: Build
if: steps.cache_build.outputs.cache-matched-key == ''
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
uses: actions/cache/save@v4
with:
path: build/*.sparsebundle
key: ${{ needs.deps.outputs.build-restore-key }}-${{ github.run_id }}
- name: Make app
run: |
hdiutil attach build/*.sparsebundle
make --touch build ${{ env.MAKE_VARS }}
make zip ${{ env.MAKE_VARS }}
- name: Upload app artifact
uses: actions/upload-artifact@v4
with:
name: app-${{ env.OPENFOAM }}-${{ runner.arch }}
path: build/*-app-*.zip
if-no-files-found: error
test:
needs: build
strategy:
matrix:
os: [macos-12, macos-13, macos-14]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Homebrew dependencies
if: inputs.deps-kind == 'homebrew'
run: |
brew bundle
- name: Download app artifact
uses: actions/download-artifact@v4
with:
name: app-${{ env.OPENFOAM }}-${{ needs.build.outputs.arch }}
path: build
- name: Unzip app
run: |
unzip *-app-*.zip
working-directory: build
- name: Test
if: needs.build.outputs.arch == runner.arch
run: |
make test ${{ env.MAKE_VARS }}
release:
needs: test
if: inputs.release
runs-on: ubuntu-latest
steps:
- name: Download app artifact
uses: actions/download-artifact@v4
with:
name: app-${{ env.OPENFOAM }}
- name: Upload app to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: '*-app-*.zip'
tag: ${{ github.ref }}
file_glob: true
overwrite: false