Address review comments

This commit is contained in:
Jakub Beránek 2024-05-03 10:06:13 +02:00
parent e2e280610d
commit bf8bcc4c2d
No known key found for this signature in database
GPG key ID: 909CD0D26483516B

View file

@ -74,13 +74,13 @@ class GitHubCtx:
def get_custom_jobs(ctx: GitHubCtx) -> List[str]: def get_custom_jobs(ctx: GitHubCtx) -> List[str]:
""" """
Tries to parse names of specific CI jobs that should be executed in the form of Tries to parse names of specific CI jobs that should be executed in the form of
ci-job: <job-name> try-job: <job-name>
from the commit message of the passed GitHub context. from the commit message of the passed GitHub context.
""" """
if ctx.commit_message is None: if ctx.commit_message is None:
return [] return []
regex = re.compile(r"^ci-job: (.*)", re.MULTILINE) regex = re.compile(r"^try-job: (.*)", re.MULTILINE)
jobs = [] jobs = []
for match in regex.finditer(ctx.commit_message): for match in regex.finditer(ctx.commit_message):
jobs.append(match.group(1)) jobs.append(match.group(1))
@ -125,11 +125,15 @@ def calculate_jobs(run_type: WorkflowRunType, job_data: Dict[str, Any]) -> List[
) )
jobs = [] jobs = []
unknown_jobs = []
for custom_job in custom_jobs: for custom_job in custom_jobs:
job = [j for j in job_data["auto"] if j["image"] == custom_job] job = [j for j in job_data["auto"] if j["image"] == custom_job]
if not job: if not job:
raise Exception(f"Custom job `{custom_job}` not found in auto jobs") unknown_jobs.append(custom_job)
continue
jobs.append(job[0]) jobs.append(job[0])
if unknown_jobs:
raise Exception(f"Custom job(s) `{unknown_jobs}` not found in auto jobs")
return add_base_env(name_jobs(jobs, "try"), job_data["envs"]["try"]) return add_base_env(name_jobs(jobs, "try"), job_data["envs"]["try"])
elif run_type is AutoRunType: elif run_type is AutoRunType: