-
Notifications
You must be signed in to change notification settings - Fork 419
143 lines (134 loc) · 4.51 KB
/
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
# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions
# https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
#
# Needed GitHub Repository Secret:
# PYPI_PASSWORD - PyPI API token allowing write, release access to PyPI.
# Limit scope to just project.
# (See package.python.org example link above.)
name: tests
on:
pull_request:
push:
# If changing default-python be sure to change job "tests" matrix: include: also
env:
default-python: "3.11"
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.default-python }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.default-python }}
- name: Upgrade pip, Install nox
run: |
python -m pip install --upgrade pip
python -m pip install nox
- name: Lint
run: |
nox --error-on-missing-interpreters --non-interactive --session lint
verify-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.default-python }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.default-python }}
- name: Upgrade pip, Install nox
run: |
python -m pip install --upgrade pip
python -m pip install nox
- name: Verify Docs
run: |
nox --error-on-missing-interpreters --non-interactive --session build_docs
tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
include:
- os: windows-latest
python-version: "3.11"
- os: macos-latest
python-version: "3.11"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Persistent Github pip cache
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip${{ matrix.python-version }}
- name: Persistent .pipx_tests/package_cache
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/.pipx_tests/package_cache/${{ matrix.python-version }}
key: pipx-tests-package-cache-${{ runner.os }}-${{ matrix.python-version }}
- name: Upgrade pip, Install nox
run: |
python -m pip install --upgrade pip
python -m pip install nox
- name: Execute Tests
run: |
nox --non-interactive --session tests-${{ matrix.python-version }}
pypi-publish:
name: Publish pipx to PyPI on release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: [verify-docs, lint, tests]
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v4
- name: Set up Python ${{ env.default-python }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.default-python }}
- name: Upgrade pip, Install nox
run: |
python -m pip install --upgrade pip
pip install nox
- name: Build sdist and wheel
run: |
nox --error-on-missing-interpreters --non-interactive --session build
- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@v1.8.7
with:
user: __token__
password: ${{ secrets.pypi_password }}
build-zipapp:
name: Build zipapp
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: [verify-docs, lint, tests]
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v4
- name: Set up Python ${{ env.default-python }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.default-python }}
- name: Upgrade pip, Install shiv
run: |
python -m pip install --upgrade pip
pip install shiv
- name: Build zipapp
run: shiv -c pipx -o ./pipx.pyz git+https://github.com/pypa/pipx@${{ github.ref_name }}
- name: Test zipapp
run: |
python ./pipx.pyz --version
python ./pipx.pyz install black
- name: Upload to releases
uses: softprops/action-gh-release@v1
with:
files: pipx.pyz