Skip to content

Commit

Permalink
Add contrib template
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Jul 16, 2024
1 parent fb5303a commit b2168fe
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,47 @@ def get_lint_jobs_data(tox_envs: list) -> list:
return lint_jobs_data


def get_contrib_jobs_data(tox_envs: list) -> list:

contrib_jobs_data = []

tox_contrib_env_regex = re_compile(
r"py38-contrib-(?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)

if tox_contrib_env_match is None:
continue

groups = tox_contrib_env_match.groupdict()

tox_env = tox_contrib_env_match.string

contrib_requirements = groups["contrib_requirements"]

if contrib_requirements is None:
contrib_requirements = " "

else:
contrib_requirements = f"-{contrib_requirements} "

contrib_jobs_data.append(
{
"ui_name": (
f"{groups['name']}"
f"{contrib_requirements}"
),
"tox_env": tox_env,
}

)

return contrib_jobs_data


def generate_test_workflow(
tox_ini_path: Path,
workflow_directory_path: Path,
Expand Down Expand Up @@ -178,4 +219,18 @@ def generate_lint_workflow(
def generate_contrib_workflow(
workflow_directory_path: Path,
) -> None:
return get_tox_envs(Path(__file__).parent.joinpath("tox.ini"))

with (
open(workflow_directory_path.joinpath("contrib.yml"), "w") as
contrib_yml_file
):
contrib_yml_file.write(
Environment(
loader=FileSystemLoader(Path(__file__).parent)
).get_template("contrib.yml.j2").render(
jobs=get_contrib_jobs_data(
get_tox_envs(Path(__file__).parent.joinpath("tox.ini"))
)
)
)
contrib_yml_file.write("\n")
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Do not edit this file.
# This file is generated automatically by executing tox -e generate_workflows

name: Contrib

on:
push:
branches-ignore:
- 'release/*'
pull_request:
env:
CONTRIB_REPO_SHA: 141a6a2e473ef7f0ec4915dfb71e3c0fa595283e
CORE_REPO_SHA: ${% raw %}{{ github.sha }}{% endraw %}
PIP_EXISTS_ACTION: w

jobs:
{%- for job in jobs %}

{{ job.tox_env }}:
name: {{ job.ui_name }}
runs-on: ubuntu-latest
steps:
- name: Checkout Contrib Repo @ SHA - ${{% raw %}{ env.CONTRIB_REPO_SHA }}{% endraw %}
uses: actions/checkout@v4
with:
repository: open-telemetry/opentelemetry-python-contrib
ref: ${{ env.CONTRIB_REPO_SHA }}}}

- name: Checkout Core Repo @ SHA - ${% raw %}{{ github.sha }}{% endraw %}
uses: actions/checkout@v4
with:
repository: open-telemetry/opentelemetry-python
path: opentelemetry-python-core

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

- name: Install tox
run: pip install tox

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

0 comments on commit b2168fe

Please sign in to comment.