-
Notifications
You must be signed in to change notification settings - Fork 3
197 lines (187 loc) · 7.48 KB
/
main.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
name: Build macOS pkg Installer
on:
workflow_dispatch:
inputs:
incoming_ref:
description: >
The ref from Cantera/cantera to be built. Can be a tag, commit hash,
or branch name.
required: true
default: "main"
concurrency:
group: ${{ github.ref }}-${{ github.event.inputs.incoming_ref }}
cancel-in-progress: true
env:
MW_HEADERS_DIR: ${{ github.workspace }}/mw_headers
MACOSX_DEPLOYMENT_TARGET: "10.15"
PKG_DIR: ${{ github.workspace }}
ACTION_URL: "https://github.com/Cantera/cantera-macos-pkg/actions/runs/${{ github.run_id }}"
INCOMING_REF: ${{ github.event.inputs.incoming_ref }}
jobs:
post-pending-status:
name: Post a pending workflow status to Cantera/cantera
runs-on: ubuntu-22.04
env:
GITHUB_TOKEN: ${{ secrets.CANTERA_REPO_STATUS }}
outputs:
incoming-sha: ${{ steps.get-incoming-sha.outputs.incoming-sha }}
tag-ref: ${{ steps.munge-incoming-ref.outputs.tag-ref }}
steps:
- name: Munge the incoming ref
id: munge-incoming-ref
run: |
import os
import re
from pathlib import Path
INCOMING_REF = "${{ github.event.inputs.incoming_ref }}"
if INCOMING_REF.startswith("refs/"):
INCOMING_REF = INCOMING_REF.replace("refs/", "")
elif re.match(r"^v\d\.\d\.\d.*$", INCOMING_REF) is not None:
INCOMING_REF = f"tags/{INCOMING_REF}"
else:
INCOMING_REF = f"heads/{INCOMING_REF}"
TAG_REF = "false"
if INCOMING_REF.startswith("tags"):
TAG_REF = "true"
Path(os.environ["GITHUB_ENV"]).write_text(
f"INCOMING_REF={INCOMING_REF}\n"
f"TAG_REF={TAG_REF}"
)
Path(os.environ["GITHUB_OUTPUT"]).write_text(
f"tag-ref={TAG_REF}"
)
shell: python
- name: Get the SHA associated with the incoming ref
id: get-incoming-sha
run: |
INCOMING_SHA=$(gh api repos/cantera/cantera/git/matching-refs/${INCOMING_REF} \
-H "Accept: application/vnd.github.v3+json" --jq ".[0].object.sha")
echo "INCOMING_SHA=${INCOMING_SHA}" >> $GITHUB_ENV
echo "incoming-sha=${INCOMING_SHA}" >> $GITHUB_OUTPUT
- name: Post the status to the upstream commit
id: set-the-status
if: env.TAG_REF == 'false'
run: |
gh api repos/cantera/cantera/statuses/${INCOMING_SHA} \
-H "Accept: application/vnd.github.v3+json" \
--field state='pending' \
--field target_url=$ACTION_URL \
--field context='macOS Package Build' \
--field description="Pending build" \
--silent
build-intel:
name: Build Intel-based package
runs-on: macos-11
needs:
- "post-pending-status"
outputs:
job-status: ${{ job.status }}
steps:
- name: Checkout this repository
uses: actions/checkout@v3
- name: Checkout Cantera repository
uses: actions/checkout@v3
with:
submodules: recursive
repository: Cantera/cantera
path: cantera
ref: ${{ github.event.inputs.incoming_ref }}
# The known_hosts key is generated with `ssh-keygen -F cantera.org` from a
# machine that has previously logged in to cantera.org and trusts
# that it logged in to the right machine
- name: Set up SSH key and host for cloning MATLAB
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.CTDEPLOY_SSH_KEY }}
known_hosts: ${{ secrets.CTDEPLOY_KNOWN_HOSTS }}
- name: Get the MATLAB headers
run: "rsync -azvP [email protected]:. ${MW_HEADERS_DIR}"
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install Python dependencies
run: |
python -m pip install -U pip setuptools
python -m pip install scons
- name: Install Brew dependencies
run: brew install boost
- name: Install Packages
run: sudo /usr/sbin/installer -pkg Packages.pkg -target /
- name: Build Cantera
working-directory: cantera
run: |
echo "matlab_path='${MW_HEADERS_DIR}'" >> cantera.conf
echo "f90_interface='n'" >> cantera.conf
echo "system_sundials='n'" >> cantera.conf
echo "debug='n'" >> cantera.conf
echo "python_package='none'" >> cantera.conf
echo "prefix='${PKG_DIR}'" >> cantera.conf
echo "layout='compact'" >> cantera.conf
echo "logging='debug'" >> cantera.conf
python3 `which scons` build -j3 boost_inc_dir="$(brew --prefix)/include"
- name: Test Cantera
working-directory: cantera
run: python3 `which scons` test-general test-thermo test-kinetics test-transport
- name: Install Cantera
working-directory: cantera
run: python3 `which scons` install
- name: Package Cantera
run: /usr/local/bin/packagesbuild ./cantera-matlab-interface.pkgproj
- name: Upload the pkg artifact
uses: actions/upload-artifact@v3
with:
path: build/*.pkg
name: intel
send_status_to_cantera:
name: Send jobs status to Cantera/cantera
runs-on: ubuntu-22.04
needs:
- "post-pending-status"
- "build-intel"
if: always()
steps:
- name: Collect statuses
run: |
from collections import Counter
import os
statuses = {
"intel": "${{ needs.build-intel.outputs.job-status }}",
}
# This is a deliberate comparison to the empty string.
if all(v == "success" for v in statuses.values()):
overall_status = "success"
elif any(v in ("cancelled", "") for v in statuses.values()):
overall_status = "error"
elif any(v == "failure" for v in statuses.values()):
overall_status = "failure"
status_counts = Counter(statuses.values())
description = []
if overall_status in ("error", "failure"):
if status_counts.get("success") is not None:
description.append(f"{status_counts['success']} succeeded")
if status_counts.get("cancelled") is not None:
description.append(f"{status_counts['cancelled']} cancelled")
if status_counts.get("failure") is not None:
description.append(f"{status_counts['failure']} failed")
if status_counts.get("") is not None:
description.append(f"{status_counts['']} skipped")
description = ", ".join(description)
else:
description = "Successfully built macOS packages!"
with open(os.environ["GITHUB_ENV"], "a") as gh_env:
gh_env.write(f"OVERALL_STATUS={overall_status}\nDESCRIPTION={description}")
shell: python
- name: Post the status to the upstream commit
if: needs.post-pending-status.outputs.tag-ref == 'false'
run: |
INCOMING_SHA=${{ needs.post-pending-status.outputs.incoming-sha }}
gh api repos/cantera/cantera/statuses/${INCOMING_SHA} \
-H "Accept: application/vnd.github.v3+json" \
--field state="${OVERALL_STATUS}" \
--field target_url=$ACTION_URL \
--field context='macOS Package Build' \
--field description="${DESCRIPTION}" \
--silent
env:
GITHUB_TOKEN: ${{ secrets.CANTERA_REPO_STATUS }}