Detect unused Cucumber step definitions in CI#2349
Open
delthas wants to merge 22 commits intoimprovement/ZENKO-5203from
Open
Detect unused Cucumber step definitions in CI#2349delthas wants to merge 22 commits intoimprovement/ZENKO-5203from
delthas wants to merge 22 commits intoimprovement/ZENKO-5203from
Conversation
Issue: ZENKO-5203
…he DLQ was ~250 in the tests, stopping sorbetclt from restoring objects Issue: ZENKO-5203
…rs instead of sleep Issue: ZENKO-5203
…prove debugging Issue: ZENKO-5203
Add a check-unused-steps.sh script that runs cucumber-js in dry-run mode with usage reporting to detect unused step definitions. Wire it as an npm script and add it to the lint-and-build-ctst CI job. Issue: ZENKO-5215
Delete 4 step definitions flagged as UNUSED by the dry-run check:
- Given('an account', ...) in common/common.ts
- Given('{int} mpu objects ...') in common/common.ts
- Then('i can get the {string} location details', ...) in azureArchive.ts
- Given('a DR failing to be installed', ...) in pra.ts
Issue: ZENKO-5215
francoisferrand
approved these changes
Mar 12, 2026
Remove the check-unused-steps.sh script and inline the command directly into the npm script. Drop --parallel 1 to use the config default parallelism. Issue: ZENKO-5215
dedf6c3 to
4a27e41
Compare
maeldonn
approved these changes
Mar 13, 2026
Contributor
maeldonn
left a comment
There was a problem hiding this comment.
Could you squash or fixup these changes into the relevant commits? Keeping the history clean makes it much easier to follow the logic during future audits.
4a27e41 to
0c6fedd
Compare
0c6fedd to
879ebee
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cucumber-js --dry-run --format usageto detect unused step definitions, and fails thelint-and-build-ctstjob if any are foundHow it works
cucumber-js --dry-runloads all step definitions and cross-references them against every feature file without actually executing any steps. The--format usageoutput lists each step definition alongside its usage count, marking unreferenced ones asUNUSED. The newcheck-unused-steps.shscript greps forUNUSEDin this output and exits non-zero if any are found.Why this branch
This approach requires
cucumber-js --dry-runto load all step definition files. On the main Zenko branches, this fails becausenode-rdkafka(a native C++ addon) is imported transitively by some step files, and it requires system libraries (librdkafka) that aren't available in a plainyarn installenvironment. On this branch (improvement/ZENKO-5203),node-rdkafkahas been replaced with@platformatic/kafka(a pure JS implementation), so the dry-run loads cleanly without native dependencies.Alternative approach
An alternative would be to detect unused steps at test runtime rather than as a static CI check — for example by hooking into Cucumber's
AfterAllto inspect which step definitions were matched. However, this would only catch unused steps when the full test suite runs, not at lint time, and would be harder to enforce as a gate. The dry-run approach is simpler and catches issues earlier in the pipeline.