Skip to content

Commit af31db2

Browse files
Merge pull request #942 from jiridanek/jd_no_chains_in_gha
RHOAIENG-19048: chore(gha): remove the upfront workflow generation script
2 parents b9e4357 + 67954fd commit af31db2

File tree

5 files changed

+46
-227
lines changed

5 files changed

+46
-227
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
"name": "Build Notebooks (push)"
3+
"on":
4+
"push":
5+
"workflow_dispatch":
6+
"schedule":
7+
- "cron": "0 2 * * *"
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
13+
jobs:
14+
gen:
15+
name: Generate job matrix
16+
runs-on: ubuntu-latest
17+
outputs:
18+
matrix: ${{ steps.gen.outputs.matrix }}
19+
has_jobs: ${{ steps.gen.outputs.has_jobs }}
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Determine targets to build (we want to build everything on push)
24+
run: |
25+
set -x
26+
python3 ci/cached-builds/gen_gha_matrix_jobs.py
27+
id: gen
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
shell: bash
31+
32+
build:
33+
needs: ["gen"]
34+
strategy:
35+
fail-fast: false
36+
matrix: "${{ fromJson(needs.gen.outputs.matrix) }}"
37+
uses: ./.github/workflows/build-notebooks-TEMPLATE.yaml
38+
if: ${{ fromJson(needs.gen.outputs.has_jobs) }}
39+
with:
40+
target: "${{ matrix.target }}"
41+
github: "${{ toJSON(github) }}"
42+
secrets: inherit

.github/workflows/build-notebooks.yaml

Lines changed: 0 additions & 181 deletions
This file was deleted.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ endef
107107
####################################### Build helpers #######################################
108108

109109
# https://stackoverflow.com/questions/78899903/how-to-create-a-make-target-which-is-an-implicit-dependency-for-all-other-target
110-
skip-init-for := deploy% undeploy% test% scan-image-vulnerabilities
110+
skip-init-for := all-images deploy% undeploy% test% scan-image-vulnerabilities
111111
ifneq (,$(filter-out $(skip-init-for),$(MAKECMDGOALS) $(.DEFAULT_GOAL)))
112112
$(SELF): bin/buildinputs
113113
endif

ci/cached-builds/gen_gha_matrix_jobs.py

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import gha_pr_changed_files
1414

1515
"""Trivial Makefile parser that extracts target dependencies so that we can build each Dockerfile image target in its
16-
own GitHub Actions job and handle dependencies between them.
16+
own GitHub Actions job.
1717
1818
The parsing is not able to handle general Makefiles, it only works with the Makefile in this project.
1919
Use https://pypi.org/project/py-make/ or https://github.com/JetBrains/intellij-plugins/tree/master/makefile/grammars if you look for general parser."""
@@ -57,46 +57,7 @@ def extract_image_targets(makefile_dir: str = os.getcwd()) -> list[str]:
5757
if len(all_images) < 1:
5858
raise Exception("No image dependencies found for 'all-images' Makefile target")
5959

60-
return all_images
61-
62-
def write_github_workflow_file(targets: list[str], path: pathlib.Path) -> None:
63-
jobs = {}
64-
65-
# IDs may only contain alphanumeric characters, '_', and '-'. IDs must start with a letter or '_' and must be less than 100 characters.
66-
allowed_github_chars = string.ascii_letters + string.digits + "_-"
67-
68-
for target in targets:
69-
task_name = re.sub(r"[^-_0-9A-Za-z]", "_", target)
70-
jobs[task_name] = {
71-
"needs": [],
72-
"uses": "./.github/workflows/build-notebooks-TEMPLATE.yaml",
73-
"with": {
74-
"target": target,
75-
"github": "${{ toJSON(github) }}",
76-
},
77-
"secrets": "inherit",
78-
}
79-
80-
workflow = {
81-
"name": "Build Notebooks (push)",
82-
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
83-
"permissions": {
84-
"packages": "write",
85-
},
86-
"on": {
87-
"push": {},
88-
"workflow_dispatch": {},
89-
"schedule": [{ "cron": "0 2 * * *"}], # 2am UTC everyday
90-
},
91-
"jobs": jobs,
92-
}
93-
94-
with open(path, "wt") as f:
95-
print("---", file=f)
96-
print("# This file is autogenerated by", pathlib.Path(__file__).relative_to(project_dir), file=f)
97-
# every json file is a valid yaml file
98-
json.dump(workflow, f, sort_keys=False, indent=4)
99-
print(file=f)
60+
return all_images
10061

10162

10263
def main() -> None:
@@ -112,8 +73,6 @@ def main() -> None:
11273

11374
targets = extract_image_targets()
11475

115-
write_github_workflow_file(targets, project_dir / ".github" / "workflows" / "build-notebooks.yaml")
116-
11776
if args.from_ref:
11877
logging.info(f"Skipping targets not modified in the PR")
11978
changed_files = gha_pr_changed_files.list_changed_files(args.from_ref, args.to_ref)
@@ -165,4 +124,4 @@ def test_select_changed_targets_shared_file(self):
165124
'runtime-cuda-pytorch-ubi9-python-3.11',
166125
'cuda-jupyter-tensorflow-ubi9-python-3.11',
167126
'rocm-jupyter-minimal-ubi9-python-3.11',
168-
'runtime-cuda-tensorflow-ubi9-python-3.11'}
127+
'runtime-cuda-tensorflow-ubi9-python-3.11'}

ci/generate_code.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env bash
22
set -Eeuxo pipefail
33

4-
python3 ci/cached-builds/gen_gha_matrix_jobs.py
54
bash scripts/sync-requirements-txt.sh

0 commit comments

Comments
 (0)