Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add skip field to test steps #2307

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

karthikmanam
Copy link

Implements #2297 - Add ability to skip steps based on conditions

This PR adds a new 'skip' field to TestStepSpec that allows steps to be conditionally skipped based on a boolean value or a template expression.

  • Added Skip field to TestStepSpec

  • Added unit tests for the Skip field

  • Added documentation for the skip feature

Explanation

This PR adds a new skip field to test steps, allowing steps to be conditionally skipped based on a boolean value or a template expression. Users can now define conditional test flows where specific steps are run or skipped based on environment variables or other conditions. This enhances test flexibility and enables creating more adaptable test suites that can run in different environments without requiring script-based workarounds.

Related issue

Fixes #2297

Proposed Changes

This PR implements the ability to skip steps in a test based on conditions as requested in issue #2297.
The implementation includes:
**API Changes: **

  • Added a Skip field to the TestStepSpec struct in pkg/apis/v1alpha1/step.go
  • The field is defined as a pointer to a string, allowing for both simple boolean values and templated expressions

Tests:

  • Added unit tests in pkg/apis/v1alpha1/step_test.go to verify the Skip field works correctly
  • Tests cover both static boolean values and template expressions

Documentation:

  • Created a new documentation page at website/docs/step/skip.md
  • Added comprehensive documentation for the feature, including:
  • Basic usage examples
    • Template-based dynamic skipping
    • Conditional skipping examples

Usage notes and caveats
Updated the mkdocs navigation to include the new documentation

Note: The runner implementation is not complete due to import issues in the runner.go file. Help from maintainers would be appreciated to complete this part.

Checklist

  • I have read the contributing guidelines.
  • I have read the PR documentation guide and followed the process including adding proof manifests to this PR.
  • This is a bug fix and I have added unit tests that prove my fix is effective.

Further Comments

This PR provides the foundation for the skip feature by implementing the API changes, tests, and documentation. The runner implementation has issues with conflicting imports in the runner.go file, which would benefit from assistance from maintainers who are more familiar with the codebase.
Currently, the API part and documentation are fully functional and tested. The implementation follows the same pattern as other conditional features in the codebase, supporting both static values and templated expressions.

Implements kyverno#2297 - Add ability to skip steps based on conditions

This PR adds a new 'skip' field to TestStepSpec that allows steps to be conditionally skipped based on a boolean value or a template expression.

- Added Skip field to TestStepSpec

- Added unit tests for the Skip field

- Added documentation for the skip feature

Signed-off-by: Karthik babu Manam <[email protected]>
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.

[Feature] enable skipping step based on condition
1 participant