forked from spacetelescope/jdaviz
-
Notifications
You must be signed in to change notification settings - Fork 1
198 lines (166 loc) · 6.92 KB
/
standalone.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
name: Build standalone
on:
push:
branches:
- main
- 'v*'
tags:
- 'v*'
workflow_dispatch:
pull_request:
types: [opened, synchronize, labeled, unlabeled]
defaults:
run:
shell: bash {0}
jobs:
build_binary_not_osx:
runs-on: ${{ matrix.os }}-latest
if: (github.repository == 'spacetelescope/jdaviz' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'Build standalone')))
strategy:
matrix:
os: [ubuntu, windows]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install jdaviz
run: pip install .[test]
- name: Install pyinstaller
run: pip install "pyinstaller<6"
- name: Create standalone binary
env:
DEVELOPER_ID_APPLICATION: ${{ secrets.DEVELOPER_ID_APPLICATION }}
run: (cd standalone; pyinstaller ./jdaviz.spec)
- name: Run jdaviz cmd in background
run: ./standalone/dist/jdaviz/jdaviz-cli imviz&
- name: Install playwright
run: (pip install playwright; playwright install chromium)
- name: Install pytest
run: pip install pytest-playwright
- name: Wait for Solara to get online
uses: ifaxity/wait-on-action@a7d13170ec542bdca4ef8ac4b15e9c6aa00a6866 # v1.2.1
with:
resource: tcp:8765
timeout: 60000
- name: Test standalone
run: (cd standalone; touch pytest.ini; JUPYTER_PLATFORM_DIRS=1 pytest test_standalone.py --video=on)
- name: Upload Test artifacts
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.os }}
path: standalone/test-results
- name: Upload jdaviz standalone (non-OSX)
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: jdaviz-standlone-${{ matrix.os }}
path: |
standalone/dist/jdaviz
# Do not want to deal with OSX certs in pull request builds.
build_binary_osx:
runs-on: ${{ matrix.os }}-latest
if: (github.repository == 'spacetelescope/jdaviz' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch'))
strategy:
matrix:
os: [macos]
steps:
# osx signing based on https://melatonin.dev/blog/how-to-code-sign-and-notarize-macos-audio-plugins-in-ci/
- name: Import Certificates (macOS)
uses: apple-actions/import-codesign-certs@v3
if: ${{ matrix.os == 'macos' }}
with:
p12-file-base64: ${{ secrets.DEV_ID_APP_CERT }}
p12-password: ${{ secrets.DEV_ID_APP_PASSWORD }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install jdaviz
run: pip install .[test]
- name: Install pyinstaller
run: pip install "pyinstaller<6"
- name: Create standalone binary
env:
DEVELOPER_ID_APPLICATION: ${{ secrets.DEVELOPER_ID_APPLICATION }}
run: (cd standalone; pyinstaller ./jdaviz.spec)
- name: Remove invalid files for OSX
# hopefully we can improve this in the future
# by using good hooks
# i think the issue is that we have a . in the name, there are many
# google hits on pyqt having the same issue
# and we might be able to remove it after https://github.com/pyinstaller/pyinstaller/pull/7619
# is released (pyinstaller 5.13 probably)
if: ${{ matrix.os == 'macos' }}
run: |
rm -rf standalone/dist/jdaviz.app/Contents/MacOS/skimage/.dylibs
rm -rf standalone/dist/jdaviz.app/Contents/Resources/skimage/.dylibs
rm -rf standalone/dist/jdaviz.app/Contents/MacOS/shapely/.dylibs
rm -rf standalone/dist/jdaviz.app/Contents/Resources/shapely/.dylibs
rm -rf standalone/dist/jdaviz.app/Contents/MacOS/scipy/.dylibs
rm -rf standalone/dist/jdaviz.app/Contents/Resources/scipy/.dylibs
rm -rf standalone/dist/jdaviz.app/Contents/Resources/scipy/special/*.dylib
- name: Codesign (OSX)
if: ${{ matrix.os == 'macos' }}
run: |
cd standalone/dist
codesign --deep --force --options=runtime --entitlements ../entitlements.plist --sign ${{ secrets.DEVELOPER_ID_APPLICATION }} --timestamp jdaviz.app
- name: Create dmg (OSX)
# if we do not call always() GHA will && with success()
if: ${{ always() && (matrix.os == 'macos') }}
# it seems ditto (not zip) should be used in combination with notarization
# see https://developer.apple.com/forums/thread/116831
# but dmg also works
# see https://github.com/glue-viz/glue-standalone-apps/blob/main/.github/workflows/build_stable.yml
run: |
rm -rf standalone/dist/jdaviz
hdiutil create -volname "Jdaviz" -srcfolder standalone/dist -ov -format UDZO standalone/dist/jdaviz.dmg
- name: Notary step + stapling (OSX)
if: ${{ matrix.os == 'macos' }}
run: |
output=$(xcrun notarytool submit standalone/dist/jdaviz.dmg --apple-id ${{ secrets.NOTARIZATION_USERNAME }} --team-id ${{ secrets.TEAM_ID }} --wait --password ${{ secrets.NOTARIZATION_PASSWORD }}) || true
echo "$output"
uuid=$(echo "$output" | awk -F '[ :]+' '/id:/ {print $3; exit}')
echo "UUID: $uuid"
if [[ $output == *"status: Accepted"* ]]; then
echo "Great, notarization succeeded, staple it!"
xcrun stapler staple standalone/dist/jdaviz.dmg
else
echo "Log output for failed notarization: $uuid"
xcrun notarytool log --apple-id ${{ secrets.NOTARIZATION_USERNAME }} --team-id ${{ secrets.TEAM_ID }} --password ${{ secrets.NOTARIZATION_PASSWORD }} $uuid || true
fi
- name: Validate app (OSX)
if: ${{ matrix.os == 'macos' }}
run: |
spctl -a -vvv -t execute standalone/dist/jdaviz.app
- name: Run jdaviz cmd in background
if: ${{ matrix.os == 'macos' }}
run: ./standalone/dist/jdaviz.app/Contents/MacOS/jdaviz-cli imviz&
- name: Install playwright
run: (pip install playwright; playwright install chromium)
- name: Install pytest
run: pip install pytest-playwright
- name: Wait for Solara to get online
uses: ifaxity/wait-on-action@a7d13170ec542bdca4ef8ac4b15e9c6aa00a6866 # v1.2.1
with:
resource: tcp:8765
timeout: 60000
- name: Test standalone
run: (cd standalone; touch pytest.ini; JUPYTER_PLATFORM_DIRS=1 pytest test_standalone.py --video=on)
- name: Upload Test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.os }}
path: standalone/test-results
- name: Upload jdaviz standalone (OSX)
if: ${{ always() && (matrix.os == 'macos') }}
uses: actions/upload-artifact@v4
with:
name: jdaviz-standlone-${{ matrix.os }}
path: standalone/dist/jdaviz.dmg