Skip to content

Commit 5caa394

Browse files
committed
fix
1 parent 9a72fa8 commit 5caa394

File tree

5 files changed

+343
-94
lines changed

5 files changed

+343
-94
lines changed

.github/workflows/build_binaries.yml

Lines changed: 50 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -11,68 +11,66 @@ permissions:
1111
packages: write
1212

1313
jobs:
14-
read_shortname:
14+
validate_metadata:
1515
runs-on: ubuntu-latest
1616
outputs:
17-
status: ${{ steps.read_model_shortname.outputs.model_short_name }}
17+
shortname: ${{ steps.validate_model_metadata.outputs.model_short_name }}
18+
binary: ${{ steps.validate_model_metadata.outputs.model_binary }}
19+
version: ${{ steps.validate_model_metadata.outputs.model_version }}
20+
1821
steps:
1922
- uses: actions/checkout@v4
2023
- name: Set up Python
2124
uses: actions/setup-python@v5
2225
with:
2326
python-version: '3.x'
2427

25-
- name: Find model's shortname
26-
id: read_model_shortname
27-
run: |
28-
python .github/workflows/get_model_shortname.py
29-
30-
- name: Write model's shortname to file
28+
- name: Install dependencies
3129
run: |
32-
echo "${{ steps.read_model_shortname.outputs.model_short_name }}" > shortname.txt
30+
pip install PyYAML
3331
34-
- name: Upload model's shortname
32+
- name: Validate model's metadata
33+
id: validate_model_metadata
34+
run: |
35+
python .github/workflows/validate_model_metadata.py
36+
37+
- name: Upload model's metadata
3538
uses: actions/upload-artifact@v4
3639
with:
37-
name: shortname
38-
path: shortname.txt
40+
name: metadata
41+
path: |
42+
model.yml
43+
README.md
3944
4045
ubuntu:
4146

4247
runs-on: ubuntu-latest
43-
needs: read_shortname
44-
if : needs.read_shortname.outputs.status != ''
48+
needs: validate_metadata
4549
steps:
4650
- uses: actions/checkout@v4
4751
- name: Set up Python
4852
uses: actions/setup-python@v5
4953
with:
5054
python-version: '3.x'
51-
52-
- name: Read model metadata
53-
id: read_model_metadata
54-
run: |
55-
pip install PyYAML
56-
python .github/workflows/read_model_metadata.py
57-
55+
5856
- name: Build model
5957
run: |
6058
make static STATIC_OPENMP=/usr/lib/gcc/x86_64-linux-gnu/12/libgomp.a
6159
6260
- name: Checking binary for model
6361
run: |
64-
ldd ${{ steps.read_model_metadata.outputs.model_binary }}
62+
ldd ${{ needs.validate_metadata.outputs.binary }}
6563
6664
- name: Build model archive
6765
run: |
6866
rm -fr config/PhysiCell_settings-backup.xml
69-
tar -zcvf ${{ steps.read_model_metadata.outputs.model_short_name }}-linux.tar.gz ${{ steps.read_model_metadata.outputs.model_binary }} Makefile main.cpp config/ custom_modules/ model.yml
67+
tar -zcvf ${{ needs.validate_metadata.outputs.shortname }}-linux.tar.gz ${{ needs.validate_metadata.outputs.binary }} Makefile main.cpp config/ custom_modules/ model.yml
7068
7169
7270
windows:
7371
runs-on: windows-2022
74-
needs: read_shortname
75-
if : needs.read_shortname.outputs.status != ''
72+
needs: validate_metadata
73+
7674
defaults:
7775
run:
7876
shell: msys2 {0}
@@ -91,41 +89,35 @@ jobs:
9189
with:
9290
python-version: '3.x'
9391

94-
- name: Read model metadata
95-
id: read_model_metadata
96-
run: |
97-
python .github/workflows/read_model_metadata.py
98-
9992
- name: Build model
10093
run: |
10194
python beta/setup_windows_dep.py
10295
make static
10396
10497
- name: Checking binary for model
10598
run: |
106-
ldd .\\${{ steps.read_model_metadata.outputs.model_binary }}.exe
99+
ldd .\\${{ needs.validate_metadata.outputs.binary }}.exe
107100
108101
- name: Build model archive
109102
run: |
110103
rm -fr config/PhysiCell_settings-backup.xml
111-
tar -zcvf ${{ steps.read_model_metadata.outputs.model_short_name }}-win.tar.gz ${{ steps.read_model_metadata.outputs.model_binary }}.exe *.dll Makefile main.cpp config/ custom_modules/ model.yml
104+
tar -zcvf ${{ needs.validate_metadata.outputs.shortname }}-win.tar.gz ${{ needs.validate_metadata.outputs.binary }}.exe *.dll Makefile main.cpp config/ custom_modules/ model.yml
112105
113106
- uses: actions/upload-release-asset@v1
114107
if: github.event_name == 'release'
115108
env:
116109
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117110
with:
118111
upload_url: ${{ github.event.release.upload_url }}
119-
asset_name: ${{ steps.read_model_metadata.outputs.model_short_name }}-win.tar.gz
120-
asset_path: ${{ github.workspace }}\${{ steps.read_model_metadata.outputs.model_short_name }}-win.tar.gz
112+
asset_name: ${{ needs.validate_metadata.outputs.shortname }}-win.tar.gz
113+
asset_path: ${{ github.workspace }}\${{ needs.validate_metadata.outputs.shortname }}-win.tar.gz
121114
asset_content_type: application/gzip
122115

