Skip to content

Commit

Permalink
Add misc workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Jul 17, 2024
1 parent 48cb84a commit 7098f31
Show file tree
Hide file tree
Showing 5 changed files with 226 additions and 15 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/generate_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

from generate_workflows_lib import (
generate_test_workflow,
generate_lint_workflow
generate_lint_workflow,
generate_misc_workflow
)

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

generate_test_workflow(tox_ini_path, workflows_directory_path, "ubuntu-latest")
generate_lint_workflow(tox_ini_path, workflows_directory_path)
generate_misc_workflow(tox_ini_path, workflows_directory_path)
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
from collections import defaultdict


_tox_test_env_regex = re_compile(
r"(?P<python_version>py\w+)-test-"
r"(?P<name>[-\w]+\w)-?(?P<test_requirements>\d+)?"
)
_tox_lint_env_regex = re_compile(r"lint-(?P<name>[-\w]+)")
_tox_contrib_env_regex = re_compile(
r"py38-test-(?P<name>[-\w]+\w)-?(?P<contrib_requirements>\d+)?"
)


def get_tox_envs(tox_ini_path: Path) -> list:

tox_ini = ToxIni(tox_ini_path)
Expand Down Expand Up @@ -55,15 +65,10 @@ def get_test_job_datas(tox_envs: list, operating_systems: list) -> list:

test_job_datas = []

tox_test_env_regex = re_compile(
r"(?P<python_version>py\w+)-test-"
r"(?P<name>[-\w]+\w)-?(?P<test_requirements>\d+)?"
)

for operating_system in operating_systems:
for tox_env in tox_envs:

tox_test_env_match = tox_test_env_regex.match(tox_env)
tox_test_env_match = _tox_test_env_regex.match(tox_env)

if tox_test_env_match is None:
continue
Expand Down Expand Up @@ -106,11 +111,9 @@ def get_lint_job_datas(tox_envs: list) -> list:

lint_job_datas = []

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)
tox_lint_env_match = _tox_lint_env_regex.match(tox_env)

if tox_lint_env_match is None:
continue
Expand All @@ -133,13 +136,9 @@ def get_contrib_job_datas(tox_envs: list) -> list:

contrib_job_datas = []

tox_contrib_env_regex = re_compile(
r"py38-test-(?P<name>[-\w]+\w)-?(?P<contrib_requirements>\d+)?"
)

for tox_env in tox_envs:

tox_contrib_env_match = tox_contrib_env_regex.match(tox_env)
tox_contrib_env_match = _tox_contrib_env_regex.match(tox_env)

if tox_contrib_env_match is None:
continue
Expand Down Expand Up @@ -170,6 +169,23 @@ def get_contrib_job_datas(tox_envs: list) -> list:
return contrib_job_datas


def get_misc_job_datas(tox_envs: list) -> list:

misc_job_datas = []

for tox_env in tox_envs:
if (
_tox_test_env_regex.match(tox_env) is not None or
_tox_lint_env_regex.match(tox_env) is not None or
_tox_contrib_env_regex.match(tox_env) is not None
):
continue

misc_job_datas.append(tox_env)

return misc_job_datas


def _generate_workflow(
job_datas: list, name: str, workflow_directory_path: Path
):
Expand Down Expand Up @@ -234,3 +250,15 @@ def generate_contrib_workflow(
"contrib",
workflow_directory_path
)


def generate_misc_workflow(
tox_ini_path: Path,
workflow_directory_path: Path,
) -> None:

_generate_workflow(
get_misc_job_datas(get_tox_envs(tox_ini_path)),
"misc",
workflow_directory_path
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Do not edit this file.
# This file is generated automatically by executing tox -e generate_workflows

name: Misc {{ file_number }}

on:
push:
branches-ignore:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: main
PIP_EXISTS_ACTION: w

jobs:
{%- for job_data in job_datas %}

{{ job_data }}:
name: {{ job_data }}
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${% raw %}{{ github.sha }}{% endraw %}
uses: actions/checkout@v4
{%- if job_data.os != "shellcheck" %}

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

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e {{ job_data }} -- -ra
{%- if job_data == "generate_workflows" %}

- name: Check workflows are up to date
run: git diff --exit-code || (echo 'Generated workflows are out of date, run "tox -e generate_workflows" and commit the changes in this PR.' && exit 1)
{%- endif %}
{%- if job_data == "generate" %}

- name: Check workflows are up to date
run: git diff --exit-code || (echo 'Generated code is out of date, run "tox -e generate" and commit the changes in this PR.' && exit 1)
{%- endif %}
{%- endfor %}
126 changes: 126 additions & 0 deletions .github/workflows/misc_0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Do not edit this file.
# This file is generated automatically by executing tox -e generate_workflows

name: Misc 0

on:
push:
branches-ignore:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: main
PIP_EXISTS_ACTION: w

jobs:

benchmark-sdk-extension-aws:
name: benchmark-sdk-extension-aws
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
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 benchmark-sdk-extension-aws -- -ra

benchmark-propagator-aws-xray:
name: benchmark-propagator-aws-xray
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
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 benchmark-propagator-aws-xray -- -ra

spellcheck:
name: spellcheck
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
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 spellcheck -- -ra

docker-tests:
name: docker-tests
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
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 docker-tests -- -ra

docs:
name: docs
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
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 docs -- -ra

generate:
name: generate
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
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 generate -- -ra

- name: Check workflows are up to date
run: git diff --exit-code || (echo 'Generated code is out of date, run "tox -e generate" and commit the changes in this PR.' && exit 1)
8 changes: 8 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1300,3 +1300,11 @@ commands_pre =

commands =
python {toxinidir}/.github/workflows/generate_workflows.py

[testenv:shellcheck]

commands_pre =
sudo apt update && sudo apt install --assume-yes shellcheck

commands =
find . -name \*.sh | xargs shellcheck --severity=warning

0 comments on commit 7098f31

Please sign in to comment.