generated from scottclowe/python-template-repo
-
Notifications
You must be signed in to change notification settings - Fork 15
145 lines (126 loc) · 4.13 KB
/
test-release-candidate.yaml
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
# Tests for releases and release candidates
#
# Runs on every tag creation, and all pushes and PRs to release branches
# named "v1.2.x", etc.
#
# This workflow is more extensive than the regular test workflow.
# - Tests are executed on more Python versions
# - Tests are run on more operating systems
# - N.B. There is no pip cache here to ensure runs are always against the
# very latest versions of dependencies, even if this workflow ran recently.
#
# In addition, the package is built as a wheel on each OS/Python job, and these
# are stored as artifacts to use for your distribution process. There is an
# extra job (disabled by default) which can be enabled to push to Test PyPI.
name: release candidate tests
on:
push:
branches:
# Release branches.
# Examples: "v1", "v3.0", "v1.2.x", "1.5.0", "1.2rc0"
# Expected usage is (for example) a branch named "v1.2.x" which contains
# the latest release in the 1.2 series.
- 'v[0-9]+'
- 'v?[0-9]+.[0-9x]+'
- 'v?[0-9]+.[0-9]+.[0-9x]+'
- 'v?[0-9]+.[0-9]+.[0-9]+.[0-9x]+'
- 'v?[0-9]+.[0-9x]+rc[0-9]*'
tags:
# Run whenever any tag is created
- '**'
pull_request:
branches:
# Release branches
- 'v[0-9]+'
- 'v?[0-9]+.[0-9x]+'
- 'v?[0-9]+.[0-9]+.[0-9x]+'
- 'v?[0-9]+.[0-9]+.[0-9]+.[0-9x]+'
- 'v?[0-9]+.[0-9x]+rc[0-9]*'
release:
# Run on a new release
types: [created, edited, published]
jobs:
test-build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.11"]
include:
- os: macos-latest
python-version: "3.11"
- os: macos-latest
python-version: "3.11"
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: System information
run: python .github/workflows/system_info.py
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install flake8
python -m pip install --editable .[test]
- name: Sanity check with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
python -m flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings
python -m flake8 . --count --exit-zero --statistics
- name: Debug environment
run: python -m pip freeze
- name: Test with pytest
run: |
python -m pytest --cov=package_name --cov-report term --cov-report xml --cov-config .coveragerc --junitxml=testresults.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
flags: unittests
env_vars: OS,PYTHON
name: Python ${{ matrix.python-version }} on ${{ runner.os }}
- name: Build wheels
run: |
python -m pip install --upgrade setuptools wheel twine
python setup.py sdist bdist_wheel
- name: Store wheel artifacts
uses: actions/upload-artifact@v3
with:
name: wheel-${{ matrix.os }}-${{ matrix.python-version }}
path: dist/*
- name: Build HTML docs
run: |
python -m pip install --editable .[docs]
cd docs
make html
cd ..
publish:
# Disabled by default
if: |
false &&
startsWith(github.ref, 'refs/tags/')
needs: test-build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download wheel artifacts
uses: actions/download-artifact@v2
with:
name: wheel-*
path: dist/
- name: Store aggregated wheel artifacts
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist/*
- name: Publish package to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/