Skip to content

Commit 331ef38

Browse files
committed
Add tests to GitHub Actions CI/CD workflow
1 parent c19c53c commit 331ef38

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

.github/workflows/python-tests.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Test suite
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
# Run daily at 0:01 UTC
8+
# https://crontab.guru/#1_0_*_*_*
9+
- cron: 1 0 * * *
10+
11+
jobs:
12+
tests:
13+
name: 👷
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
# max-parallel: 5
18+
matrix:
19+
python-version:
20+
- 3.8
21+
- 2.7
22+
- pypy3
23+
- 3.7
24+
- 3.6
25+
- 3.5
26+
- pypy2
27+
os:
28+
- ubuntu-latest
29+
- ubuntu-16.04
30+
- macOS-latest
31+
- windows-latest
32+
- windows-2016
33+
env:
34+
- TOXENV: python
35+
tox-addargs:
36+
- --use-venv -m unit
37+
- --use-venv -m integration -n auto --duration=5 -k "not test_install"
38+
- --use-venv -m integration -n auto --duration=5 -k "test_install"
39+
40+
env:
41+
TOX_PARALLEL_NO_SPINNER: 1
42+
43+
steps:
44+
- uses: actions/checkout@master
45+
- name: Set up Python ${{ matrix.python-version }}
46+
uses: actions/setup-python@v1
47+
with:
48+
python-version: ${{ matrix.python-version }}
49+
- name: Log Python version
50+
run: >-
51+
python --version
52+
- name: Log Python location
53+
run: >-
54+
which python
55+
- name: Log Python env
56+
run: >-
57+
python -m sysconfig
58+
- name: Cache pip
59+
uses: actions/cache@v1
60+
with:
61+
path: ~/.cache/pip
62+
key: ${{ runner.os }}-pip-${{ hashFiles('tools/requirements/tests.txt') }}-${{ hashFiles('tools/requirements/docs.txt') }}-${{ hashFiles('tox.ini') }}
63+
restore-keys: |
64+
${{ runner.os }}-pip-
65+
${{ runner.os }}-
66+
- name: Install tox
67+
run: >-
68+
python -m pip install --upgrade tox
69+
- name: 'Initialize tox envs: ${{ matrix.env.TOXENV }}'
70+
run: |
71+
${{ startsWith(matrix.os, 'windows-') && 'setx TOXENV ' || 'export TOXENV=' }}${{ (startsWith(matrix.python-version, 'pypy') && matrix.python-version) || (startsWith(matrix.os, 'windows-') && '$TOXENV' || '%TOXENV%') }}
72+
${{ startsWith(matrix.os, 'macOS-') && 'pypy3' == matrix.python-version && 'export TOXENV=pypy3' || '' }}
73+
echo TOXENV="$TOXENV"
74+
python -m tox --parallel auto --notest --skip-missing-interpreters false
75+
env: ${{ matrix.env }}
76+
- name: Test with tox
77+
run: |
78+
${{ startsWith(matrix.os, 'windows-') && 'setx NETWORK_REQUIRED ' || 'export NETWORK_REQUIRED=' }}1
79+
${{ startsWith(matrix.os, 'windows-') && 'setx TOXENV ' || 'export TOXENV=' }}${{ (startsWith(matrix.python-version, 'pypy') && matrix.python-version) || (startsWith(matrix.os, 'windows-') && '$TOXENV' || '%TOXENV%') }}
80+
${{ startsWith(matrix.os, 'macOS-') && 'pypy3' == matrix.python-version && 'export TOXENV=pypy3' || '' }}
81+
echo TOXENV="$TOXENV"
82+
python -m tox --parallel auto -- ${{ matrix.tox-addargs }}
83+
env: ${{ matrix.env }}

0 commit comments

Comments
 (0)