Skip to content

Detect unused Cucumber step definitions in CI#2349

Open
delthas wants to merge 23 commits intodevelopment/2.14from
improvement/ZENKO-5215/detect-unused-cucumber-steps
Open

Detect unused Cucumber step definitions in CI#2349
delthas wants to merge 23 commits intodevelopment/2.14from
improvement/ZENKO-5215/detect-unused-cucumber-steps

Conversation

@delthas
Copy link
Copy Markdown
Contributor

@delthas delthas commented Mar 12, 2026

Summary

  • Add a CI check that runs cucumber-js --dry-run --format usage to detect unused step definitions, and fails the lint-and-build-ctst job if any are found
  • Remove 4 unused step definitions flagged by this check

How it works

cucumber-js --dry-run loads all step definitions and cross-references them against every feature file without actually executing any steps. The --format usage output lists each step definition alongside its usage count, marking unreferenced ones as UNUSED. The new check-unused-steps.sh script greps for UNUSED in this output and exits non-zero if any are found.

Why this branch

This approach requires cucumber-js --dry-run to load all step definition files. On the main Zenko branches, this fails because node-rdkafka (a native C++ addon) is imported transitively by some step files, and it requires system libraries (librdkafka) that aren't available in a plain yarn install environment. On this branch (improvement/ZENKO-5203), node-rdkafka has 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 AfterAll to 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.

SylvainSenechal and others added 22 commits March 11, 2026 15:50
…he DLQ was ~250 in the tests, stopping sorbetclt from restoring objects

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
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
@SylvainSenechal SylvainSenechal force-pushed the improvement/ZENKO-5203 branch from dedf6c3 to 4a27e41 Compare March 13, 2026 10:15
Copy link
Copy Markdown
Contributor

@maeldonn maeldonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@SylvainSenechal SylvainSenechal force-pushed the improvement/ZENKO-5203 branch 2 times, most recently from 0c6fedd to 879ebee Compare March 13, 2026 15:46
@francoisferrand
Copy link
Copy Markdown
Contributor

must be rebased, this is not up-to-date with improvement/ZENKO-5203

@delthas
Copy link
Copy Markdown
Contributor Author

delthas commented Mar 18, 2026

must be rebased, this is not up-to-date with improvement/ZENKO-5203

Yes, waiting for that PR to be merged/stabilized

@SylvainSenechal SylvainSenechal force-pushed the improvement/ZENKO-5203 branch 6 times, most recently from 45cc2d4 to 4925585 Compare March 23, 2026 09:16
@SylvainSenechal SylvainSenechal force-pushed the improvement/ZENKO-5203 branch from 4925585 to b9c29e8 Compare April 1, 2026 15:55
Base automatically changed from improvement/ZENKO-5203 to development/2.14 April 2, 2026 00:25
@bert-e
Copy link
Copy Markdown
Contributor

bert-e commented Apr 2, 2026

Hello delthas,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Available options
name description privileged authored
/after_pull_request Wait for the given pull request id to be merged before continuing with the current one.
/bypass_author_approval Bypass the pull request author's approval
/bypass_build_status Bypass the build and test status
/bypass_commit_size Bypass the check on the size of the changeset TBA
/bypass_incompatible_branch Bypass the check on the source branch prefix
/bypass_jira_check Bypass the Jira issue check
/bypass_peer_approval Bypass the pull request peers' approval
/bypass_leader_approval Bypass the pull request leaders' approval
/approve Instruct Bert-E that the author has approved the pull request. ✍️
/create_pull_requests Allow the creation of integration pull requests.
/create_integration_branches Allow the creation of integration branches.
/no_octopus Prevent Wall-E from doing any octopus merge and use multiple consecutive merge instead
/unanimity Change review acceptance criteria from one reviewer at least to all reviewers
/wait Instruct Bert-E not to run until further notice.
Available commands
name description privileged
/help Print Bert-E's manual in the pull request.
/status Print Bert-E's current status in the pull request TBA
/clear Remove all comments from Bert-E from the history TBA
/retry Re-start a fresh build TBA
/build Re-start a fresh build TBA
/force_reset Delete integration branches & pull requests, and restart merge process from the beginning.
/reset Try to remove integration branches unless there are commits on them which do not appear on the source branch.

Status report is not available.

@bert-e
Copy link
Copy Markdown
Contributor

bert-e commented Apr 2, 2026

Branches have diverged

This pull request's source branch improvement/ZENKO-5215/detect-unused-cucumber-steps has diverged from
development/2.14 by more than 50 commits.

To avoid any integration risks, please re-synchronize them using one of the
following solutions:

  • Merge origin/development/2.14 into improvement/ZENKO-5215/detect-unused-cucumber-steps
  • Rebase improvement/ZENKO-5215/detect-unused-cucumber-steps onto origin/development/2.14

Note: If you choose to rebase, you may have to ask me to rebuild
integration branches using the reset command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants