Generate CI job matrix for PR jobs in Python
This commit is contained in:
parent
99c42d2340
commit
c22c81cbc1
28
.github/workflows/ci.yml
vendored
28
.github/workflows/ci.yml
vendored
@ -36,8 +36,21 @@ concurrency:
|
|||||||
group: "${{ github.workflow }}-${{ ((github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.sha) || github.ref }}"
|
group: "${{ github.workflow }}-${{ ((github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.sha) || github.ref }}"
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
jobs:
|
jobs:
|
||||||
|
calculate_matrix:
|
||||||
|
name: Calculate job matrix
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
jobs: "${{ steps.jobs.outputs.jobs }}"
|
||||||
|
steps:
|
||||||
|
- 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
|
||||||
|
id: jobs
|
||||||
pr:
|
pr:
|
||||||
name: "PR - ${{ matrix.name }}"
|
name: "PR - ${{ matrix.name }}"
|
||||||
|
needs:
|
||||||
|
- calculate_matrix
|
||||||
env:
|
env:
|
||||||
PR_CI_JOB: 1
|
PR_CI_JOB: 1
|
||||||
CI_JOB_NAME: "${{ matrix.name }}"
|
CI_JOB_NAME: "${{ matrix.name }}"
|
||||||
@ -51,20 +64,7 @@ jobs:
|
|||||||
continue-on-error: "${{ matrix.name == 'mingw-check-tidy' }}"
|
continue-on-error: "${{ matrix.name == 'mingw-check-tidy' }}"
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include: "${{ fromJSON(needs.calculate_matrix.outputs.jobs) }}"
|
||||||
- name: mingw-check
|
|
||||||
os: ubuntu-20.04-4core-16gb
|
|
||||||
env: {}
|
|
||||||
- name: mingw-check-tidy
|
|
||||||
os: ubuntu-20.04-4core-16gb
|
|
||||||
env: {}
|
|
||||||
- name: x86_64-gnu-llvm-17
|
|
||||||
env:
|
|
||||||
ENABLE_GCC_CODEGEN: "1"
|
|
||||||
os: ubuntu-20.04-16core-64gb
|
|
||||||
- name: x86_64-gnu-tools
|
|
||||||
os: ubuntu-20.04-16core-64gb
|
|
||||||
env: {}
|
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}"
|
shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}"
|
||||||
|
@ -340,9 +340,21 @@ concurrency:
|
|||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
calculate_matrix:
|
||||||
|
name: Calculate job matrix
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
jobs: ${{ steps.jobs.outputs.jobs }}
|
||||||
|
steps:
|
||||||
|
- 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
|
||||||
|
id: jobs
|
||||||
pr:
|
pr:
|
||||||
<<: *base-ci-job
|
<<: *base-ci-job
|
||||||
name: PR - ${{ matrix.name }}
|
name: PR - ${{ matrix.name }}
|
||||||
|
needs: [ calculate_matrix ]
|
||||||
env:
|
env:
|
||||||
<<: [*shared-ci-variables, *public-variables]
|
<<: [*shared-ci-variables, *public-variables]
|
||||||
PR_CI_JOB: 1
|
PR_CI_JOB: 1
|
||||||
@ -350,20 +362,7 @@ jobs:
|
|||||||
continue-on-error: ${{ matrix.name == 'mingw-check-tidy' }}
|
continue-on-error: ${{ matrix.name == 'mingw-check-tidy' }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include: ${{ fromJSON(needs.calculate_matrix.outputs.jobs) }}
|
||||||
- name: mingw-check
|
|
||||||
<<: *job-linux-4c
|
|
||||||
|
|
||||||
- name: mingw-check-tidy
|
|
||||||
<<: *job-linux-4c
|
|
||||||
|
|
||||||
- name: x86_64-gnu-llvm-17
|
|
||||||
env:
|
|
||||||
ENABLE_GCC_CODEGEN: "1"
|
|
||||||
<<: *job-linux-16c
|
|
||||||
|
|
||||||
- name: x86_64-gnu-tools
|
|
||||||
<<: *job-linux-16c
|
|
||||||
|
|
||||||
auto:
|
auto:
|
||||||
<<: *base-ci-job
|
<<: *base-ci-job
|
||||||
|
46
src/ci/github-actions/jobs.yml
Normal file
46
src/ci/github-actions/jobs.yml
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
x--expand-yaml-anchors--remove:
|
||||||
|
- &base-job
|
||||||
|
env: { }
|
||||||
|
|
||||||
|
- &job-linux-4c
|
||||||
|
os: ubuntu-20.04-4core-16gb
|
||||||
|
<<: *base-job
|
||||||
|
|
||||||
|
- &job-linux-8c
|
||||||
|
os: ubuntu-20.04-8core-32gb
|
||||||
|
<<: *base-job
|
||||||
|
|
||||||
|
- &job-linux-16c
|
||||||
|
os: ubuntu-20.04-16core-64gb
|
||||||
|
<<: *base-job
|
||||||
|
|
||||||
|
- &job-macos-xl
|
||||||
|
os: macos-13 # We use the standard runner for now
|
||||||
|
<<: *base-job
|
||||||
|
|
||||||
|
- &job-macos-m1
|
||||||
|
os: macos-14
|
||||||
|
<<: *base-job
|
||||||
|
|
||||||
|
- &job-windows-8c
|
||||||
|
os: windows-2019-8core-32gb
|
||||||
|
<<: *base-job
|
||||||
|
|
||||||
|
- &job-windows-16c
|
||||||
|
os: windows-2019-16core-64gb
|
||||||
|
<<: *base-job
|
||||||
|
|
||||||
|
- &job-aarch64-linux
|
||||||
|
os: [ self-hosted, ARM64, linux ]
|
||||||
|
|
||||||
|
pr:
|
||||||
|
- name: mingw-check
|
||||||
|
<<: *job-linux-4c
|
||||||
|
- name: mingw-check-tidy
|
||||||
|
<<: *job-linux-4c
|
||||||
|
- name: x86_64-gnu-llvm-17
|
||||||
|
env:
|
||||||
|
ENABLE_GCC_CODEGEN: "1"
|
||||||
|
<<: *job-linux-16c
|
||||||
|
- name: x86_64-gnu-tools
|
||||||
|
<<: *job-linux-16c
|
25
src/ci/scripts/calculate-job-matrix.py
Executable file
25
src/ci/scripts/calculate-job-matrix.py
Executable file
@ -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.parent / "github-actions" / "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)}")
|
Loading…
x
Reference in New Issue
Block a user