-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/698 update a workflow by yaml #709
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
Draft
ArBridgeman
wants to merge
10
commits into
main
Choose a base branch
from
feature/698_update_a_workflow_by_yaml
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
23d5ec9
Adjust so that noxconfig.py can be loaded here until the migration is…
ArBridgeman 60b4a83
Add custom exception for InvalidWorkflowPatcherYamlError
ArBridgeman 33c8f57
Add custom exceptions YamlSyntaxError and TemplateRenderingError
ArBridgeman 14ed14b
Move example to conftest for re-use
ArBridgeman 92a08b9
Switch to cached value
ArBridgeman 40397ca
Make file_path part of class for improved exceptions
ArBridgeman 811ae80
Switch these to fixtures as will be resused for unit tests
ArBridgeman 946f3e8
Add extract_by_workflow and test
ArBridgeman a654651
Update docstring
ArBridgeman a03971f
Add class to patch the workflow & tests to verify but do not activate…
ArBridgeman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| from dataclasses import dataclass | ||
| from inspect import cleandoc | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| from exasol.toolbox.util.workflows.patch_workflow import WorkflowPatcher | ||
| from noxconfig import PROJECT_CONFIG | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class ExamplePatcherYaml: | ||
| remove_jobs = """ | ||
| workflows: | ||
| - name: "checks.yml" | ||
| remove_jobs: | ||
| - build-documentation-and-check-links | ||
| """ | ||
| step_customization = """ | ||
| workflows: | ||
| - name: "checks.yml" | ||
| step_customizations: | ||
| - action: {action} | ||
| job: run-unit-tests | ||
| step_id: check-out-repository | ||
| content: | ||
| - name: Check out Repository | ||
| id: check-out-repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| """ | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def example_patcher_yaml(): | ||
| return ExamplePatcherYaml | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def workflow_patcher_yaml(tmp_path: Path) -> Path: | ||
| return tmp_path / ".workflow-patcher.yml" | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def workflow_patcher(workflow_patcher_yaml) -> WorkflowPatcher: | ||
| return WorkflowPatcher( | ||
| github_template_dict=PROJECT_CONFIG.github_template_dict, | ||
| file_path=workflow_patcher_yaml, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def remove_job_yaml(example_patcher_yaml, workflow_patcher_yaml): | ||
| content = cleandoc(example_patcher_yaml.remove_jobs) | ||
| workflow_patcher_yaml.write_text(content) | ||
| return content | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def step_customization_yaml(request, example_patcher_yaml, workflow_patcher_yaml): | ||
| # request.param will hold the value passed from @pytest.mark.parametrize | ||
| action_value = request.param | ||
|
|
||
| text = example_patcher_yaml.step_customization.format(action=action_value) | ||
| content = cleandoc(text) | ||
| workflow_patcher_yaml.write_text(content) | ||
| return content |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WorkflowPatcher-> original actually has a many:1 relationship and new one has a 1:1. Other naming ideas there? Or other way to think of the class?WorkflowPatcherand to theTemplateRenderer-> multi additions, etc.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Semi-common use cases not covered:
-> we could add to the
WorkflowPatcherconfig a field with a list of workflow names to skip-> at some point for that field & workflow name, i would want to add a literal check for comparing to the active ones
-> this one is tricky as we want the users to mostly put new jobs into their own workflows. however, would we want them to be able to add to the merge-gate like so:
https://github.com/exasol/python-toolbox/blob/main/.github/workflows/merge-gate.yml#L35
?
-> when removing jobs, we don't remove them from
needsyethttps://github.com/exasol/python-toolbox/blob/main/.github/workflows/slow-checks.yml#L24
-> we could change the pattern here some like creating a workflow to get out specific PROJECT_CONFIG values & returning them in a matrix. For the standard-slow tests, we could change it to get a configurable target -- just need to figure out a way to do the names...maybe there's a trip with github's json, idk
-> maybe other / simpler ideas for that too
-> could alternately handle if they could modify a job