From 9fec43ddf12118f6bfa66aedb17bca91618f153b Mon Sep 17 00:00:00 2001 From: Jakub Beránek Date: Fri, 19 Apr 2024 21:41:49 +0200 Subject: Move calculate-job-matrix.py to `ci/github-actions` --- src/ci/github-actions/calculate-job-matrix.py | 25 +++++++++++++++++++++++++ src/ci/github-actions/ci.yml | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100755 src/ci/github-actions/calculate-job-matrix.py (limited to 'src/ci/github-actions') diff --git a/src/ci/github-actions/calculate-job-matrix.py b/src/ci/github-actions/calculate-job-matrix.py new file mode 100755 index 00000000000..ba40f4da847 --- /dev/null +++ b/src/ci/github-actions/calculate-job-matrix.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 + +""" +This script serves for generating a matrix of jobs that should +be executed on CI. + +It reads job definitions from `src/ci/github-actions/jobs.yml` +and filters them based on the event that happened on CI. + +Currently, it only supports PR builds. +""" + +import json +from pathlib import Path + +import yaml + +JOBS_YAML_PATH = Path(__file__).absolute().parent / "jobs.yml" + + +if __name__ == "__main__": + with open(JOBS_YAML_PATH) as f: + jobs = yaml.safe_load(f) + job_output = jobs["pr"] + print(f"jobs={json.dumps(job_output)}") diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml index de71b9f874f..9d1c3284be2 100644 --- a/src/ci/github-actions/ci.yml +++ b/src/ci/github-actions/ci.yml @@ -351,7 +351,7 @@ jobs: - name: Checkout the source code uses: actions/checkout@v4 - name: Calculate the CI job matrix - run: python3 src/ci/scripts/calculate-job-matrix.py >> $GITHUB_OUTPUT + run: python3 src/ci/github-actions/calculate-job-matrix.py >> $GITHUB_OUTPUT id: jobs pr: <<: *base-ci-job -- cgit 1.4.1-3-g733a5