Skip to content

Commit 9e949f8

Browse files
committed
Move CI to Github Actions
Signed-off-by: Bernát Gábor <gaborjbernat@gmail.com>
1 parent 717b764 commit 9e949f8

File tree

9 files changed

+310
-408
lines changed

9 files changed

+310
-408
lines changed

.github/workflows/check.yml

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
name: check
2+
on:
3+
push:
4+
pull_request:
5+
schedule:
6+
- cron: "0 8 * * *"
7+
8+
concurrency:
9+
group: check-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: actions/setup-python@v2
18+
- uses: pre-commit/action@v2.0.3
19+
20+
test:
21+
name: test ${{ matrix.py }} - ${{ matrix.os }}
22+
runs-on: ${{ matrix.os }}
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
py:
27+
- "3.10"
28+
- "pypy-3.7-v7.3.7" # ahead to start it earlier because takes longer
29+
- "pypy-2.7-v7.3.6" # ahead to start it earlier because takes longer
30+
- "3.9"
31+
- "3.8"
32+
- "3.7"
33+
- "3.6"
34+
- "3.5"
35+
- "2.7"
36+
os:
37+
- ubuntu-20.04
38+
- windows-2022
39+
- macos-10.15
40+
41+
steps:
42+
- name: Setup python for tox
43+
uses: actions/setup-python@v2
44+
with:
45+
python-version: "3.10"
46+
- name: Install tox
47+
run: python -m pip install tox
48+
- uses: actions/checkout@v2
49+
with:
50+
fetch-depth: 0
51+
- name: Setup python for test ${{ matrix.py }}
52+
uses: actions/setup-python@v2
53+
with:
54+
python-version: ${{ matrix.py }}
55+
- name: Pick environment to run
56+
run: |
57+
import codecs
58+
import os
59+
import platform
60+
import sys
61+
cpy = platform.python_implementation() == "CPython"
62+
base =("{}{}{}" if cpy else "{}{}").format("py" if cpy else "pypy", *sys.version_info[0:2])
63+
env = "TOXENV={}\n".format(base)
64+
print("Picked:\n{}for{}".format(env, sys.version))
65+
with codecs.open(os.environ["GITHUB_ENV"], "a", "utf-8") as file_handler:
66+
file_handler.write(env)
67+
shell: python
68+
- name: Setup test suite
69+
run: tox -vv --notest
70+
- name: Run test suite
71+
run: tox --skip-pkg-install
72+
env:
73+
PYTEST_ADDOPTS: "-vv --durations=20"
74+
CI_RUN: "yes"
75+
DIFF_AGAINST: HEAD
76+
- name: Rename coverage report file
77+
run: import os; import sys; os.rename(".tox/.coverage.{}".format(os.environ['TOXENV']), ".tox/.coverage.{}-{}.format(os.environ['TOXENV'], sys.platform)")
78+
shell: python
79+
- name: Upload coverage data
80+
uses: actions/upload-artifact@v2
81+
with:
82+
name: coverage-data
83+
path: ".tox/.coverage.*"
84+
85+
coverage:
86+
name: Combine coverage
87+
runs-on: ubuntu-latest
88+
needs: test
89+
steps:
90+
- uses: actions/checkout@v2
91+
with:
92+
fetch-depth: 0
93+
- uses: actions/setup-python@v2
94+
with:
95+
python-version: "3.10"
96+
- name: Install tox
97+
run: python -m pip install tox
98+
- name: Setup coverage tool
99+
run: tox -e coverage --notest
100+
- name: Install package builder
101+
run: python -m pip install build
102+
- name: Build package
103+
run: pyproject-build --wheel .
104+
- name: Download coverage data
105+
uses: actions/download-artifact@v2
106+
with:
107+
name: coverage-data
108+
path: .tox
109+
- name: Combine and report coverage
110+
run: tox -e coverage
111+
- name: Upload HTML report
112+
uses: actions/upload-artifact@v2
113+
with:
114+
name: html-report
115+
path: .tox/htmlcov
116+
117+
check:
118+
name: ${{ matrix.tox_env }} - ${{ matrix.os }}
119+
runs-on: ${{ matrix.os }}
120+
strategy:
121+
fail-fast: false
122+
matrix:
123+
os:
124+
- ubuntu-20.04
125+
- windows-2022
126+
tox_env:
127+
- dev
128+
- docs
129+
- readme
130+
exclude:
131+
- { os: windows-2022, tox_env: readme }
132+
steps:
133+
- uses: actions/checkout@v2
134+
with:
135+
fetch-depth: 0
136+
- name: Setup Python "3.10"
137+
uses: actions/setup-python@v2
138+
with:
139+
python-version: "3.10"
140+
- name: Install tox
141+
run: python -m pip install tox
142+
- name: Setup test suite
143+
run: tox -vv --notest -e ${{ matrix.tox_env }}
144+
- name: Run test suite
145+
run: tox --skip-pkg-install -e ${{ matrix.tox_env }}
146+
147+
publish:
148+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
149+
needs: [ check, coverage, lint ]
150+
runs-on: ubuntu-20.04
151+
steps:
152+
- name: Setup python to build package
153+
uses: actions/setup-python@v2
154+
with:
155+
python-version: "3.10"
156+
- name: Install build
157+
run: python -m pip install build
158+
- uses: actions/checkout@v2
159+
with:
160+
fetch-depth: 0
161+
- name: Build sdist and wheel
162+
run: python -m build -s -w . -o dist
163+
- name: Publish to PyPi
164+
uses: pypa/gh-action-pypi-publish@master
165+
with:
166+
skip_existing: true
167+
user: __token__
168+
password: ${{ secrets.pypi_password }}

