diff --git a/.github/workflows/generate_required_checks.py b/.github/workflows/generate_required_checks.py new file mode 100644 index 000000000..8e9185f76 --- /dev/null +++ b/.github/workflows/generate_required_checks.py @@ -0,0 +1,42 @@ +""" +This script builds a text file with the list of required checks based on +the tox environments. Similarly to the system we are using to build the +github workflows. +The output is in the format than can be cut-and-pasted into the python-contrib +terraform configuration in the admin repository. +""" + +from pathlib import Path + +from generate_workflows_lib import ( + get_lint_job_datas, + get_misc_job_datas, + get_test_job_datas, + get_tox_envs, +) + +tox_ini_path = Path(__file__).parent.parent.parent.joinpath("tox.ini") + + +def get_gh_contexts_from_jobs(job_datas): + def get_job_name(job): + if isinstance(job, str): + return job + return job["ui_name"] + + return [ + f""" {{ context = "{get_job_name(job)}" }},\n""" + for job in job_datas + ] + + +jobs = sorted( + get_gh_contexts_from_jobs(get_lint_job_datas(get_tox_envs(tox_ini_path))) + + get_gh_contexts_from_jobs( + get_test_job_datas(get_tox_envs(tox_ini_path), ["ubuntu-latest"]) + ) + + get_gh_contexts_from_jobs(get_misc_job_datas(get_tox_envs(tox_ini_path))) +) +with open("opentelemetry-admin-jobs.txt", "w") as f: + for job in jobs: + f.write(job) diff --git a/.gitignore b/.gitignore index 1c32b4446..09141b12e 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,6 @@ target # Benchmark result files *-benchmark.json + +# opentelemetry-admin jobs +opentelemetry-admin-jobs.txt diff --git a/tox.ini b/tox.ini index 8c5ff3aca..fdfd33afd 100644 --- a/tox.ini +++ b/tox.ini @@ -1117,6 +1117,7 @@ deps = commands = python {toxinidir}/.github/workflows/generate_workflows.py + python {toxinidir}/.github/workflows/generate_required_checks.py [testenv:shellcheck]