|
2 | 2 | # Copyright (c) Jupyter Development Team. |
3 | 3 | # Distributed under the terms of the Modified BSD License. |
4 | 4 | import json |
5 | | -import os |
6 | 5 | from pathlib import Path |
7 | 6 | from typing import Any |
8 | 7 |
|
9 | 8 | THIS_DIR = Path(__file__).parent.resolve() |
10 | | -REPOSITORY_OWNER = os.environ["REPOSITORY_OWNER"] |
11 | 9 |
|
12 | 10 |
|
13 | | -def generate_matrix() -> dict[str, Any]: |
14 | | - dockerfiles = sorted(file.name for file in THIS_DIR.glob("*.dockerfile")) |
| 11 | +def generate_matrix() -> Any: |
| 12 | + dockerfiles = sorted(THIS_DIR.glob("*.dockerfile")) |
15 | 13 | runs_on = ["ubuntu-24.04", "ubuntu-22.04-arm"] |
16 | | - return { |
17 | | - "dockerfile": dockerfiles, |
18 | | - "runs-on": runs_on, |
19 | | - "exclude": [ |
20 | | - {"dockerfile": "oracledb.dockerfile", "runs-on": "ubuntu-22.04-arm"} |
21 | | - ], |
22 | | - } |
| 14 | + |
| 15 | + configurations = [] |
| 16 | + for dockerfile in dockerfiles: |
| 17 | + dockerfile_name = dockerfile.name |
| 18 | + for run in runs_on: |
| 19 | + if dockerfile_name == "oracledb.dockerfile" and run == "ubuntu-22.04-arm": |
| 20 | + continue |
| 21 | + dockerfile_lines = dockerfile.read_text().splitlines() |
| 22 | + base_image = [ |
| 23 | + line for line in dockerfile_lines if line.startswith("ARG BASE_IMAGE=") |
| 24 | + ][0][15:] |
| 25 | + base_image_short = base_image[base_image.rfind("/") + 1 :] |
| 26 | + # Handling a case of `docker.io/jupyter/base-notebook:notebook-6.5.4` image |
| 27 | + if ":" in base_image_short: |
| 28 | + base_image_short = "" |
| 29 | + configurations.append( |
| 30 | + { |
| 31 | + "dockerfile": dockerfile_name, |
| 32 | + "runs-on": run, |
| 33 | + "platform": "x86_64" if run == "ubuntu-24.04" else "aarch64", |
| 34 | + "parent-image": base_image_short, |
| 35 | + } |
| 36 | + ) |
| 37 | + return {"include": configurations} |
23 | 38 |
|
24 | 39 |
|
25 | 40 | if __name__ == "__main__": |
|
0 commit comments