Skip to content

Commit

Permalink
Add Flake8 GitHub Actions workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed Nov 26, 2020
1 parent a3691e1 commit 4681b82
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 0 deletions.
18 changes: 18 additions & 0 deletions repo_helper/files/ci_cd.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"make_github_ci",
"make_github_docs_test",
"make_github_octocheese",
"make_github_flake8",
"make_github_manylinux",
"ensure_bumpversion",
"make_actions_deploy_conda",
Expand Down Expand Up @@ -284,6 +285,23 @@ def make_github_octocheese(repo_path: pathlib.Path, templates: jinja2.Environmen
return [file.relative_to(repo_path).as_posix()]


@management.register("flake8_action")
def make_github_flake8(repo_path: pathlib.Path, templates: jinja2.Environment) -> List[str]:
"""
Add configuration for the Flake8 Github Action.
:param repo_path: Path to the repository root.
:param templates:
"""

file = PathPlus(repo_path / ".github" / "workflows" / "flake8.yml")
file.parent.maybe_make(parents=True)

file.write_clean(templates.get_template(file.name).render())

return [file.relative_to(repo_path).as_posix()]


@management.register("bumpversion")
def ensure_bumpversion(repo_path: pathlib.Path, templates: jinja2.Environment) -> List[str]:
"""
Expand Down
33 changes: 33 additions & 0 deletions repo_helper/templates/flake8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file is managed by 'repo_helper'. Don't edit it directly.
---
name: Flake8

on:
push:
pull_request:
branches: ["master"]

jobs:
Run:
name: "Flake8"
runs-on: "ubuntu-18.04"

steps:
- name: Checkout 🛎️
uses: "actions/checkout@v2"

- name: Setup Python 🐍
uses: "actions/setup-python@v2"
with:
python-version: "3.8"

- name: Install dependencies 🔧
run: |
python -VV
python -m site
python -m pip install --upgrade pip setuptools wheel
python -m pip install flake8-prettycount
python -m pip install .
- name: "Run Flake8"
run: "python -m flake8_prettycount flake8_github_action --format github"
1 change: 1 addition & 0 deletions tests/test_core_/test_via_Repo_class.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- .github/workflows/assign.yml
- .github/workflows/cleanup.yml
- .github/workflows/docs_test_action.yml
- .github/workflows/flake8.yml
- .github/workflows/manylinux_build.yml
- .github/workflows/octocheese.yml
- .github/workflows/python_ci.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The following files will be committed:
.github/ISSUE_TEMPLATE/feature_request.md
.github/workflows/cleanup.yml
.github/workflows/docs_test_action.yml
.github/workflows/flake8.yml
.github/workflows/octocheese.yml
.github/workflows/python_ci.yml
.github/workflows/python_ci_linux.yml
Expand Down
7 changes: 7 additions & 0 deletions tests/test_files/test_ci_cd.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
make_actions_deploy_conda,
make_github_ci,
make_github_docs_test,
make_github_flake8,
make_github_manylinux,
make_github_octocheese
)
Expand Down Expand Up @@ -214,6 +215,12 @@ def test_make_github_octocheese(tmp_pathplus, demo_environment, file_regression:
assert not (tmp_pathplus / ".github/workflows/octocheese.yml").exists()


def test_make_github_flake8(tmp_pathplus, demo_environment, file_regression: FileRegressionFixture):
assert make_github_flake8(tmp_pathplus, demo_environment) == [".github/workflows/flake8.yml"]
assert (tmp_pathplus / ".github/workflows/flake8.yml").is_file()
check_file_output(tmp_pathplus / ".github/workflows/flake8.yml", file_regression)


@pytest.mark.parametrize("py_versions", [["3.6", "3.7", "3.8"], ["3.6", "3.7"]])
@pytest.mark.parametrize("enable_docs", [True, False])
@pytest.mark.parametrize("py_modules", [["hello_world.py"], []])
Expand Down
33 changes: 33 additions & 0 deletions tests/test_files/test_ci_cd_/test_make_github_flake8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file is managed by 'repo_helper'. Don't edit it directly.
---
name: Flake8

on:
push:
pull_request:
branches: ["master"]

jobs:
Run:
name: "Flake8"
runs-on: "ubuntu-18.04"

steps:
- name: Checkout 🛎️
uses: "actions/checkout@v2"

- name: Setup Python 🐍
uses: "actions/setup-python@v2"
with:
python-version: "3.8"

- name: Install dependencies 🔧
run: |
python -VV
python -m site
python -m pip install --upgrade pip setuptools wheel
python -m pip install flake8-prettycount
python -m pip install .
- name: "Run Flake8"
run: "python -m flake8_prettycount flake8_github_action --format github"

0 comments on commit 4681b82

Please sign in to comment.