Edit test.yml #407
Workflow file for this run
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: Test | |
on: | |
push: | |
pull_request: | |
jobs: | |
test: | |
if: github.event_name != 'pull_request' || !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association) | |
name: py${{ matrix.python }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python: [3.7, 3.11] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Install dependencies | |
run: | | |
pip install -U .[dev] | |
pip install pytest pytest-qt # Ensure pytest-qt is installed for Qt tests | |
# Add this step to install Xvfb | |
- name: Set up Xvfb | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y xvfb | |
# Modify the existing pytest run step to use Xvfb | |
- name: Run tests | |
env: | |
DISPLAY: :99.0 # Set the display environment variable for Xvfb | |
run: | | |
xvfb-run -a pytest --maxfail=1 --disable-warnings -q | |
deploy: | |
needs: [test] | |
name: PyPI Deploy | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
id: changes | |
name: Check annotated tag | |
run: | | |
git fetch --tags -f | |
title=$(git for-each-ref --format="%(contents:subject)" ${GITHUB_REF}) | |
body=$(git for-each-ref --format="%(contents:body)" ${GITHUB_REF}) | |
tag="${GITHUB_REF#refs/tags/}" | |
if test "$title" = "Version ${tag#v}" -a -n "$body"; then | |
echo "title=$title" >> "$GITHUB_OUTPUT" | |
DELIM=$(openssl rand -hex 8) | |
echo "body<<$DELIM" >> "$GITHUB_OUTPUT" | |
echo "$body" >> "$GITHUB_OUTPUT" | |
echo "$DELIM" >> "$GITHUB_OUTPUT" | |
else | |
echo "::error title=Missing tag annotation::$tag" | |
changelog=$(git log --pretty='format:%d%n- %s%n%b---' $(git tag --sort=v:refname | tail -n2 | head -n1)..HEAD) | |
cat <<EOF >> "$GITHUB_STEP_SUMMARY" | |
# Missing tag annotation | |
## Fix | |
See <https://github.com/TomographicImaging/eqt/tree/main/CONTRIBUTING.md#releasing>. | |
## Suggested body | |
See <https://github.com/TomographicImaging/eqt/tree/main/CHANGELOG.md>. | |
In particular, check that these commits are described: | |
$changelog | |
EOF | |
exit 1 | |
fi | |
- id: dist | |
uses: casperdcl/deploy-pypi@v2 | |
with: | |
build: true | |
password: ${{ secrets.EQT_SECRET_TOKEN }} | |
upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }} | |
skip_existing: true # allow for annotated tag amendments | |
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
name: Release | |
run: > | |
gh release create | |
--title "${{ steps.changes.outputs.title }}" | |
--notes "${{ steps.changes.outputs.body }}" | |
"${GITHUB_REF#refs/tags/}" | |
dist/${{ steps.dist.outputs.whl }} | |
dist/${{ steps.dist.outputs.targz }} | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }} |