.pre-commit-config.yaml

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
default_language_version:
2-
python: python3
31
repos:
42
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.0.1
3+
rev: v4.1.0
64
hooks:
75
- id: check-ast
86
- id: check-builtin-literals
@@ -14,61 +12,40 @@ repos:
1412
- id: end-of-file-fixer
1513
- id: trailing-whitespace
1614
- repo: https://github.com/asottile/pyupgrade
17-
rev: v2.29.0
15+
rev: v2.30.0
1816
hooks:
1917
- id: pyupgrade
2018
- repo: https://github.com/PyCQA/isort
21-
rev: 5.9.3
19+
rev: 5.10.1
2220
hooks:
2321
- id: isort
2422
- repo: https://github.com/psf/black
25-
rev: 21.9b0
23+
rev: 21.12b0
2624
hooks:
2725
- id: black
28-
args:
29-
- --safe
30-
language_version: python3.8
26+
args: [ --safe ]
3127
- repo: https://github.com/asottile/blacken-docs
32-
rev: v1.11.0
28+
rev: v1.12.0
3329
hooks:
3430
- id: blacken-docs
35-
additional_dependencies:
36-
- black==20.8b1
37-
language_version: python3.8
31+
additional_dependencies: [ black==21.12b0 ]
3832
- repo: https://github.com/pre-commit/pygrep-hooks
3933
rev: v1.9.0
4034
hooks:
4135
- id: rst-backticks
36+
- repo: https://github.com/tox-dev/tox-ini-fmt
37+
rev: "0.5.1"
38+
hooks:
39+
- id: tox-ini-fmt
40+
args: [ "-p", "fix_lint" ]
4241
- repo: https://github.com/asottile/setup-cfg-fmt
43-
rev: v1.18.0
42+
rev: v1.20.0
4443
hooks:
4544
- id: setup-cfg-fmt
46-
args:
47-
- --min-py3-version
48-
- "3.4"
49-
- --max-py-version
50-
- "3.10"
45+
args: [ --min-py3-version, "3.5", "--max-py-version", "3.10" ]
5146
- repo: https://github.com/PyCQA/flake8
5247
rev: 4.0.1
5348
hooks:
5449
- id: flake8
5550
additional_dependencies:
56-
- flake8-bugbear == 20.11.1
57-
language_version: python3.8
58-
- repo: local
59-
hooks:
60-
- id: changelogs-rst
61-
name: changelog filenames
62-
language: fail
63-
entry: >-
64-
changelog files must be named
65-
####.(bugfix|feature|deprecation|breaking|doc|misc).rst
66-
exclude: >-
67-
^docs/changelog/(\d+\.(bugfix|feature|deprecation|breaking|doc|misc).rst|README.rst|template.jinja2)
68-
files: ^docs/changelog/
69-
- id: changelogs-user-role
70-
name: changelog files have a non-broken :user:`name` role
71-
language: pygrep
72-
entry: :user:([^`]+`?|`[^`]+[\s,])
73-
pass_filenames: true
74-
types: [file, rst]
51+
- flake8-bugbear==21.11.29

