-
Notifications
You must be signed in to change notification settings - Fork 641
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
215 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Do not edit this file. | ||
# This file is generated automatically by executing generate_tests.py. | ||
|
||
name: Contrib Tests | ||
|
||
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: {{ job.os }} | ||
steps: | ||
- name: Checkout Core Repo @ SHA - ${% raw %}{{ github.sha }}{% endraw %} | ||
uses: actions/checkout@v4 | ||
|
||
- name: Checkout Contrib Repo @ SHA - ${{ env.CONTRIB_REPO_SHA }} | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: open-telemetry/opentelemetry-python-contrib | ||
ref: ${{ env.CONTRIB_REPO_SHA }} | ||
|
||
- name: Set up Python {{ job.python_version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "{{ job.python_version }}" | ||
|
||
- name: Install tox | ||
run: pip install tox | ||
|
||
- name: Run tests | ||
run: tox -e {{ job.tox_env }} -- -ra | ||
{%- endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
from configparser import ConfigParser | ||
from os.path import join | ||
from pathlib import Path | ||
from re import compile as re_compile | ||
from jinja2 import Environment, FileSystemLoader | ||
from git import Repo | ||
|
||
|
||
current_directory_path = Path(__file__).parent | ||
|
||
contrib_repo = Repo.clone_from( | ||
"https://github.com/open-telemetry/opentelemetry-python-contrib", | ||
"opentelmetry-python-contrib" | ||
) | ||
|
||
tox_ini_paths = [] | ||
|
||
test_env_regex = re_compile( | ||
r"py(?P<pypy>py)?3(\{(?P<cpython_versions>[\w,]+)\})?-test-" | ||
r"(?P<name>[-\w]+\w)-?(\{(?P<test_versions>[\d,]+)\})?" | ||
) | ||
|
||
short_regex = re_compile(r"-test-") | ||
tox_ini_path = join(str(Path(__file__).parents[2]), "tox.ini") | ||
config_parser = ConfigParser() | ||
config_parser.read(tox_ini_path) | ||
|
||
long_regex_counter = 0 | ||
short_regex_counter = 0 | ||
|
||
envs = {} | ||
|
||
for env in config_parser["tox"]["envlist"].split(): | ||
env = env.strip() | ||
|
||
if env.startswith(";"): | ||
continue | ||
|
||
test_env_regex_match = test_env_regex.match(env) | ||
short_regex_match = short_regex.search(env) | ||
|
||
if test_env_regex_match is not None: | ||
long_regex_counter += 1 | ||
|
||
env_dict = test_env_regex_match.groupdict() | ||
env_dict_name = env_dict["name"] | ||
|
||
if env_dict_name not in envs.keys(): | ||
envs[env_dict_name] = [] | ||
|
||
python_test_versions = {"python_versions": [], "test_versions": []} | ||
|
||
if env_dict["pypy"] is not None: | ||
python_test_versions["python_versions"].append("py3") | ||
|
||
if env_dict["cpython_versions"] is not None: | ||
( | ||
python_test_versions["python_versions"]. | ||
extend( | ||
[ | ||
f"3{cpython_version}" | ||
for cpython_version | ||
in env_dict["cpython_versions"].split(",") | ||
] | ||
) | ||
) | ||
|
||
if env_dict["test_versions"] is not None: | ||
( | ||
python_test_versions["test_versions"]. | ||
extend(env_dict["test_versions"].split(",")) | ||
) | ||
|
||
envs[env_dict_name].append(python_test_versions) | ||
|
||
if short_regex_match is not None: | ||
short_regex_counter += 1 | ||
|
||
assert short_regex_counter == long_regex_counter | ||
|
||
sorted_envs = [] | ||
|
||
for key, value in envs.items(): | ||
sorted_envs.append([key, value]) | ||
|
||
sorted_envs = sorted(sorted_envs) | ||
|
||
jobs = [] | ||
|
||
|
||
def get_os_alias(os): | ||
return os.replace("-latest", "") | ||
|
||
|
||
def get_python_version_alias(python_version): | ||
if python_version == "py3": | ||
return "pypy-3.8" | ||
|
||
return f"3.{python_version.replace('3', '')}" | ||
|
||
|
||
for os in ["ubuntu-latest"]: | ||
|
||
for env_name, python_test_versions in sorted_envs: | ||
|
||
for python_test_version in python_test_versions: | ||
|
||
for python_version in python_test_version["python_versions"]: | ||
|
||
tox_env = f"py{python_version}-test-{env_name}" | ||
|
||
if python_test_version["test_versions"]: | ||
for test_version in python_test_version["test_versions"]: | ||
|
||
jobs.append( | ||
{ | ||
"tox_env": f"{tox_env}-{test_version}", | ||
"python_version": ( | ||
f"{get_python_version_alias(python_version)}" | ||
), | ||
"os": os, | ||
"ui_name": ( | ||
f"{env_name}-{test_version} " | ||
f"{get_python_version_alias(python_version)} " | ||
f"{get_os_alias(os)}" | ||
), | ||
"name": ( | ||
f"{env_name}_" | ||
f"{test_version}_" | ||
f"{python_version}_" | ||
f"{os}" | ||
) | ||
} | ||
) | ||
|
||
else: | ||
jobs.append( | ||
{ | ||
"tox_env": f"{tox_env}", | ||
"python_version": ( | ||
f"{get_python_version_alias(python_version)}" | ||
), | ||
"os": os, | ||
"ui_name": ( | ||
f"{env_name} " | ||
f"{get_python_version_alias(python_version)} " | ||
f"{get_os_alias(os)}" | ||
), | ||
"name": ( | ||
f"{env_name}_" | ||
f"{python_version}_" | ||
f"{os}" | ||
) | ||
} | ||
) | ||
|
||
current_directory_path = Path(__file__).parent | ||
|
||
with open(current_directory_path.joinpath("tests.yml"), "w") as test_yml_file: | ||
test_yml_file.write( | ||
Environment( | ||
loader=FileSystemLoader(current_directory_path) | ||
).get_template("tests.yml.j2").render(**locals()) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters