-
Notifications
You must be signed in to change notification settings - Fork 2
115 lines (107 loc) · 3.47 KB
/
pythontests.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
name: Testsuite
on:
[push, pull_request]
defaults:
run:
shell: bash
jobs:
linter:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
echo "dir=$(pip cache dir)" >> $env:GITHUB_OUTPUT
- name: pip cache
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: py${{ matrix.python-version }}-${{ matrix.os }}-pip
- name: Install linter
run: python -m pip install flake8
- name: Check syntax and style
run: python -m flake8 .
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12"]
include:
- python-version: "pypy-3.7"
os: ubuntu-latest
- python-version: "pypy-3.9"
os: ubuntu-latest
- python-version: "pypy-3.10"
os: ubuntu-latest
env:
OS: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
run: |
python -m pip install -U pip # to ensure version > 20 to have cache dir
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
echo "dir=$(pip cache dir)" >> $env:GITHUB_OUTPUT
- name: pip cache
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: py${{ matrix.python-version }}-${{ matrix.os }}-pip
- name: Test environment setup
run: |
python -m pip install wheel
python -m pip install pytest pytest-cov pytest-randomly tox
- name: Run tests
run: |
TOX_PYTHON_VERSION=$(if [[ ${{ matrix.python-version }} == pypy* ]]; then echo ${{ matrix.python-version }} | tr -d .-; else echo py${{ matrix.python-version }} | tr -d .-; fi)
COV_CMD=$(if [ ${{ matrix.python-version }} = 3.10 ]; then echo "--cov=find_dependencies --cov-report=xml"; else echo ; fi) tox -e $(tox -l | grep $TOX_PYTHON_VERSION | paste -sd "," -)
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
if: ${{ success() && matrix.python-version == 3.10 }}
with:
env_vars: OS
name: codecov-pytest-find-dependencies
files: ./coverage.xml
deploy:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-latest
needs: [linter, test]
steps:
- uses: actions/checkout@v4
with:
path: main
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install wheel
run: |
python -m pip install --upgrade pip
pip install wheel
- name: Build package
run: |
cd main
python setup.py sdist bdist_wheel
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages_dir: main/dist/
user: __token__
password: ${{ secrets.PYPI_API_TOKEN_PYTEST_FIND_DEPS }}