azure-pipelines.yml

Lines changed: 0 additions & 75 deletions
This file was deleted.

docs/conf.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222

2323
def generate_draft_news():
2424
home = "https://github.com"
25-
issue = "{}/issue".format(home)
25+
issue = f"{home}/issue"
2626
fragments_path = ROOT_SRC_TREE_DIR / "docs" / "changelog"
2727
for pattern, replacement in (
28-
(r"[^`]@([^,\s]+)", r"`@\1 <{}/\1>`_".format(home)),
29-
(r"[^`]#([\d]+)", r"`#pr\1 <{}/\1>`_".format(issue)),
28+
(r"[^`]@([^,\s]+)", fr"`@\1 <{home}/\1>`_"),
29+
(r"[^`]#([\d]+)", fr"`#pr\1 <{issue}/\1>`_"),
3030
):
3131
for path in fragments_path.glob("*.rst"):
3232
path.write_text(re.sub(pattern, replacement, path.read_text()))
@@ -43,20 +43,20 @@ def generate_draft_news():
4343
content = ""
4444
else:
4545
note = "*Changes in master, but not released yet are under the draft section*."
46-
content = "{}\n\n{}".format(note, changelog)
46+
content = f"{note}\n\n{changelog}"
4747
(ROOT_SRC_TREE_DIR / "docs" / "_draft.rst").write_text(content)
4848

4949

5050
generate_draft_news()
5151

52-
project = u"tox"
52+
project = "tox"
5353
_full_version = tox.__version__
5454
release = _full_version.split("+", 1)[0]
5555
version = ".".join(release.split(".")[:2])
5656

5757
author = "holger krekel and others"
5858
year = date.today().year
59-
copyright = u"2010-{}, {}".format(year, author)
59+
copyright = f"2010-{year}, {author}"
6060

6161
master_doc = "index"
6262
source_suffix = ".rst"
@@ -84,9 +84,9 @@ def generate_draft_news():
8484
html_favicon = "_static/img/toxfavi.ico"
8585
html_show_sourcelink = False
8686
html_static_path = ["_static"]
87-
htmlhelp_basename = "{}doc".format(project)
88-
latex_documents = [("index", "tox.tex", u"{} Documentation".format(project), author, "manual")]
89-
man_pages = [("index", project, u"{} Documentation".format(project), [author], 1)]
87+
htmlhelp_basename = f"{project}doc"
88+
latex_documents = [("index", "tox.tex", f"{project} Documentation", author, "manual")]
89+
man_pages = [("index", project, f"{project} Documentation", [author], 1)]
9090
epub_title = project
9191
epub_author = author
9292
epub_publisher = author
@@ -104,11 +104,11 @@ def parse_node(env, text, node):
104104
node += addnodes.literal_strong(name, name)
105105

106106
if len(args) > 2:
107-
default = "={}".format(args[2].strip())
107+
default = f"={args[2].strip()}"
108108
node += nodes.literal(text=default)
109109

110110
if len(args) > 1:
111-
content = "({})".format(args[1].strip())
111+
content = f"({args[1].strip()})"
112112
node += addnodes.compact_paragraph(text=content)
113113

114114
return name # this will be the link

0 commit comments

Comments
 (0)