123116

124117
macos_step0a:
125118

126119
runs-on: macos-13
127-
needs: read_shortname
128-
if : needs.read_shortname.outputs.status != ''
120+
needs: validate_metadata
129121

130122
steps:
131123
- uses: actions/checkout@v4
@@ -142,36 +134,29 @@ jobs:
142134
with:
143135
python-version: '3.x'
144136

145-
- name: Read model metadata
146-
id: read_model_metadata
147-
run: |
148-
pip install PyYAML
149-
python .github/workflows/read_model_metadata.py
150-
151137
- name: Build model
152138
run: |
153139
export MACOSX_DEPLOYMENT_TARGET=13
154140
make PHYSICELL_CPP=g++-13 static
155-
cp ${{ steps.read_model_metadata.outputs.model_binary }} ${{ steps.read_model_metadata.outputs.model_binary }}_macos13
141+
cp ${{ needs.validate_metadata.outputs.binary }} ${{ needs.validate_metadata.outputs.binary }}_macos13
156142
157143
- name: Caching produced project binary
158144
uses: actions/cache@v4
159145
with:
160146
path: |
161-
${{ github.workspace }}/${{ steps.read_model_metadata.outputs.model_binary }}_macos13
147+
${{ github.workspace }}/${{ needs.validate_metadata.outputs.binary }}_macos13
162148
key: ${{ runner.os }}-macos13-${{ github.run_id }}
163149

164150
- name: Look at the generated binary
165151
run: |
166-
otool -L ${{ steps.read_model_metadata.outputs.model_binary }}
167-
otool -l ${{ steps.read_model_metadata.outputs.model_binary }}
168-
lipo -archs ${{ steps.read_model_metadata.outputs.model_binary }}
152+
otool -L ${{ needs.validate_metadata.outputs.binary }}
153+
otool -l ${{ needs.validate_metadata.outputs.binary }}
154+
lipo -archs ${{ needs.validate_metadata.outputs.binary }}
169155
170156
macos_step0b:
171157

172158
runs-on: macos-14
173-
needs: read_shortname
174-
if : needs.read_shortname.outputs.status != ''
159+
needs: validate_metadata
175160

176161
steps:
177162
- uses: actions/checkout@v4
@@ -187,36 +172,30 @@ jobs:
187172
uses: actions/setup-python@v5
188173
with:
189174
python-version: '3.x'
190-
191-
- name: Read model metadata
192-
id: read_model_metadata
193-
run: |
194-
pip install PyYAML
195-
python .github/workflows/read_model_metadata.py
196-
175+
197176
- name: Build model
198177
run: |
199178
export MACOSX_DEPLOYMENT_TARGET=13
200179
make PHYSICELL_CPP=g++-13 static
201-
cp ${{ steps.read_model_metadata.outputs.model_binary }} ${{ steps.read_model_metadata.outputs.model_binary }}_macosm1
180+
cp ${{ needs.validate_metadata.outputs.binary }} ${{ needs.validate_metadata.outputs.binary }}_macosm1
202181
203182
- name: Caching produced project binary
204183
uses: actions/cache@v4
205184
with:
206185
path: |
207-
${{ github.workspace }}/${{ steps.read_model_metadata.outputs.model_binary }}_macosm1
186+
${{ github.workspace }}/${{ needs.validate_metadata.outputs.binary }}_macosm1
208187
key: ${{ runner.os }}-macosm1-${{ github.run_id }}
209188

210189
- name: Look at the generated binary
211190
run: |
212-
otool -L ${{ steps.read_model_metadata.outputs.model_binary }}
213-
otool -l ${{ steps.read_model_metadata.outputs.model_binary }}
214-
lipo -archs ${{ steps.read_model_metadata.outputs.model_binary }}
191+
otool -L ${{ needs.validate_metadata.outputs.binary }}
192+
otool -l ${{ needs.validate_metadata.outputs.binary }}
193+
lipo -archs ${{ needs.validate_metadata.outputs.binary }}
215194
216195
macos_step1:
217196

218197
runs-on: macos-13
219-
needs: [macos_step0a, macos_step0b, read_shortname]
198+
needs: [macos_step0a, macos_step0b, validate_metadata]
220199

