-
Notifications
You must be signed in to change notification settings - Fork 15
166 lines (145 loc) · 5.37 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
163
164
165
166
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:
runs-on: ${{ matrix.os }}
needs: build-python-distributions
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.7", "3.10", "3.12"]
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 }}
- name: install tox
run: |
python -m pip install -U pip wheel &&
python -m pip install ${{ env.TOX_REQUIREMENT }}
- run: python -c "import sys; print(sys.executable)"
- run: python -c "import platform; print(platform.platform())"
- name: Run tox
run: tox -e ${{ matrix.python-version }} --skip-build
- name: Show lines not covered by tests
# No need to run this is all tests and coverage check passes
if: failure()
run: tox -e show-uncovered-lines
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
additional-mypy-checks:
# This is an *additional* check for mypy using the oldest and newest
# supported python
runs-on: ubuntu-latest
# Note that it's not possible to build the package using python 3.7
# (build is only tested on the env.PYTHON_VERSION). Therefore this mypy
# check just uses the build from the previous step. And build is required
# since it creates the wakepy._version module.
needs: build-python-distributions
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: wakepy-python-packages
path: ./dist/
- name: Install python
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d #v5.1
with:
python-version: ${{ matrix.python-version }}
- name: install tox
run: python${{ matrix.python-version }} -m pip install ${{ env.TOX_REQUIREMENT }}
- name: Check code
run: tox -e mypy --skip-build
test-build-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