Skip to content

Commit 61336c2

Browse files
authored
Merge pull request #233 from graingert/configure-isolated-builds
configure isolated builds and pypi upload
2 parents 7792227 + c6503a9 commit 61336c2

File tree

3 files changed

+118
-53
lines changed

3 files changed

+118
-53
lines changed

.github/workflows/main.yml

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
pull_request:
99

1010
jobs:
11-
modernize:
11+
tox:
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
fail-fast: false
@@ -34,7 +34,9 @@ jobs:
3434
uses: actions/cache@v2
3535
with:
3636
path: ${{ steps.pip-cache.outputs.dir }}
37-
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.cfg') }}
37+
key:
38+
${{ runner.os }}-pip-${{ hashFiles('pyproject.toml', 'setup.py',
39+
'setup.cfg') }}
3840
restore-keys: |
3941
${{ runner.os }}-pip-
4042
@@ -45,4 +47,30 @@ jobs:
4547
- name: tox
4648
env:
4749
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48-
run: tox -e py,lint,coveralls
50+
run: tox -e py,lint,coveralls,release
51+
52+
- name: upload dist
53+
uses: actions/upload-artifact@v2
54+
with:
55+
name: ${{ matrix.os }}_${{ matrix.python-version}}_dist
56+
path: dist
57+
58+
all-successful:
59+
# https://github.community/t/is-it-possible-to-require-all-github-actions-tasks-to-pass-without-enumerating-them/117957/4?u=graingert
60+
runs-on: ubuntu-latest
61+
needs: [tox]
62+
steps:
63+
- name: Download dists for PyPI
64+
uses: actions/download-artifact@v2
65+
with:
66+
name: ubuntu-latest_3.8_dist
67+
68+
- name: Publish package
69+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
70+
uses: pypa/gh-action-pypi-publish@master
71+
with:
72+
user: __token__
73+
password: ${{ secrets.pypi_password }}
74+
75+
- name: note that all tests succeeded
76+
run: echo "🎉"

pyproject.toml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
[build-system]
2+
requires = [ "setuptools >= 35.0.2", "wheel >= 0.29.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.isort]
6+
profile = "black"
7+
add_imports="from __future__ import generator_stop"
8+
9+
[tool.pytest.ini_options]
10+
addopts = [
11+
"--strict-config",
12+
"--strict-markers",
13+
"--cov",
14+
"--cov-fail-under=91.53",
15+
"--cov-report=term-missing:skip-covered",
16+
]
17+
xfail_strict = true
18+
junit_family = "xunit2"
19+
filterwarnings = ["error"]
20+
21+
[tool.coverage.run]
22+
branch = true
23+
source_pkgs = [
24+
"modernize",
25+
"libmodernize",
26+
]
27+
source = ["tests"]
28+
29+
[tool.coverage.paths]
30+
source = [
31+
".",
32+
".tox/*/lib/*/site-packages/",
33+
'.tox\\*\\Lib\\site-packages\\',
34+
]
35+
36+
37+
[tool.tox]
38+
legacy_tox_ini = """
39+
; tox configuration file for running tests on local dev env and Travis CI.
40+
;
41+
; The local dev environment will be executed against latest released Twisted.
42+
; The coverage is reported only and local dev and not on Travis-CI as there
43+
; we have separate reported (ex codecov.io)
44+
45+
[tox]
46+
envlist =
47+
py{36,37,38},lint
48+
minversion=3.20.0
49+
requires=
50+
virtualenv >= 20.0.31
51+
tox-wheel >= 0.5.0
52+
53+
[testenv]
54+
extras = test
55+
commands = pytest {posargs}
56+
wheel = True
57+
wheel_pep517 = True
58+
wheel_build_env = build
59+
60+
[testenv:build]
61+
# empty environment to build universal wheel once per tox invocation
62+
# https://github.com/ionelmc/tox-wheel#build-configuration
63+
64+
[testenv:coveralls]
65+
passenv = GITHUB_*
66+
deps =
67+
coveralls
68+
coverage>=5.3
69+
commands = coveralls
70+
71+
[testenv:lint]
72+
deps = pre-commit
73+
commands = pre-commit run --all-files --show-diff-on-failure {posargs}
74+
skip_install = true
75+
76+
77+
[testenv:release]
78+
deps = pep517
79+
whitelist_externals =
80+
cp
81+
rm
82+
commands =
83+
rm -rf {toxinidir}/dist
84+
cp -r {distdir} {toxinidir}/dist # copy the wheel built by tox-wheel
85+
{envpython} -m pep517.build --source --out-dir={toxinidir}/dist {toxinidir}
86+
"""

setup.cfg

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -42,59 +42,10 @@ universal = 1
4242

4343
[zest.releaser]
4444
python-file-with-version = libmodernize/__init__.py
45+
tag-format = v{version}
4546

4647
[flake8]
4748
disable-noqa = True
4849
max-line-length = 88
4950
extend-ignore =
5051
E203, # whitespace before : is not PEP8 compliant (& conflicts with black)
51-
52-
[isort]
53-
profile = black
54-
add_imports=from __future__ import generator_stop
55-
56-
[tool:pytest]
57-
addopts =
58-
--strict-config
59-
--strict-markers
60-
--cov
61-
--cov-fail-under=91.53
62-
--cov-report=term-missing:skip-covered
63-
xfail_strict = True
64-
junit_family = xunit2
65-
filterwarnings =
66-
error
67-
68-
[coverage:run]
69-
branch = True
70-
source_pkgs =
71-
modernize
72-
libmodernize
73-
source =
74-
tests
75-
76-
[coverage:paths]
77-
source =
78-
.
79-
.tox/*/lib/*/site-packages/
80-
.tox\\*\\Lib\\site-packages\\
81-
82-
[tox:tox]
83-
envlist =
84-
py{36,37,38},lint
85-
86-
[testenv]
87-
extras = test
88-
commands = pytest {posargs}
89-
90-
[testenv:coveralls]
91-
passenv = GITHUB_*
92-
deps =
93-
coveralls
94-
coverage>=5.3
95-
commands = coveralls
96-
97-
[testenv:lint]
98-
deps = pre-commit
99-
commands = pre-commit run --all-files --show-diff-on-failure {posargs}
100-
skip_install = true

0 commit comments

Comments
 (0)