Skip to content

Commit

Permalink
update deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
billbrod committed Feb 28, 2024
1 parent b3afb90 commit d91bd82
Showing 1 changed file with 65 additions and 3 deletions.
68 changes: 65 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: deploy
on:
workflow_dispatch:
release:
types: [published]

Expand All @@ -17,9 +18,70 @@ jobs:
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build --outdir dist/ --sdist
run: python -m build --outdir dist/ --sdist --wheel
- name: Check there's only one sdist and one whl file created
shell: bash
# because the following two tests will be weird otherwise. see
# https://askubuntu.com/a/454568 for why this is the right way to handle
# it. using [[ BOOLEAN ]] || EXPR is a compact way of writing IF NOT
# BOOLEAN THEN EXPR in bash
run: |
[[ $(find dist/ -type f -name "*whl" -printf x | wc -c) == 1 ]] || exit 1
[[ $(find dist/ -type f -name "*tar.gz" -printf x | wc -c) == 1 ]] || exit 1
- name: Check setuptools_scm version against git tag
shell: bash
run: |
# we use the error code of this comparison: =~ is bash's regex
# operator, so it checks whether the right side is contained in the
# left side. In particular, we succeed if the path of the source code
# ends in the most recent git tag, fail if it does not.
[[ "$(ls dist/*tar.gz)" =~ "-$(git describe --tags).tar.gz" ]]
- name: Check we can install from wheel
# note that this is how this works in bash (different shells might be
# slightly different). we've checked there's only one .whl file in an
# earlier step, so the bit in `$()` will expand to that single file,
# then we pass [dev] to get specify the optional dev dependencies, and
# we wrap the whole thing in quotes so bash doesn't try to interpret the
# square brackets but passes them directly to pip install
shell: bash
run: |
pip install "$(ls dist/*whl)[dev,nb]"
- name: Run tests
run: |
pytest -n auto
- name: Run notebooks
run: |
for file in examples/*ipynb; do
# these first two notebooks take much longer than the rest to run (2
# and 1 hours on laptop, respectively, longer on runners). So we use
# papermill's parameters to reduce the max number of steps for
# synthesis in them (we want to test that each cell runs, but we
# don't need synthesis to go to completion).
if [[ "$file" =~ "Metamer-Portilla-Simoncelli" ]]; then
papermill $file $file_output.ipynb -p short_synth_max_iter 10 -p long_synth_max_iter 10 -p longest_synth_max_iter 10 -k python3 --cwd examples/
elif [[ "$file" =~ "Demo_Eigendistortion" ]]; then
papermill $file $file_output.ipynb -p max_iter_frontend 10 -p max_iter_vgg 10 -k python3 --cwd examples/
else
jupyter execute $file --kernel_name=python3
fi
done
- uses: actions/upload-artifact@v3
with:
path: dist/*

publish:
name: Upload release to Test PyPI
needs: [build]
environment: pypi
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Publish package to test pypi
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/

0 comments on commit d91bd82

Please sign in to comment.