forked from openslide/openslide-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
workflows: calculate artifact basenames in pre-commit job
Avoid redundant name calculations. Signed-off-by: Benjamin Gilbert <[email protected]>
- Loading branch information
Showing
1 changed file
with
19 additions
and
18 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,9 @@ 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: | ||
- name: Check out repo | ||
uses: actions/checkout@v4 | ||
|
@@ -26,6 +29,11 @@ jobs: | |
python-version: '3.12' | ||
- name: Run pre-commit hooks | ||
uses: pre-commit/[email protected] | ||
- name: Define artifact 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 | ||
|
@@ -106,27 +114,25 @@ jobs: | |
exit 1 | ||
fi | ||
esac | ||
basename=openslide-python-dist-$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: Remove wheel from upload | ||
if: matrix.sdist && ! env.archive_wheel | ||
run: rm artifacts/$basename/*.whl | ||
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: | ||
|
@@ -163,15 +169,13 @@ jobs: | |
- name: Build wheel | ||
run: | | ||
python -m build -w | ||
basename=openslide-python-dist-$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 | ||
|
@@ -188,7 +192,7 @@ jobs: | |
if: env.archive_wheel | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ env.basename }} | ||
name: ${{ needs.pre-commit.outputs.dist-base }} | ||
path: artifacts | ||
|
||
docs: | ||
|
@@ -207,12 +211,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 |