Feat: Publish build artefacts and drop dead input - #10
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an opt-in mechanism to publish packaged build outputs (jars/wars/ears) from the reusable Maven and Gradle verify workflows, and removes a non-existent github_summary input previously passed to build-metadata-action.
Changes:
- Introduces
upload_build_artifactsandbuild_artifact_retention_daysinputs, plus artifact collection/upload steps, for both Maven and Gradle verify lanes. - Removes the invalid
github_summaryinput fromlfreleng-actions/build-metadata-actionusage and updates surrounding comments/docs accordingly. - Documents the build-artifact “shape” behavior (Maven
m2repovs reactortarget/, Gradlebuild/libs) and adds example caller snippets.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| examples/maven/build-test/github.yaml | Documents the new opt-in build artifact upload inputs for Maven callers. |
| examples/gradle/build-test/github.yaml | Documents the new opt-in build artifact upload inputs for Gradle callers. |
| docs/BRIEF.md | Adds design-brief documentation for build artifact publication behavior and shapes. |
| .github/workflows/maven-build-test.yaml | Adds inputs, surfaces build outputs, removes dead github_summary input, and implements Maven artifact collection/upload. |
| .github/workflows/gradle-build-test.yaml | Adds inputs, removes dead github_summary input, and implements Gradle artifact collection/upload. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e748900 to
4bbe0f0
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
.github/workflows/maven-build-test.yaml:510
- The upload step uses
always()and only checkssteps.build-artifacts.outputs.count != '0'. If the precedingCollect build artefactsstep fails before writing outputs,countwill be empty and this condition will still evaluate true, causing this step to run and fail (or fail with a confusing error), potentially obscuring the original failure. Gate the upload on the collect step succeeding while still allowing uploads on failed builds.
if: ${{ always() && inputs.upload_build_artifacts && steps.build-artifacts.outputs.count != '0' }}
.github/workflows/gradle-build-test.yaml:448
- Same issue as the Maven lane: with
always()and only acount != '0'check, a failure inCollect build artefactscan leavecountempty and still trigger this upload step, causing extra noise and potentially masking the root cause. Gate the upload on the collect step outcome.
if: ${{ always() && inputs.upload_build_artifacts && steps.build-artifacts.outputs.count != '0' }}
The build lane threw its output away. Only JUnit XML, the SBOM and the Grype results survived a run; every jar the reactor produced died with the runner. Nothing downstream of a build could exist, and a human debugging a failed run had no way to fetch the jar it produced. Add upload_build_artifacts, off by default. The packaged output is large and most verify lanes never read it back, so uploading it unconditionally would charge storage to every consumer to serve a minority. The cases that want it are real, so this is a switch rather than an omission. Two shapes can come out of a Maven build and they are not interchangeable. A deploy phase writes a repository layout to m2repo, which is what Nexus staging and nexus-publish-action consume; any other phase leaves packaged output under the reactor's target/ directories. The collect step prefers m2repo when it exists and records which shape it took in the artefact name, so a consumer knows what it has without inspecting the contents. The lane's default phases are 'clean install', which yields the reactor shape; m2repo appears only when a caller asks for deploy. Collection takes files sitting directly in target/ (or build/libs for Gradle), so compiled classes and unpacked dependencies underneath are left behind. The build job also now surfaces m2repo_exists, m2repo_path and artifact_count, which maven-build-action already computed and the workflow discarded. Separately, both lanes passed github_summary to build-metadata-action, which has no such input. GitHub warned and ignored it on every run, so the metadata summary the comment promised has never rendered. The neighbouring repository-metadata-action does take github_summary, which is the likely source of the copy. Remove it and correct the comments. Also bump the default harden-runner allow-list from v0.12.0 to v0.12.2, the current release. It adds five endpoints, of which nexus-iq.wl.linuxfoundation.org and download.sonatype.com matter to sibling lanes, and node/yarn registries to Node builds. Consumers that take the default, including ONAP cps, pick this up on the next bump. Copilot review: take the m2repo location from maven-build-action's m2repo_path output instead of re-deriving the literal path. The premise offered was that path_prefix relocates it, which it does not -- the action writes to GITHUB_WORKSPACE/m2repo unconditionally -- but consuming the output is still better, because it removes a duplicated assumption about the action's internal layout. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
4bbe0f0 to
809e557
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
.github/workflows/maven-build-test.yaml:514
- If the "Collect build artefacts" step fails before writing
countto$GITHUB_OUTPUT(e.g., invalidpath_prefix),steps.build-artifacts.outputs.countwill be empty, which still satisfies!= '0'and causes the upload step to run and fail with a confusingif-no-files-founderror. Gate the upload on the collect step succeeding as well.
if: ${{ always() && inputs.upload_build_artifacts && steps.build-artifacts.outputs.count != '0' }}
.github/workflows/gradle-build-test.yaml:448
- If the "Collect build artefacts" step fails before writing
countto$GITHUB_OUTPUT(e.g., invalidpath_prefix),steps.build-artifacts.outputs.countwill be empty, which still satisfies!= '0'and causes the upload step to run and fail with a confusingif-no-files-founderror. Gate the upload on the collect step succeeding as well.
if: ${{ always() && inputs.upload_build_artifacts && steps.build-artifacts.outputs.count != '0' }}
2071735
into
lfreleng-actions:main
Summary
The build lane threw its output away. Adds opt-in build artefact publication to both the Maven and Gradle lanes, and removes an input that has never worked.
The gap
Run
30466479894(ONAPcps, 24-module reactor) produced four artefacts:maven-junit-reportssbom-filesgrype-scan-resultsrepository-metadata-…Not one jar. Every artefact the reactor built died with the runner. That blocks anything downstream of a build — publish/stage, container builds, CSIT — and leaves a human debugging a failed run with no way to fetch the jar it produced.
upload_build_artifacts, off by defaultOff by default is a deliberate call, and the one thing here most worth pushing back on. The packaged output is large and most verify lanes never read it back, so uploading unconditionally would charge storage to every consumer in order to serve a minority. The cases that want it are real, so this is a switch rather than an omission.
build_artifact_retention_daysdefaults to 7, against the SBOM's 45: build output is reproducible from the commit, so it is a convenience rather than a record.Two shapes, and why the artefact says which
A Maven build can yield either, and they are not interchangeable:
deployphase writes a repository layout tom2repo(groupId/artifactId/version/...) — the layout Nexus staging andnexus-publish-actionconsume, viafiles_path.target/directories.The collect step prefers
m2repowhen present and records which it took in the artefact name —maven-build-artifacts-m2repoormaven-build-artifacts-reactor— so a consumer knows what it has without inspecting the contents.Worth flagging: this lane's default
mvn_phasesisclean install, so the reactor shape is what most callers will get.m2repoappears only when a caller asks fordeploy. I deliberately did not change the default phase todeploy— that is a real behaviour change for every consumer and belongs in its own discussion, not smuggled into an artefact fix.Collection takes files sitting directly in
target/(orbuild/libsfor Gradle), sotarget/classes/andtarget/dependency/are left behind.Also surfaces
m2repo_exists,m2repo_pathandartifact_countas build-job outputs.maven-build-actionalready computed these and documented them as "for downstream publish/stage actions"; the workflow simply discarded them.Dead input removed
Both lanes passed
github_summary: 'true'tobuild-metadata-action, which has no such input:GitHub warned and ignored it on every run, so the metadata summary the comment promised has never rendered. The neighbouring
repository-metadata-actioncall does takegithub_summary, which is the likely source of the copy — that one is correct and untouched. Comments corrected so they no longer describe a feature that does not exist.Validation
prek run --all-files— every hook passes, including actionlint, shellcheck, workflow schema validation and the timeout-minutes checkzizmor --persona auditor --min-severity informational .github/workflows/— no findings, all seven workflows parsed without warningsCollection logic exercised locally against fixture trees, all three paths:
shape=reactor count=3— picked updmi-stub/dmi-stub-service/target/, correctly skippedtarget/classes/andtarget/dependency/shape=m2repo count=2— layout preservedshape=none count=0— upload step skips, no spurious failureFollow-up
ONAP
cpsandcps-ncmp-dmi-plugincallers will setupload_build_artifacts: trueonce this tags.