-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Enhancement Type
- CI/CD enhancement
Problem Statement
container-build.yml triggers on **/Containerfile and **/Dockerfile path changes, but only builds
contexts explicitly listed in strategy.matrix.include. A contributor can add a Containerfile to
a component or pipeline directory and CI will never build it -- syntax errors, missing files, and broken
RUN steps go undetected.
This applies to all component/pipeline locations, including subcategories:
components/<category>/<component_name>/Containerfilecomponents/<category>/<subcategory>/<component_name>/Containerfilepipelines/<category>/<pipeline_name>/Containerfilepipelines/<category>/<subcategory>/<pipeline_name>/Containerfile
Proposed Solution
A Python script under .github/scripts/check_container_build_matrix/ that:
- Discovers every
Containerfile/Dockerfilerecursively undercomponents/,pipelines/,
anddocs/examples/. - Parses
.github/workflows/container-build.ymland extractscontextvalues from
jobs.build.strategy.matrix.include. - Fails if any discovered file's parent directory has no matching matrix
context.
A new workflow (e.g., .github/workflows/container-build-matrix-check.yml) triggers on PRs touching
**/Containerfile, **/Dockerfile, or .github/workflows/container-build.yml and runs the script.
This follows the existing pattern of check_imports and validate_base_images.
Validation sketch
SEARCH_ROOTS = ["components", "pipelines", "docs/examples"]
def check():
container_files = []
for root in SEARCH_ROOTS:
container_files += Path(root).rglob("Containerfile")
container_files += Path(root).rglob("Dockerfile")
matrix_contexts = parse_matrix_contexts(".github/workflows/container-build.yml")
unmatched = [cf for cf in container_files if str(cf.parent) not in matrix_contexts]
if unmatched:
for f in unmatched:
print(f"ERROR: {f} has no matching matrix entry in container-build.yml")
sys.exit(1)Additional considerations
- Support an exclusion mechanism (YAML config or CLI flag) for files not intended to be built by CI.
- Error messages should tell the contributor exactly what to add to
container-build.yml, referencing
the Adding a Custom Base Image docs. - Unit tests following
.github/scripts/patterns.
Use Cases
- Contributor adds a
Containerfilewithout a matrix entry -- CI fails with a clear message. - Contributor adds a
Containerfileinside a subcategory without a matrix entry -- CI fails. - Contributor removes a matrix entry but leaves the
Containerfile-- CI fails. - Contributor adds both the
Containerfileand the matrix entry -- CI passes.
Alternatives Considered
- Code review only: fragile, already proven insufficient.
- Dynamic matrix generation: higher complexity; can be pursued separately.
- Inline shell step: less testable, inconsistent with repo patterns.
Willing to Contribute
- Yes, I can implement this enhancement
- Yes, I can help with testing
- Yes, I can help with documentation
Interested in this enhancement? Give it a 👍.