Fix submodule detection, the CleanupArtifacts NameError and the skippable Bandit scan - #246
Fix submodule detection, the CleanupArtifacts NameError and the skippable Bandit scan#246Paebbels wants to merge 1 commit into
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Coverage variation | ✅ +0.00% coverage variation |
| Diff coverage | ✅ ∅ diff coverage |
Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (08dd2c2) 45 41 91.11% Head commit (5808758) 45 (+0) 41 (+0) 91.11% (+0.00%) 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 (#246) 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.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #246 +/- ##
=======================================
Coverage 82.22% 82.22%
=======================================
Files 1 1
Lines 45 45
Branches 9 9
=======================================
Hits 37 37
Misses 4 4
Partials 4 4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
**`PrepareJob.yml`: submodules were never detected.** The check tested for a file named `.gitsubmodules`; Git's file is `.gitmodules`. `has_submodules` was therefore always `'false'` and `git_submodule_count`, `git_submodule_names` and `git_submodule_paths` kept their initial empty values for every repository. The block already had the correct name in a local variable one line below, which is now used for the test as well. Verified against a scratch repository with two submodules: ``` has_submodules=true count=2 names=libA:libB paths=deps/libA:deps/libB ``` and `has_submodules=false` once the file is removed. **`CleanupArtifacts.yml`: an unknown artifact ID raised `NameError`.** Both compute steps call `printf(...)` in their `case _:` fallback, but the step runs `shell: python`, where `printf` is not a function. An `artifact-json-ids` entry that is not a key of the JSON dictionary - a typo, or a key removed from `Parameters.yml` while a consumer still lists it - aborted the step with `NameError: name 'printf' is not defined` instead of reporting the name. That is precisely the case the branch exists for. Reproduced against the previous revision (exit code 1, `NameError`) and against this one: ``` Name 'typo_key' not found in JSON dictionary. Artifact to delete: pyX-UnitTestReportSummary-XML-* pyX-Packages ``` `_Checking_CleanupArtifacts.yml` now passes an `unknown_key` entry, so the branch is exercised by the verification pipeline. **`CheckCodeQuality.yml`: the security scan could be skipped silently.** The `Bandit` step was guarded by `if: inputs.artifact != ''`, although the step writes its report to a fixed path and never used that parameter. An empty artifact name skipped the scan while the job still reported success. The guard is removed; the scan now runs whenever the job runs. Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
0443fff to
5808758
Compare
New Features
Changes
@r7consumers need no adjustment.CheckCodeQuality.yml'sartifactinput is now unused. It is kept declared, because removing an input from a stable release branch breaks every consumer that passes it —CompletePipelinedoes. See the note at the bottom.Bug Fixes
PrepareJob.yml: submodules were never detected. The check tested for a file named.gitsubmodules; Git's file is.gitmodules.has_submoduleswas therefore always'false', andgit_submodule_count,git_submodule_namesandgit_submodule_pathskept their initial empty values — for every repository, since the workflow was introduced.The block already had the correct name in a local variable one line below:
The variable is now assigned first and used for the test.
Verified against a scratch repository with two submodules:
and
has_submodules=falseonce.gitmodulesis removed.Nothing consumes these four outputs today, which is why nobody hit it. It matters as soon as a pipeline wants to check out submodules conditionally.
CleanupArtifacts.yml: an unknown artifact ID raisedNameError. Both compute steps callprintf(...)in theircase _:fallback, but the step runsshell: python, whereprintfis not a function:So an
artifact-json-idsentry that is not a key of the JSON dictionary — a typo, or a key removed fromParameters.ymlwhile a consumer still lists it — aborted the step instead of reporting the name. That is precisely the case the branch exists for.Reproduced against the previous revision of the step:
and against this one:
The second run also confirms that a
#-commented entry is still skipped and that the prefix/postfix forms still resolve.CheckCodeQuality.yml: the security scan could be skipped silently. TheBanditstep was guarded byif: inputs.artifact != '', although the step writes its report to a fixed path (report/bandit/report.xml) and never used that parameter. An empty artifact name skipped the scan, while the job installed bandit, ran to the end and reported success — a green security check that scanned nothing.artifactis declaredrequired: true, but GitHub does not enforce required inputs that arrive as an empty string from an expression, which is how a consumer would realistically pass one.The guard is removed. The scan now runs whenever the job runs, i.e. whenever
bandit: 'true'.Documentation
.. attention::notes; those notes are removed in that pull-request's branch, since this one makes them obsolete. The two pull-requests are independent, but both should land — see the note below.Unit Tests
_Checking_CleanupArtifacts.ymlnow passes anunknown_keyentry, so thecase _:branch is exercised by the verification pipeline rather than only by a typo in production.The
PrepareJobsubmodule logic was executed offline against a scratch repository, in both states (.gitmodulespresent and absent) — output quoted above. The Actions repository itself has no submodules, so its own pipeline cannot cover the positive case.Both changed shell scripts pass
bash -n, and all four changed workflows parse as YAML.The
CheckCodeQualitychange is covered by this repository's own pipeline:_Checking_JobTemplates.ymlinstantiates the template, and the Bandit findings inmyPackage/myFrameworkare deliberate, so the step must run and report them.Related Issues and Pull-Requests
Note
CheckCodeQuality.yml'sartifactinput is now referenced nowhere. It is declaredrequired: true, so it cannot be dropped without breaking consumers that pass it on@r7. Two options for a later major release: remove it, or give it a purpose by uploading the bandit XML report under that name. Left as is here, because either choice is an interface decision rather than a bug fix.