diff --git a/.github/workflows/build-notebooks-TEMPLATE.yaml b/.github/workflows/build-notebooks-TEMPLATE.yaml index e7b804d07..13ff9ae13 100644 --- a/.github/workflows/build-notebooks-TEMPLATE.yaml +++ b/.github/workflows/build-notebooks-TEMPLATE.yaml @@ -78,6 +78,8 @@ jobs: - name: "pull_request: make ${{ inputs.target }}" run: | # start a black hole container registry as make target always does a push + mkdir -p $HOME/.config/containers/registries.conf.d/ + cp ci/insecure_localhost_registry.conf $HOME/.config/containers/registries.conf.d/insecure_localhost_registry.conf go run ci/dev_null_container_registry.go & # build and push the image make ${{ inputs.target }} diff --git a/.github/workflows/build-notebooks-pr.yaml b/.github/workflows/build-notebooks-pr.yaml index e1380370a..12eb52780 100644 --- a/.github/workflows/build-notebooks-pr.yaml +++ b/.github/workflows/build-notebooks-pr.yaml @@ -1,5 +1,5 @@ --- -"name": "Build Notebooks", +"name": "Build Notebooks" "permissions": "packages": "read" "on": @@ -13,16 +13,17 @@ jobs: matrix: ${{ steps.gen.outputs.matrix }} steps: - uses: actions/checkout@v4 - - run: python3 gen_gha_matrix_jobs.py + - run: python3 ci/gen_gha_matrix_jobs.py id: gen # base images build: - needs: [ "gen" ] + needs: ["gen"] strategy: fail-fast: false matrix: "${{ fromJson(needs.gen.outputs.matrix) }}" uses: ./.github/workflows/build-notebooks-TEMPLATE.yaml with: target: "${{ matrix.target }}" + github: "${{ toJSON(github) }}" secrets: inherit diff --git a/ci/gen_gha_matrix_jobs.py b/ci/gen_gha_matrix_jobs.py index 8d766bb18..088535796 100644 --- a/ci/gen_gha_matrix_jobs.py +++ b/ci/gen_gha_matrix_jobs.py @@ -1,3 +1,4 @@ +import itertools import json import os import pathlib @@ -110,18 +111,22 @@ def write_github_workflow_file(tree: dict[str, list[str]], path: pathlib.Path) - json.dump(workflow, f, sort_keys=False, indent=4) print(file=f) + +def flatten(list_of_lists): + return list(itertools.chain.from_iterable(list_of_lists)) + def compute_leafs_in_dependency_tree(tree: dict[str, list[str]]) -> list[str]: key_set = set(tree.keys()) - value_set = set(*tree.values()) + value_set = set(flatten(tree.values())) return [key for key in key_set if key not in value_set] -def print_github_actions_pr_matrix(tree: dict[str, list[str]], leafs: list[str]) -> str: +def print_github_actions_pr_matrix(tree: dict[str, list[str]], leafs: list[str]) -> list[str]: """Outputs GitHub matrix definition Json """ targets = [] for leaf in leafs: # in level 0, we only want base images, not other utility tasks - if not tree[leaf] and leaf.startswith("base-"): + if not tree[leaf] and not leaf.startswith("base-"): continue # we won't build rhel-based images because they need subscription @@ -131,7 +136,7 @@ def print_github_actions_pr_matrix(tree: dict[str, list[str]], leafs: list[str]) targets.append(leaf) matrix = {"target": targets} - return f"matrix={json.dumps(matrix, separators=(",", ":"))}" + return [f"matrix={json.dumps(matrix, separators=(',', ':'))}"] def main() -> None: @@ -143,10 +148,9 @@ def main() -> None: write_github_workflow_file(tree, project_dir / ".github" / "workflows" / "build-notebooks.yaml") leafs = compute_leafs_in_dependency_tree(tree) - output = print_github_actions_pr_matrix(leafs) - - write_github_workflow_file(tree) + output = print_github_actions_pr_matrix(tree, leafs) + print("leafs", leafs) print(*output, sep="\n") with open(os.environ["GITHUB_OUTPUT"], "at") as f: for line in output: diff --git a/ci/insecure-localhost-registry.conf b/ci/insecure_localhost_registry.conf similarity index 100% rename from ci/insecure-localhost-registry.conf rename to ci/insecure_localhost_registry.conf