221200
steps:
222201
- uses: actions/checkout@v4
@@ -225,47 +204,41 @@ jobs:
225204
with:
226205
python-version: '3.x'
227206

228-
- name: Read model metadata
229-
id: read_model_metadata
230-
run: |
231-
pip install PyYAML
232-
python .github/workflows/read_model_metadata.py
233-
234207
- name: Caching produced project binary
235208
uses: actions/cache@v4
236209
with:
237210
path: |
238-
${{ github.workspace }}/${{ steps.read_model_metadata.outputs.model_binary }}_macosm1
211+
${{ github.workspace }}/${{ needs.validate_metadata.outputs.binary }}_macosm1
239212
key: ${{ runner.os }}-macosm1-${{ github.run_id }}
240213

241214
- name: Caching produced project binary
242215
uses: actions/cache@v4
243216
with:
244217
path: |
245-
${{ github.workspace }}/${{ steps.read_model_metadata.outputs.model_binary }}_macos13
218+
${{ github.workspace }}/${{ needs.validate_metadata.outputs.binary }}_macos13
246219
key: ${{ runner.os }}-macos13-${{ github.run_id }}
247220

248221
- name: Creating universal binary
249222
run: |
250-
lipo -create -output ${{ steps.read_model_metadata.outputs.model_binary }} ${{ steps.read_model_metadata.outputs.model_binary }}_macos13 ${{ steps.read_model_metadata.outputs.model_binary }}_macosm1
223+
lipo -create -output ${{ needs.validate_metadata.outputs.binary }} ${{ needs.validate_metadata.outputs.binary }}_macos13 ${{ needs.validate_metadata.outputs.binary }}_macosm1
251224
252225
- name: Checking universal binary
253226
run: |
254-
lipo -archs ${{ steps.read_model_metadata.outputs.model_binary }}
255-
otool -l ${{ steps.read_model_metadata.outputs.model_binary }}
256-
otool -L ${{ steps.read_model_metadata.outputs.model_binary }}
227+
lipo -archs ${{ needs.validate_metadata.outputs.binary }}
228+
otool -l ${{ needs.validate_metadata.outputs.binary }}
229+
otool -L ${{ needs.validate_metadata.outputs.binary }}
257230
258231
- name: Build project archive
259232
run: |
260233
rm -fr config/PhysiCell_settings-backup.xml
261-
tar -zcvf ${{ steps.read_model_metadata.outputs.model_short_name }}-macos.tar.gz ${{ steps.read_model_metadata.outputs.model_binary }} Makefile main.cpp config/ custom_modules/ model.yml
234+
tar -zcvf ${{ needs.validate_metadata.outputs.shortname }}-macos.tar.gz ${{ needs.validate_metadata.outputs.binary }} Makefile main.cpp config/ custom_modules/ model.yml
262235
263236
- uses: actions/upload-release-asset@v1
264237
if: github.event_name == 'release'
265238
env:
266239
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
267240
with:
268241
upload_url: ${{ github.event.release.upload_url }}
269-
asset_name: ${{ steps.read_model_metadata.outputs.model_short_name }}-macos.tar.gz
270-
asset_path: ${{ github.workspace }}/${{ steps.read_model_metadata.outputs.model_short_name }}-macos.tar.gz
242+
asset_name: ${{ needs.validate_metadata.outputs.shortname }}-macos.tar.gz
243+
asset_path: ${{ github.workspace }}/${{ needs.validate_metadata.outputs.shortname }}-macos.tar.gz
271244
asset_content_type: application/gzip

.github/workflows/get_model_shortname.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/workflows/read_model_metadata.py

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import yaml, os
2+
with open('model.yml') as file:
3+
model = yaml.safe_load(file)
4+
5+
with open('README.md') as file:
6+
readme_content = file.read()
7+
8+
if 'binary' not in model:
9+
raise ValueError("Model metadata must contain a 'binary' key.")
10+
else:
11+
print(f"Model binary: {model['binary']} : OK")
12+
13+
if 'short_name' not in model:
14+
raise ValueError("Model metadata must contain a 'short_name' key.")
15+
else:
16+
print(f"Model short name: {model['short_name']} : OK")
17+
18+
if 'version' not in model:
19+
raise ValueError("Model metadata must contain a 'version' key.")
20+
else:
21+
print(f"Model version: {model['version']} : OK")
22+
23+
if len(readme_content) < 100:
24+
raise ValueError("README.md must contain at least 100 characters.")
25+
else:
26+
print(f"README.md content length: {len(readme_content)} characters : OK")
27+
28+
with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
29+
print(f'model_binary={model['binary']}', file=fh)
30+
print(f'model_short_name={model['short_name']}', file=fh)
31+
print(f'model_version={model['version']}', file=fh)
32+
print(f'model_readme={readme_content}', file=fh)
33+
34+
exit(0)

0 commit comments

Comments
 (0)