Merge pull request #2481 from pllim/autoconfig-tmppath #228
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build standalone | |
on: | |
push: | |
branches: | |
- main | |
- 'v*' | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash {0} | |
jobs: | |
build_binary: | |
runs-on: ${{ matrix.os }}-latest | |
strategy: | |
matrix: | |
os: [ubuntu, windows, 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@v2 | |
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@v4 | |
with: | |
python-version: "3.10" | |
- name: Install jdaviz | |
run: pip install .[test] | |
- name: Install pyinstaller | |
run: pip install pyinstaller==5.11 | |
- 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 | |
- 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: Run jdaviz cmd in background | |
if: ${{ matrix.os != 'macos' }} | |
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 Voila to get online | |
uses: ifaxity/wait-on-action@628831cec646e6dacca502f34a6c6b46e131e51d # v1.1.0 | |
with: | |
resource: tcp:8866 | |
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@v3 | |
with: | |
name: test-results-${{ matrix.os }} | |
path: standalone/test-results | |
- name: Upload jdaviz standalone (non-OSX) | |
if: ${{ always() && (matrix.os != 'macos') }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: jdaviz-standlone-${{ matrix.os }} | |
path: | | |
standalone/dist/jdaviz | |
- name: Upload jdaviz standalone (OSX) | |
if: ${{ always() && (matrix.os == 'macos') }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: jdaviz-standlone-${{ matrix.os }} | |
path: standalone/dist/jdaviz.dmg |