Skip to content

Commit

Permalink
Merge pull request #245 from bgilbert/workflows
Browse files Browse the repository at this point in the history
workflows: rename wheels GH artifact; fix archiving source tarball; cleanups
  • Loading branch information
bgilbert authored Nov 18, 2023
2 parents 5fab25f + fd39a83 commit d123249
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
- [ ] Update `CHANGELOG.md` and version in `openslide/_version.py`
- [ ] Create and push signed tag
- [ ] `git clean -dxf && mkdir dist`
- [ ] Find the [workflow run](https://github.com/openslide/openslide-python/actions) for the tag; download its docs and wheels artifacts
- [ ] `unzip /path/to/downloaded/openslide-python-wheels.zip && mv openslide-python-wheels-*/* dist/`
- [ ] Find the [workflow run](https://github.com/openslide/openslide-python/actions/workflows/python.yml) for the tag; download its dist and docs artifacts
- [ ] `unzip /path/to/downloaded/openslide-python-dist.zip && mv openslide-python-dist-*/* dist/`
- [ ] `twine upload dist/*`
- [ ] Recompress tarball with `xz`
- [ ] Attach release notes to [GitHub release](https://github.com/openslide/openslide-python/releases/new); upload tarballs and wheels
Expand Down
57 changes: 34 additions & 23 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,25 @@ jobs:
pre-commit:
name: Rerun pre-commit checks
runs-on: ubuntu-latest
outputs:
dist-base: ${{ steps.paths.outputs.dist }}
docs-base: ${{ steps.paths.outputs.docs }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- name: Check out repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- uses: pre-commit/[email protected]
- name: Run pre-commit hooks
uses: pre-commit/[email protected]
- name: Define artifact paths
id: paths
run: |
suffix="$GITHUB_RUN_NUMBER-$(echo $GITHUB_SHA | cut -c-10)"
echo "dist=openslide-python-dist-$suffix" >> $GITHUB_OUTPUT
echo "docs=openslide-python-docs-$suffix" >> $GITHUB_OUTPUT
tests:
name: Tests
needs: pre-commit
Expand Down Expand Up @@ -83,7 +96,7 @@ jobs:
brew install openslide
;;
esac
- name: Build wheel
- name: Build dist
run: |
if [ -z "${{ matrix.sdist }}" ]; then
wheel_only=-w
Expand All @@ -102,25 +115,27 @@ jobs:
exit 1
fi
esac
basename=openslide-python-wheels-$GITHUB_RUN_NUMBER-$(echo $GITHUB_SHA | cut -c-10)
mkdir -p "artifacts/${basename}"
mv dist/* "artifacts/${basename}"
echo "basename=${basename}" >> $GITHUB_ENV
mkdir -p "artifacts/${{ needs.pre-commit.outputs.dist-base }}"
mv dist/* "artifacts/${{ needs.pre-commit.outputs.dist-base }}"
# save version-specific wheels and oldest abi3 wheel
python -c 'import sys
if sys.version_info < (3, 12): print("archive_wheel=1")' >> $GITHUB_ENV
- name: Install
run: pip install artifacts/${basename}/*.whl
run: pip install artifacts/${{ needs.pre-commit.outputs.dist-base }}/*.whl
- name: Run tests
run: pytest -v
- name: Tile slide
run: python examples/deepzoom/deepzoom_tile.py --viewer -o tiled tests/fixtures/small.svs
- name: Archive wheel
if: env.archive_wheel
- name: Remove wheel from upload
if: matrix.sdist && ! env.archive_wheel
run: rm artifacts/${{ needs.pre-commit.outputs.dist-base }}/*.whl
- name: Archive dist
if: matrix.sdist || env.archive_wheel
uses: actions/upload-artifact@v3
with:
name: ${{ env.basename }}
name: ${{ needs.pre-commit.outputs.dist-base }}
path: artifacts

windows:
name: Windows
needs: pre-commit
Expand Down Expand Up @@ -155,15 +170,13 @@ jobs:
- name: Build wheel
run: |
python -m build -w
basename=openslide-python-wheels-$GITHUB_RUN_NUMBER-$(echo $GITHUB_SHA | cut -c-10)
mkdir -p "artifacts/${basename}"
mv dist/*.whl "artifacts/${basename}"
echo "basename=${basename}" >> $GITHUB_ENV
mkdir -p "artifacts/${{ needs.pre-commit.outputs.dist-base }}"
mv dist/*.whl "artifacts/${{ needs.pre-commit.outputs.dist-base }}"
# save version-specific wheels and oldest abi3 wheel
python -c 'import sys
if sys.version_info < (3, 12): print("archive_wheel=1")' >> $GITHUB_ENV
- name: Install
run: pip install artifacts/${basename}/*.whl
run: pip install artifacts/${{ needs.pre-commit.outputs.dist-base }}/*.whl
- name: Run tests
# Reads OPENSLIDE_PATH
run: pytest -v
Expand All @@ -180,8 +193,9 @@ jobs:
if: env.archive_wheel
uses: actions/upload-artifact@v3
with:
name: ${{ env.basename }}
name: ${{ needs.pre-commit.outputs.dist-base }}
path: artifacts

docs:
name: Docs
needs: pre-commit
Expand All @@ -198,12 +212,9 @@ jobs:
python -m pip install --upgrade pip
pip install sphinx
- name: Build
run: |
basename=openslide-python-docs-$GITHUB_RUN_NUMBER-$(echo $GITHUB_SHA | cut -c-10)
sphinx-build -d doctrees doc artifact/${basename}
echo "basename=${basename}" >> $GITHUB_ENV
run: sphinx-build -d doctrees doc artifact/${{ needs.pre-commit.outputs.docs-base }}
- name: Archive
uses: actions/upload-artifact@v3
with:
name: ${{ env.basename }}
name: ${{ needs.pre-commit.outputs.docs-base }}
path: artifact

0 comments on commit d123249

Please sign in to comment.