implement matrix-testing with a reusable behave workflow#403
Merged
komish merged 1 commit intoopenshift-helm-charts:mainfrom Dec 10, 2024
Merged
implement matrix-testing with a reusable behave workflow#403komish merged 1 commit intoopenshift-helm-charts:mainfrom
komish merged 1 commit intoopenshift-helm-charts:mainfrom
Conversation
3ebe3e5 to
4239176
Compare
This was referenced Nov 25, 2024
4239176 to
b8b4a56
Compare
This was referenced Dec 5, 2024
Merged
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.
Fixes #327
Summary - this PR:
Long form notes for maintainers:
Reusable workflow vs. composite actions: I ended up using a reusable workflow instead of a composite action because the former gives access to the user's base environment. I believe I also read that you cannot run a matrix in a composite action, and instead need to invoke the matrix at the call point. This would have added some overhead to every call point that just seemed inefficient. The reusable workflow completely encapsulates the behave tests, so the caller just needs to specify what tags and the state of the repository (if not default) to pull.
Splitting single-job workflows into multiple jobs: Arguably the trickiest part of this effort, I had to split workflows into, at the very least, two jobs (from one) because a matrix happens at the job level. In effect, the task that would run in a matrix would inevitably need to be in its own job, and therefore would have to receive both inputs from any previous jobs, and emit outputs for subsequent jobs. For this reason, there are several changes that partition out workflows that would be one or two jobs into many jobs.
Checkout-related inputs to behave.yml: In certain cases, the behave.yml would need to pull the changes submitted by the contributor in order to either (a) use new scripts, or (b) test updated workflows. Most of the workflows that call behave.yml are pull_request_target-triggered workflows, and so the actions/checkout task does not pull the PR (for security reasons) but instead pulls the HEAD of the main branch. We gate pull requests for critical things like this using the check-contributor action in-repo, and release-related scripts and entrypoints check it as well. Either way, in order to run the new code, we have to be able to pull the new code in. The inputs in behave.yml have had descriptions added so that the caller understands their responsibility in checking the author of the content before running.
Using a list of feature files as the matrices: IIRC I couldn't tell behave to run only HC-001 features without writing a tag for each new feature file. I also couldn't find a a clean way to generate a list of tests that were both in the full tag AND the HC-001 feature definition. Either way, both of those options would have required us to modify our tag definitions in workflow every time we want to either extend a feature file or add new features. To that end, it felt better to auto-generate the list of files and just run the full tag against the individual feature file. Worth noting - when you specify a feature file with a tag, and that feature file has no tests with that tag, you'll just get an auto-green test case in GitHub Actions. It's not perfect, but it's the simplest way I've been able to split the work into a matrix. Open to suggestions if there is an obvious other approach that doesn't have similar (or its own array of alternate) tradeoffs.
Where can I see it running?
Here's an example release: https://github.com/practice-room/development/actions/runs/12019147275/job/33508212448
Here's an example of the PR to the production repo containing new workflows and scripts. The test set here has been reduced to speed up the development feedback cycle. That's why we only see two tests: practice-room/charts#9
Remaining concerns: