Repository navigation
feat(ci): reject needs.<job>.outputs.<name> references the producer never declares - #6594
Conversation
|
Tick the box to add this pull request to the merge queue (same as
|
|
Reviewed the new A couple of things worth a look: 1. Missing try:
import yaml
except ImportError: # pragma: no cover - the workflow installs it explicitly
sys.exit("check-...: PyYAML is required (pip install pyyaml)")This script does a bare 2. Dead no-op sed 's/ runs-on: ubuntu-latest\n/&/' "$work/needs-undeclared/ci.yml" \
| awk '...'
Nothing else stood out - no correctness issues in the regex (job-id/output-name character classes match GitHub's actual constraints), no perf/security concerns (local YAML parsing only, no dynamic eval), and the |
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Documentation | 2 minor |
🟢 Metrics 45 complexity
Metric Results Complexity 45
🟢 Coverage ∅ diff coverage · -6.55% coverage variation
Metric Results Coverage variation ✅ -6.55% coverage variation Diff coverage ✅ ∅ diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (cd29d8a) 164679 131822 80.05% Head commit (8f4eda7) 197066 (+32387) 144835 (+13013) 73.50% (-6.55%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#6594) 0 0 ∅ (not applicable) Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
Both fixed in PyYAML guard. Verified the convention first: Proved the guard actually fires rather than assuming it, by running the script under a Worth noting my first attempt at that probe used the legacy No-op sed. Correct, and doubly so: sed's pattern space carries no trailing newline, so a I kept deriving the accepting fixture from the rejecting one rather than writing a second file, and said so in a comment: it is what makes the pair evidence rather than two independent assertions, since the added |
Review of
|
e34bbc7 to
6904884
Compare
|
Reviewed the diff ( One correctness gap I'd like the author to weigh in on before merge: The script doesn't verify the referenced job is actually in the consuming job's
This is exactly the failure category the sibling script ( Concretely, nothing today would catch: jobs:
build:
outputs:
tag: ${{ steps.x.outputs.tag }}
...
e2e:
# no `needs: build`
steps:
- run: docker pull ${{ needs.build.outputs.tag }} # resolves to "" - not flagged
It happens that every current usage in this repo's workflows does list the producer in Minor, non-blocking nits:
Everything else - the |
|
All three addressed in The needs gap: real, fixed, and it must be DIRECT needs, not the closure. The gap is exactly as described - the script asked "does the job exist" and "does it declare the output", never "does the consumer depend on it". Fixed. But the suggested fix, reusing
So a closure-based check would have accepted this, which is precisely the reference the script exists to reject: build: { outputs: { image-tag: ... } }
test: { needs: build }
report: { needs: test, env: { IMAGE: "\${{ needs.build.outputs.image-tag }}" } } # resolves to ""That case is now a test ("rejects a transitively-reached producer, because the needs context is direct-only"), and the reasoning is in I also duplicated the four-line Proved it fires against the real workflow, not only fixtures. Removing Restored, and green again. Nit 1, the ${{ }} gate: taken. Nit 2, duplicate lines: taken. One line per distinct Harness at 78 checks, up from 75. The check still exits 0 against current |
Review of #6594Solid addition, well-scoped and consistent with the sibling Code quality
Potential bugs / edge cases (minor, non-blocking)
Performance Security Test coverage One small nit: the PR description says Five cases added to Nice, well-justified change overall, the reasoning captured in the header comment and the needs-context-is-direct-not-transitive note are genuinely useful for whoever touches this next. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6594 +/- ##
==========================================
- Coverage 71.35% 71.33% -0.03%
==========================================
Files 1868 1868
Lines 164679 164679
Branches 34806 34806
==========================================
- Hits 117511 117478 -33
- Misses 32900 32932 +32
- Partials 14268 14269 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Follow-up to #6593, suggested in its review. Adds
check-workflow-needs-outputs.py, which asserts that everyneeds.<job>.outputs.<name>expression names an output the referenced job actually declares.Stacked on #6593 and must merge after it. This branch is based on
fix/4894-declare-image-tag-output, because the check fails againstmainas it stands - which is the point.Why
GitHub Actions does not validate these references. An output no job declares is accepted as valid YAML and silently evaluates to the empty string at runtime, so the mistake produces a workflow that looks correct, parses correctly, and quietly passes nothing where a value was meant to go.
That is the bug #6593 fixes:
build-and-packagehad nooutputs:block while seven jobs passedneeds.build-and-package.outputs.image-tagasARCADEDB_DOCKER_IMAGE. It survived because every consumer was defensive in a way that hid it -e2e-goguards!= "",js-bolt-conformancefalls back with||, and twoe2e-jssuites hardcode:latestand never read the variable. Since the saved artifact carries only the:latesttag, those fallbacks all landed on the right image, so the suites were correct by luck. It took a newly added consumer strict enough to pass""through to Docker to surface it, asinvalid reference format.This is the same family as
check-workflow-artifact-deps.py: valid-looking YAML that is silently wrong at runtime, where the failure mode is indistinguishable from working. It gets a sibling script, runs in the samesetupjob, and needs no new wiring.That the check is real, not decorative
Run against
mainwithout #6593's fix, it reproduces the defect independently - all seven consumers, each with its exact location:With #6593's fix present it exits 0.
Five cases added to
test-ci-scripts.sh, pinning both directions the way the existing suites do:outputs:block exists but lacks it - the easier mistake to miss, because a reader skims past the block75 checks pass in the harness, up from 70.
Deliberate boundaries
A job delegating to a reusable workflow (
jobs.<id>.uses:) declares its outputs in the called workflow, which this script does not follow. References into such a job are skipped rather than reported: this check gates every other job, so a false violation here is expensive. The distinction is explicit in the code -Nonemeans "cannot resolve from here", an empty set means "declares nothing", and only the latter is a defect.A
needsreference to a job that does not exist at all is reported, since that is never valid.