about summary refs log tree commit diff
path: root/src/ci/github-actions
diff options
context:
space:
mode:
authorJakub Beránek <berykubik@gmail.com>2024-04-23 15:06:18 +0200
committerJakub Beránek <berykubik@gmail.com>2024-04-24 11:11:16 +0200
commite25735908fc4ee84011252bedfedf51e1de22b95 (patch)
tree5ca2cd8ec24d356c125f0e9a293406edc1a05128 /src/ci/github-actions
parent2a7fe14acd4b4da3623797166b81aa35d6704508 (diff)
downloadrust-e25735908fc4ee84011252bedfedf51e1de22b95.tar.gz
rust-e25735908fc4ee84011252bedfedf51e1de22b95.zip
Skip jobs based on the active channel in Python
Diffstat (limited to 'src/ci/github-actions')
-rwxr-xr-xsrc/ci/github-actions/calculate-job-matrix.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/ci/github-actions/calculate-job-matrix.py b/src/ci/github-actions/calculate-job-matrix.py
index a54081f83f1..84c4ee40668 100755
--- a/src/ci/github-actions/calculate-job-matrix.py
+++ b/src/ci/github-actions/calculate-job-matrix.py
@@ -17,6 +17,7 @@ from typing import List, Dict, Any, Optional
 
 import yaml
 
+CI_DIR = Path(__file__).absolute().parent.parent
 JOBS_YAML_PATH = Path(__file__).absolute().parent / "jobs.yml"
 
 Job = Dict[str, Any]
@@ -90,6 +91,13 @@ def calculate_jobs(job_type: JobType, job_data: Dict[str, Any]) -> List[Job]:
     return []
 
 
+def skip_jobs(jobs: List[Dict[str, Any]], channel: str) -> List[Job]:
+    """
+    Skip CI jobs that are not supposed to be executed on the given `channel`.
+    """
+    return [j for j in jobs if j.get("CI_ONLY_WHEN_CHANNEL", channel) == channel]
+
+
 def get_github_ctx() -> GitHubCtx:
     return GitHubCtx(
         event_name=os.environ["GITHUB_EVENT_NAME"],
@@ -109,9 +117,13 @@ if __name__ == "__main__":
     job_type = find_job_type(github_ctx)
     logging.info(f"Job type: {job_type}")
 
+    with open(CI_DIR / "channel") as f:
+        channel = f.read().strip()
+
     jobs = []
     if job_type is not None:
         jobs = calculate_jobs(job_type, data)
+    jobs = skip_jobs(jobs, channel)
 
     logging.info(f"Output:\n{yaml.dump(jobs, indent=4)}")
     print(f"jobs={json.dumps(jobs)}")