-
Notifications
You must be signed in to change notification settings - Fork 2
197 lines (191 loc) · 6.94 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: libpymcr
on:
push:
branches: [main]
pull_request:
branches: [main]
types: [opened, reopened, synchronize]
release:
types: [published]
workflow_dispatch:
inputs:
py_version:
type: choice
options: ["3.7", "3.8", "3.9", "3.10", "3.11"]
concurrency :
group: ${{ github.workflow }}-${{ github.ref == 'refs/head/main' && github.run_number || github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -l {0}
env:
# Matlab only provides binaries for 64-bit systems - so force x86_64 builds in "tag"
JSONSTR: |
{
"pyvers": {
"push": ["3.8"],
"pull_request": ["3.8"],
"release": ["3.7", "3.8", "3.9", "3.10", "3.11"],
"workflow_dispatch": ["WORKFLOW_PYVER"]
},
"os_map": {
"ubuntu-22.04": {
"mlver": "R2020a",
"tag": "manylinux_x86_64",
"mlprefix": "/host/"
},
"windows-2022": {
"mlver": "R2021a",
"tag": "win_amd64",
"mlprefix": ""
},
"macos-12": {
"mlver": "R2020a",
"tag": "macosx_x86_64",
"mlprefix": ""
}
}
}
# Must match what is stored in the gists
MCRVER: R2020a
jobs:
cache_matlab:
name: Create Matlab cache, ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, windows-2022, macos-12]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache MCR
if: ${{ matrix.os != 'ubuntu-22.04' }}
id: cache-mcr
uses: actions/cache@v4
with:
path: mcr
key: ${{ runner.os }}-matlab-${{ env.MCRVER }}-mcr
lookup-only: true
- name: Cache gists
id: cache-gists
uses: actions/cache@v4
with:
path: gists
key: ${{ runner.os }}-gists
lookup-only: true
- name: Download gists
if: ${{ steps.cache-gists.outputs.cache-hit != 'true' }}
run: |
mkdir -p gists
pip3 install requests
python3 gist_test_ctf.py --get --token=${{ secrets.GH_GIST_TOKEN }} --dir gists
- name: Install Mac MCR
if: ${{ matrix.os == 'macos-12' && steps.cache-mcr.outputs.cache-hit != 'true' }}
run: |
mkdir -p mcr
unzip -d . -q gists/pace_neutrons_installer.zip
sudo ./pace_neutrons_installer/Contents/MacOS/setup -mode silent -agreeToLicense yes
sleep 10
while [[ ! -z $(ps aux |grep installer | grep mathworks) ]]; do sleep 10; done
cp -r /Applications/MATLAB/MATLAB_Runtime/v98/* mcr/
- name: Install Win MCR
if: ${{ matrix.os == 'windows-2022' && steps.cache-mcr.outputs.cache-hit != 'true' }}
run: |
mkdir -p mcr
powershell -Command "gists\pace_neutrons_installer.exe -mode silent -agreeToLicense yes"
sleep 10
powershell -Command "while(Get-Process pace_neutrons_installer -ErrorAction SilentlyContinue) { Start-Sleep -Seconds 10 }"
cp -r /c/Program\ Files/MATLAB/MATLAB\ Runtime/v98/* mcr/
build_and_test:
name: Build and test, ${{ matrix.os }}, py${{ matrix.pyver }}
needs: cache_matlab
# OS strategy matrix must match key in JSONSTR.os_map above
strategy:
matrix:
os: [ubuntu-22.04, windows-2022, macos-12]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup variables
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
export JSONSTR=$(echo $JSONSTR | sed s/WORKFLOW_PYVER/${{ github.event.inputs.py_version }}/)
fi
export EVENTTYPE=${{ github.event_name }}
if [[ "${{ github.event_name }}" == "pull_request" ]] && [[ "${{ github.event.pull_request.title }}" == *"RELEASE"* ]]; then
python3 release.py --version_check
export EVENTTYPE=release
fi
echo CIBW=`echo $JSONSTR | jq ".os_map[\"${{ matrix.os }}\"].tag as \\\$tag| .pyvers[\"$EVENTTYPE\"] | [.[] | \
capture(\"(?<maj>[0-9]+)\\\\\\.(?<min>[0-9]+)\") | \"cp\(.maj)\(.min)-\(\\\$tag)\"] | @sh" | sed s/[\"\']//g` >> $GITHUB_ENV
echo PYVERS=`echo $JSONSTR | jq ".pyvers[\"$EVENTTYPE\"] | @sh"` >> $GITHUB_ENV
export MLVER=`echo $JSONSTR | jq ".os_map[\"${{ matrix.os }}\"].mlver" | sed s/\"//g`
echo MLVER=$MLVER >> $GITHUB_ENV
echo MLPREFIX=`echo $JSONSTR | jq ".os_map[\"${{ matrix.os }}\"].mlprefix" | sed s/\"//g` >> $GITHUB_ENV
echo "HOSTDIRECTORY=`pwd`" >> $GITHUB_ENV
if [ "$RUNNER_OS" == "Linux" ]; then
echo "MATLABEXECUTABLE=/usr/local/MATLAB/$MLVER/bin/matlab" >> $GITHUB_ENV;
else
echo "MATLABEXECUTABLE=`pwd`/mcr/bin/matlab" >> $GITHUB_ENV;
fi
env
- name: Set up MATLAB
if: ${{ matrix.os == 'ubuntu-22.04' }}
uses: matlab-actions/[email protected]
with:
release: ${{ env.MLVER }}
- uses: actions/cache/restore@v4
if: ${{ matrix.os != 'ubuntu-22.04' }}
with:
path: mcr
key: ${{ runner.os }}-matlab-${{ env.MCRVER }}-mcr
fail-on-cache-miss: true
- uses: actions/cache/restore@v4
with:
path: gists
key: ${{ runner.os }}-gists
fail-on-cache-miss: true
- uses: pypa/[email protected]
env:
CIBW_BUILD: ${{ env.CIBW }}
CIBW_ENVIRONMENT: >-
MATLABEXECUTABLE="${{ env.MLPREFIX }}${{ env.MATLABEXECUTABLE }}"
HOSTDIRECTORY="${{ env.MLPREFIX }}${{ env.HOSTDIRECTORY }}"
CIBW_BUILD_VERBOSITY: 1
MACOSX_DEPLOYMENT_TARGET: "10.15"
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: false
cache-downloads: true
- name: Install wheels and run test
run: |
# set -e makes sure the script fails if any command in the loop fails
set -e
cp -f gists/* test/
for pyver in $(echo $PYVERS | sed s/[\"\']//g); do
$MAMBA_EXE create -n py$pyver -c conda-forge python=$pyver numpy six
eval "$($MAMBA_EXE shell activate py$pyver)"
python -m pip install wheelhouse/*cp$(echo $pyver | sed s/\\.//)*
cd test
# Sometimes the test results in a segfault on exit
python run_test.py || true
test -f success
cd ..
done
- name: Upload release wheels
if: ${{ github.event_name == 'release' }}
run: |
pip3 install requests
python3 release.py --notest --github --token=${{ secrets.GH_GIST_TOKEN }}
#- name: Setup tmate
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}_artifacts.zip
path: |
wheelhouse/*
**/*.mex[awmaci]*64