-
Notifications
You must be signed in to change notification settings - Fork 15
162 lines (147 loc) · 5.55 KB
/
build-and-run-tests.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: Build and test wakepy
'on':
# Allows for manually starting tests
workflow_dispatch:
# Make this a reusable workflow
workflow_call:
# Triggers when pull request is created and when pushing to PR
pull_request:
# Common environment variables
env:
TOX_REQUIREMENT: 'tox -c requirements/requirements-test.txt'
# List of available versions: https://github.com/actions/python-versions/blob/main/versions-manifest.json
PYTHON_VERSION: '3.10'
jobs:
build-python-distributions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get history and tags for setuptools-scm
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
git describe --tags
git describe --tags $(git rev-list --tags --max-count=1)
- name: Install python
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d #v5.1
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: install tox
run: |
python${{ env.PYTHON_VERSION }} -m pip install -U pip wheel && \
python${{ env.PYTHON_VERSION }} -m pip install ${{ env.TOX_REQUIREMENT }}
- name: Build with tox
run: tox -e build
- uses: actions/upload-artifact@v4
with:
name: wakepy-python-packages
path: ./dist/*.*
if-no-files-found: error
retention-days: 1
test-supported-python-versions:
name: Tests (${{ matrix.python-version }} on ${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: build-python-distributions
strategy:
matrix:
os: [ubuntu-latest]
# All supported python versions on linux
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.8", "pypy3.10"]
include:
# Oldest supported python on MacOS
- python-version: "3.7"
os: macos-13
# Newest supported python on MacOS
- python-version: "3.13"
os: macos-latest
# Oldest supported python on Windows
- python-version: "3.7"
os: windows-latest
# Newest supported python on Windows
- python-version: "3.13"
os: windows-latest
# PyPy on Windows
- python-version: "pypy3.10"
os: windows-latest
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: wakepy-python-packages
path: ./dist/
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d #v5.1
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Run tox
run: |
python -m pip install ${{ env.TOX_REQUIREMENT }}
tox -e ${{ matrix.python-version }} --skip-build
tox -e mypy --skip-build
- name: Show uncovered lines
if: success() || failure()
run: tox -e show-uncovered-lines
check-code:
# Reasons this is a separate job
# (1) This runs fast. Different from the other steps, this does not require
# the build step. It gives instant feedback if code has minor problems.
# (2) This runs isort + black + ruff + mypy. For most of there it is enough
# to run it once with one version of python and one OS.
# (3) This runs more comprehensive mypy check as it checks also the tests
# whereas the mypy check in test jobs only runs mypy on the /src
# folder. Note that some mypy check results depend on the used version
# of python and therefore it needs also a separate step (with multiple
# versions of python)
name: Check code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install python
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d #v5.1
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: install tox
run: |
python${{ env.PYTHON_VERSION }} -m pip install -U pip wheel && \
python${{ env.PYTHON_VERSION }} -m pip install ${{ env.TOX_REQUIREMENT }}
- name: Check code
run: tox -e check
test-build-docs:
name: Test building docs
runs-on: ubuntu-latest
needs: build-python-distributions
steps:
- uses: actions/checkout@v4
- name: Install python
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d #v5.1
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: install tox
run: |
python${{ env.PYTHON_VERSION }} -m pip install -U pip wheel && \
python${{ env.PYTHON_VERSION }} -m pip install ${{ env.TOX_REQUIREMENT }}
- name: Test building docs
run: tox -e builddocs
# Cancel in-progress jobs/runs for the same workflow; if you push to same
# pull request twice, the previous workflow should be canceled.
# From: https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# See: https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
permissions:
actions: write
checks: none
contents: read
deployments: none
id-token: none
issues: none
discussions: none
packages: none
pages: none
pull-requests: none
repository-projects: none
security-events: read
statuses: none