-
Notifications
You must be signed in to change notification settings - Fork 3
99 lines (91 loc) · 3.15 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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 }}