Skip to content

Commit dcbd233

Browse files
committed
Do away with tox-gh-actions to work around issue on Linux.
1 parent dc214fc commit dcbd233

File tree

36 files changed

+327
-161
lines changed

36 files changed

+327
-161
lines changed

repo_helper/configuration/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,9 @@ def custom_parsing(
330330
py_versions = parsed_config_vars["python_versions"]
331331
tox_py_versions = get_tox_python_versions(py_versions)
332332
parsed_config_vars["tox_py_versions"] = tox_py_versions
333-
tox_travis_versions = get_tox_travis_python_versions(py_versions, tox_py_versions)
334-
tox_travis_versions[parsed_config_vars["python_deploy_version"]] += ", mypy"
335-
parsed_config_vars["tox_travis_versions"] = tox_travis_versions
336-
parsed_config_vars["gh_actions_versions"] = tox_travis_versions
333+
gh_actions_versions = get_gh_actions_python_versions(py_versions, tox_py_versions)
334+
parsed_config_vars["tox_travis_versions"] = gh_actions_versions
335+
parsed_config_vars["gh_actions_versions"] = gh_actions_versions
337336

338337
if (repo_path / parsed_config_vars["import_name"].replace('.', '/') / "py.typed").is_file():
339338
parsed_config_vars["classifiers"].append("Typing :: Typed")

repo_helper/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
from repo_helper.files.linting import code_only_warning, lint_warn_list
4343
from repo_helper.files.testing import make_isort
4444
from repo_helper.templates import init_repo_template_dir, template_dir
45-
from repo_helper.utils import discover_entry_points
45+
from repo_helper.utils import brace, discover_entry_points
4646

4747
__all__ = [
4848
"RepoHelper",
@@ -92,6 +92,7 @@ def __init__(
9292
undefined=jinja2.StrictUndefined,
9393
)
9494
self.templates.globals["managed_message"] = managed_message
95+
self.templates.globals["brace"] = brace
9596

9697
self.load_settings()
9798

repo_helper/files/ci_cd.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"make_github_docs_test",
4343
"make_github_octocheese",
4444
"make_github_flake8",
45+
"make_github_mypy",
4546
"make_github_manylinux",
4647
"ensure_bumpversion",
4748
"make_actions_deploy_conda",
@@ -104,7 +105,8 @@ def make_github_ci(repo_path: pathlib.Path, templates: jinja2.Environment) -> Li
104105
"python -VV",
105106
"python -m site",
106107
"python -m pip install --upgrade pip setuptools wheel",
107-
"python -m pip install --upgrade tox tox-gh-actions virtualenv",
108+
# "python -m pip install --upgrade tox tox-gh-actions virtualenv",
109+
"python -m pip install --upgrade tox virtualenv",
108110
]
109111

110112
if "Windows" in templates.globals["platforms"]:
@@ -306,6 +308,23 @@ def make_github_flake8(repo_path: pathlib.Path, templates: jinja2.Environment) -
306308
return [file.relative_to(repo_path).as_posix()]
307309

308310

311+
@management.register("mypy_action")
312+
def make_github_mypy(repo_path: pathlib.Path, templates: jinja2.Environment) -> List[str]:
313+
"""
314+
Add configuration for the mypy Github Action.
315+
316+
:param repo_path: Path to the repository root.
317+
:param templates:
318+
"""
319+
320+
file = PathPlus(repo_path / ".github" / "workflows" / "mypy.yml")
321+
file.parent.maybe_make(parents=True)
322+
323+
file.write_clean(templates.get_template(file.name).render())
324+
325+
return [file.relative_to(repo_path).as_posix()]
326+
327+
309328
@management.register("bumpversion")
310329
def ensure_bumpversion(repo_path: pathlib.Path, templates: jinja2.Environment) -> List[str]:
311330
"""

repo_helper/templates/github_ci.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@ on:
99

1010
jobs:
1111
tests:
12-
name: "Python ${{ "{{" }} matrix.python-version {{ "}}" }}"
12+
name: "Python ${{ brace('matrix.config.python-version')}}"
1313
runs-on: "{{ ci_platform }}"
1414
env:
1515
USING_COVERAGE: '{{ ",".join(no_dev_versions(python_versions)) }}'
1616

1717
strategy:
1818
fail-fast: False
1919
matrix:
20-
python-version: ["{{ '","'.join(no_dev_versions(python_versions)) }}"]
20+
config:{% for version in no_dev_versions(python_versions) %}
21+
- {python-version: "{{ version }}", testenvs: "{{ gh_actions_versions[version].replace(' ', '') }}"}{% endfor %}
2122

2223
steps:
2324
- name: Checkout 🛎️
@@ -26,20 +27,20 @@ jobs:
2627
- name: Setup Python 🐍
2728
uses: "actions/setup-python@v2"
2829
with:
29-
python-version: "${{ "{{" }} matrix.python-version {{ "}}" }}"
30+
python-version: "${{ brace('matrix.config.python-version')}}"
3031

3132
- name: Install dependencies 🔧
3233
run: |
3334
{% for line in dependency_lines %}{{ line }}
3435
{% endfor %}
35-
- name: "Run Tests for Python ${{ "{{" }} matrix.python-version {{ "}}" }}"
36-
run: "python -m tox"
36+
- name: "Run Tests for Python ${{ brace('matrix.config.python-version')}}"
37+
run: "python -m tox -e ${{ brace('matrix.config.testenvs') }}"
3738
{% if ci_name == "Linux Tests" %}
3839
{% if enable_tests and not stubs_package %}
3940
- name: "Upload Coverage"
4041
uses: actions/upload-artifact@v2
4142
with:
42-
name: "coverage-${{ "{{" }} matrix.python-version {{ "}}" }}"
43+
name: "coverage-${{ brace('matrix.config.python-version')}}"
4344
path: .coverage
4445

4546

@@ -153,3 +154,5 @@ jobs:
153154
ANACONDA_TOKEN: ${{ "{{" }} secrets.ANACONDA_TOKEN {{ "}}" }}{% endif %}
154155

155156
{% endif %}
157+
158+
{# TODO: perhaps merge mypy into this workflow, so that releases depend on it? #}

repo_helper/templates/mypy.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This file is managed by 'repo_helper'. Don't edit it directly.
2+
---
3+
name: mypy
4+
5+
on:
6+
push:
7+
pull_request:
8+
branches: ["master"]
9+
10+
jobs:
11+
Run:
12+
name: "mypy"
13+
runs-on: ${{ "{{" }} matrix.os {{ "}}" }}
14+
15+
strategy:
16+
matrix:
17+
os: [ubuntu-latest, windows-latest, macos-latest]
18+
19+
steps:
20+
- name: Checkout 🛎️
21+
uses: "actions/checkout@v2"
22+
23+
- name: Setup Python 🐍
24+
uses: "actions/setup-python@v2"
25+
with:
26+
python-version: "3.8"
27+
28+
- name: Install dependencies 🔧
29+
run: |
30+
python -VV
31+
python -m site
32+
python -m pip install --upgrade pip setuptools wheel
33+
python -m pip install tox
34+
35+
- name: "Run mypy"
36+
run: "python -m tox -e mypy"

repo_helper/testing/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
from repo_helper.build import Builder, build_sdist, build_wheel
6060
from repo_helper.files.linting import lint_warn_list
6161
from repo_helper.templates import template_dir
62+
from repo_helper.utils import brace
6263

6364
__all__ = [
6465
"demo_environment",
@@ -172,6 +173,11 @@ def test(demo_environment):
172173
managed_message="This file is managed by 'repo_helper'. Don't edit it directly.",
173174
short_desc="a short description",
174175
on_pypi=True,
176+
brace=brace,
177+
gh_actions_versions={
178+
"3.6": "py36, mypy",
179+
"3.7": "py37, build",
180+
},
175181
)
176182
)
177183

repo_helper/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,7 @@ def commit_changes(
449449
)
450450

451451
return commit_sha.decode("UTF-8")
452+
453+
454+
def brace(string: str) -> str:
455+
return f"{{{{ {string} }}}}"

tests/test_configuration_/test_parse_yaml.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ extras_require:
5151
- lxml
5252
gh_actions_versions:
5353
'3.6': py36, build
54-
'3.7': py37, build, mypy
54+
'3.7': py37, build
5555
'3.8': py38, build
5656
3.9-dev: py39-dev, build
5757
html_context: {}
@@ -112,7 +112,7 @@ tox_requirements: []
112112
tox_testenv_extras: all
113113
tox_travis_versions:
114114
'3.6': py36, build
115-
'3.7': py37, build, mypy
115+
'3.7': py37, build
116116
'3.8': py38, build
117117
3.9-dev: py39-dev, build
118118
tox_unmanaged: []

tests/test_core_/test_via_Repo_class.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- .github/workflows/docs_test_action.yml
1313
- .github/workflows/flake8.yml
1414
- .github/workflows/manylinux_build.yml
15+
- .github/workflows/mypy.yml
1516
- .github/workflows/octocheese.yml
1617
- .github/workflows/python_ci.yml
1718
- .github/workflows/python_ci_linux.yml

tests/test_core_/test_via_run_repo_helper_backward_stdout.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ The following files will be committed:
66
.github\workflows\cleanup.yml
77
.github\workflows\docs_test_action.yml
88
.github\workflows\flake8.yml
9+
.github\workflows\mypy.yml
910
.github\workflows\octocheese.yml
1011
.github\workflows\python_ci.yml
1112
.github\workflows\python_ci_linux.yml

0 commit comments

Comments
 (0)