Skip to content

Commit 51b0711

Browse files
committed
gh-tox
1 parent 789c547 commit 51b0711

File tree

2 files changed

+35
-13
lines changed

2 files changed

+35
-13
lines changed

.github/workflows/python-package.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ on: [push, pull_request]
99
jobs:
1010
build:
1111

12-
runs-on: ubuntu-latest
12+
runs-on: ${{ matrix.operating-system }}-latest
1313
strategy:
1414
fail-fast: false
1515
matrix:
16+
operating-system: [ubuntu, windows, macos]
1617
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
1718

1819
steps:
@@ -24,8 +25,8 @@ jobs:
2425
- name: Install dependencies
2526
run: |
2627
python -m pip install --upgrade pip
27-
python -m pip install flake8 tox
28-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
28+
python -m pip install flake8 tox-gh
29+
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
2930
- name: Lint with flake8
3031
run: |
3132
# stop the build if there are Python syntax errors or undefined names
@@ -34,7 +35,7 @@ jobs:
3435
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
3536
- name: Test with tox
3637
run: |
37-
tox --skip-missing-interpreters
38+
python -m tox r
3839
env:
3940
LUOGU_USERNAME: ${{ secrets.LUOGU_USERNAME }}
4041
LUOGU_PASSWORD: ${{ secrets.LUOGU_PASSWORD }}

tox.ini

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
11
[tox]
2-
envlist = py36,py37,py38,py39,py310
3-
isolated_build = True
2+
envlist = py36, py37, py38, py39, py310, lint, docs
3+
isolated_build = true
44

55
[testenv]
6-
allowlist_externals = bash
76
passenv = *
7+
deps = coverage
8+
commands =
9+
coverage run --source={envsitepackagesdir}{/}luogu -m tests
10+
11+
[testenv:lint]
12+
skip_install = true
813
deps =
9-
codecov
10-
coverage
1114
black
1215
flake8
1316
commands =
14-
flake8 {envsitepackagesdir}{/}luogu
15-
black --exclude "__pycache__" --check {envsitepackagesdir}{/}luogu
16-
coverage run --source={envsitepackagesdir}{/}luogu -m tests
17-
bash -c "if [[ ! -z $\{GITHUB_ACTIONS\} ]]; then codecov; fi"
17+
flake8 src tests
18+
black src tests
19+
20+
[testenv:docs]
21+
allowlist_externals = make
22+
skip_install = true
23+
deps = -rdocs/requirements.txt
24+
commands =
25+
make -C docs html
26+
27+
[testenv:codecov]
28+
skip_install = true
29+
deps = codecov
30+
commands = codecov
31+
32+
[gh]
33+
python =
34+
3.6 = py36, codecov
35+
3.7 = py37, codecov
36+
3.8 = py38, codecov, lint, docs
37+
3.9 = py39, codecov
38+
3.10 = py310, codecov
1839

1940
[flake8]
2041
max-line-length = 88

0 commit comments

Comments
 (0)