Skip to content

Commit 22879d6

Browse files
authored
Build list of required jobs in generate-workflow (#4326)
* Build list of required jobs in generate-workflow Dump the list of all the jobs in the same format that is required for configuration in opentelemetry-admin terraform config files so that we don't miss required jobs. * Serialize also misc jobs * Document what this script is about
1 parent 78c948b commit 22879d6

3 files changed

Lines changed: 46 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""
2+
This script builds a text file with the list of required checks based on
3+
the tox environments. Similarly to the system we are using to build the
4+
github workflows.
5+
The output is in the format than can be cut-and-pasted into the python-contrib
6+
terraform configuration in the admin repository.
7+
"""
8+
9+
from pathlib import Path
10+
11+
from generate_workflows_lib import (
12+
get_lint_job_datas,
13+
get_misc_job_datas,
14+
get_test_job_datas,
15+
get_tox_envs,
16+
)
17+
18+
tox_ini_path = Path(__file__).parent.parent.parent.joinpath("tox.ini")
19+
20+
21+
def get_gh_contexts_from_jobs(job_datas):
22+
def get_job_name(job):
23+
if isinstance(job, str):
24+
return job
25+
return job["ui_name"]
26+
27+
return [
28+
f""" {{ context = "{get_job_name(job)}" }},\n"""
29+
for job in job_datas
30+
]
31+
32+
33+
jobs = sorted(
34+
get_gh_contexts_from_jobs(get_lint_job_datas(get_tox_envs(tox_ini_path)))
35+
+ get_gh_contexts_from_jobs(
36+
get_test_job_datas(get_tox_envs(tox_ini_path), ["ubuntu-latest"])
37+
)
38+
+ get_gh_contexts_from_jobs(get_misc_job_datas(get_tox_envs(tox_ini_path)))
39+
)
40+
with open("opentelemetry-admin-jobs.txt", "w") as f:
41+
for job in jobs:
42+
f.write(job)

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,6 @@ target
6161

6262
# Benchmark result files
6363
*-benchmark.json
64+
65+
# opentelemetry-admin jobs
66+
opentelemetry-admin-jobs.txt

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,7 @@ deps =
11171117

11181118
commands =
11191119
python {toxinidir}/.github/workflows/generate_workflows.py
1120+
python {toxinidir}/.github/workflows/generate_required_checks.py
11201121

11211122
[testenv:shellcheck]
11221123

0 commit comments

Comments
 (0)