Skip to content

Commit

Permalink
Add lint generator
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Jul 15, 2024
1 parent ba3a84f commit 10dc123
Show file tree
Hide file tree
Showing 4 changed files with 1,161 additions and 116 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/generate_workflows.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from pathlib import Path

from generate_workflows_lib import generate_test_workflow
from generate_workflows_lib import (
generate_test_workflow,
generate_lint_workflow
)

tox_ini_path = Path(__file__).parent.parent.parent.joinpath("tox.ini")
workflows_directory_path = Path(__file__).parent

generate_test_workflow(
Path(__file__).parent.parent.parent.joinpath("tox.ini"),
Path(__file__).parent,
"ubuntu-latest"
)
generate_test_workflow(tox_ini_path, workflows_directory_path, "ubuntu-latest")
generate_lint_workflow(tox_ini_path, workflows_directory_path)
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,30 @@ def get_test_jobs_data(tox_envs: list, operating_systems: list) -> list:


def get_lint_jobs_data(tox_envs: list) -> list:
pass

lint_jobs_data = []

tox_lint_env_regex = re_compile(r"lint-(?P<name>[-\w]+)")

for tox_env in tox_envs:

tox_lint_env_match = tox_lint_env_regex.match(tox_env)

if tox_lint_env_match is None:
continue

tox_env = tox_lint_env_match.string

lint_jobs_data.append(
{
"name": f"{tox_env}",
"ui_name": f"{tox_lint_env_match.groupdict()['name']}",
"tox_env": tox_env,
}

)

return lint_jobs_data


def generate_test_workflow(
Expand Down Expand Up @@ -131,7 +154,6 @@ def generate_test_workflow(
def generate_lint_workflow(
tox_ini_path: Path,
workflow_directory_path: Path,
*operating_systems
) -> None:

with (
Expand All @@ -142,9 +164,7 @@ def generate_lint_workflow(
Environment(
loader=FileSystemLoader(Path(__file__).parent)
).get_template("lint.yml.j2").render(
lint_jobs_data=get_lint_jobs_data(
tox_ini_path, operating_systems
)
jobs=get_lint_jobs_data(get_tox_envs(tox_ini_path))
)
)
lint_yml_file.write("\n")
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Do not edit this file.
# This file is generated automatically by executing tox -e generate_workflows

name: Lint

on:
push:
branches-ignore:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: 141a6a2e473ef7f0ec4915dfb71e3c0fa595283e

jobs:
{%- for job in jobs %}

{{ job.name }}:
name: {{ job.ui_name }}
runs-on: ubuntu-latest
steps:
- name: Checkout Contrib Repo @ SHA - ${% raw %}{{ github.sha }}{% endraw %}
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e {{ job.tox_env }} -- -ra
{%- endfor %}

lint-instrumentation-sklearn:
name: instrumentation-sklearn
runs-on: ubuntu-latest
steps:
- name: Checkout Contrib Repo @ SHA - ${% raw %}{{ github.sha }}{% endraw %}
uses: actions/checkout@v4

- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: "3.8"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e lint-instrumentation-sklearn -- -ra
Loading

0 comments on commit 10dc123

Please sign in to comment.