-
Notifications
You must be signed in to change notification settings - Fork 0
198 lines (188 loc) · 7.58 KB
/
main.yaml
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
name: Build MSI
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.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
MW_HEADERS_DIR: ${{ github.workspace }}/mw_headers
ACTION_URL: "https://github.com/Cantera/cantera-windows-binaries/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-20.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}"
)
with open(os.environ["GITHUB_OUTPUT"], "a") as gh_out:
gh_out.write(f"tag-ref={TAG_REF}\n")
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='Windows MSI Package Build' \
--field description="Pending build" \
--silent
build-msi:
outputs:
job-status: ${{ job.status }}
needs:
- "post-pending-status"
env:
BOOST_ROOT: ${{github.workspace}}/3rdparty/boost
BOOST_URL: https://boostorg.jfrog.io/artifactory/main/release/1.75.0/source/boost_1_75_0.7z
name: Build Matlab Package for Windows
runs-on: windows-latest
steps:
- name: Checkout this repository
uses: actions/checkout@v3
- name: Checkout the Cantera repository
uses: actions/checkout@v3
with:
submodules: recursive
repository: Cantera/cantera
path: cantera
ref: ${{ github.event.inputs.incoming_ref }}
- name: Restore Boost cache
uses: actions/cache@v3
id: cache-boost
with:
path: ${{ env.BOOST_ROOT }}
key: boost
- name: Install Boost Headers
if: steps.cache-boost.outputs.cache-hit != 'true'
run: |
BOOST_ROOT=$(echo $BOOST_ROOT | sed 's/\\/\//g')
mkdir -p $BOOST_ROOT
curl --progress-bar --location --output $BOOST_ROOT/download.7z $BOOST_URL
7z -o$BOOST_ROOT x $BOOST_ROOT/download.7z -y -bd boost_1_75_0/boost
mv $BOOST_ROOT/boost_1_75_0/boost $BOOST_ROOT/boost
rm $BOOST_ROOT/download.7z
shell: bash
# 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 deploy
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.CTDEPLOY_SSH_KEY }}
known_hosts: ${{ secrets.CTDEPLOY_KNOWN_HOSTS }}
# If the version of rsync is changed, the directories below have to be updated
- name: Install rsync on Windows
run: choco install rsync --version 6.2.4
# This seems like overkill, but rsync on Windows requires a POSIX-style path
- name: Munge the MW_HEADERS_DIR for Windows rsync
run: |
import os
from pathlib import Path, PurePosixPath
mw_headers_dir = Path(os.environ["MW_HEADERS_DIR"]).resolve()
mw_headers_dir = PurePosixPath(
"/cygdrive",
mw_headers_dir.drive[0],
PurePosixPath(*mw_headers_dir.parts[1:])
)
with Path(os.environ["GITHUB_ENV"]).open(mode="a") as gh_env:
gh_env.write(f"CYG_MW_HEADERS_DIR={mw_headers_dir}")
shell: python
# When I tried this a few times, it only worked when I used powershell and had the
# SSH options all in the single line with single quotes. Note that there is a
# separate SSH binary pre-installed on the Windows runners that comes before this
# one on the PATH, but it is linked with the wrong Cygwin DLL, so it will not work.
- name: Get the MATLAB headers
run: |
rsync -azvP -e `
'C:\ProgramData\chocolatey\lib\rsync\tools\cwrsync_6.2.4_x64_free\bin\ssh.exe -i C:\Users\runneradmin\.ssh\id_rsa -o UserKnownHostsFile=C:\Users\runneradmin\.ssh\known_hosts' `
ctdeploy@cantera.org:. $Env:CYG_MW_HEADERS_DIR
shell: powershell
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install Python dependencies
run: |
python -m pip install -U pip setuptools
python -m pip install scons pypiwin32 numpy ruamel.yaml cython
- name: Build Cantera
run: build.bat
shell: cmd
- name: Upload the MSI artifact
uses: actions/upload-artifact@v3
with:
path: 'cantera/*.msi'
send_status_to_cantera:
name: Send jobs status to Cantera/cantera
runs-on: ubuntu-20.04
needs:
- "post-pending-status"
- "build-msi"
if: always()
steps:
- name: Get the overall job description
run: |
INCOMING_SHA=${{ needs.post-pending-status.outputs.incoming-sha }}
OVERALL_STATUS=${{ needs.build-msi.outputs.job-status }}
if [ "$OVERALL_STATUS" == "success" ]; then
DESCRIPTION="succeeded"
elif [ "$OVERALL_STATUS" == "failure" ]; then
DESCRIPTION="failed"
else
DESCRIPTION="$OVERALL_STATUS"
fi
echo "INCOMING_SHA=${INCOMING_SHA}" >> $GITHUB_ENV
echo "OVERALL_STATUS=${OVERALL_STATUS}" >> $GITHUB_ENV
echo "DESCRIPTION=${DESCRIPTION}" >> $GITHUB_ENV
- name: Post the status
if: needs.post-pending-status.outputs.tag-ref == 'false'
run: |
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='Windows MSI Package Build' \
--field description="Building MSI ${DESCRIPTION}." \
--silent
env:
GITHUB_TOKEN: ${{ secrets.CANTERA_REPO_STATUS }}