Repository navigation
perf(ci): correctly versioned, faster release pipeline ⚡ #79
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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,84 @@ | ||
| import argparse | ||
| import json | ||
|
|
||
| import pytest | ||
|
|
||
| from pipelines import release | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def monorepo(tmp_path, monkeypatch): | ||
| path = tmp_path / '.genvm-monorepo-root' | ||
| path.write_text( | ||
| json.dumps( | ||
| { | ||
| 'version': 'v0.6.0-rc2', | ||
| 'active-versions': ['v0.3', 'v0.2'], | ||
| 'support-only-versions': ['v0.2'], | ||
| 'artifacts_dir': 'build/test-artifacts', | ||
| }, | ||
| indent=4, | ||
| ) | ||
| + '\n' | ||
| ) | ||
| monkeypatch.setattr(release.ci_lib, 'ROOT_DIR', tmp_path) | ||
| monkeypatch.setattr(release, 'release_filter_tag', lambda: 'integration & stable') | ||
| return path | ||
|
|
||
|
|
||
| def run(command, override=None): | ||
| parser = argparse.ArgumentParser() | ||
| command.add_to(parser) | ||
| argv = [] if override is None else ['--version-override', override] | ||
| return command.handler(parser.parse_args(argv)) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize('override', [None, '', 'v0.6.0-rc2']) | ||
| def test_apply_unchanged_version_does_not_write(monorepo, override): | ||
| before = monorepo.read_bytes() | ||
| mtime = monorepo.stat().st_mtime_ns | ||
| assert run(release.ApplyReleaseVersion(), override) == 0 | ||
| assert monorepo.read_bytes() == before | ||
| assert monorepo.stat().st_mtime_ns == mtime | ||
|
|
||
|
|
||
| @pytest.mark.parametrize('override', ['v1.2.3', 'v0.6.0-rc3', 'v1.2.3+build.4']) | ||
| def test_apply_changes_only_version_and_preserves_format(monorepo, override): | ||
| before = monorepo.read_text() | ||
| assert run(release.ApplyReleaseVersion(), override) == 0 | ||
| assert monorepo.read_text() == before.replace('v0.6.0-rc2', override) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| 'override', | ||
| [ | ||
| '1.2.3', | ||
| 'v1.2', | ||
| 'release', | ||
| ' v1.2.3', | ||
| 'v1.2.3 rc', | ||
| 'v1.2.3;x', | ||
| 'v1.2.3-rc..1', | ||
| 'v1.2.3-rc.', | ||
| 'v1.2.3-x.lock', | ||
| ], | ||
| ) | ||
| def test_plan_and_apply_reject_invalid_version( | ||
| monorepo, tmp_path, monkeypatch, override | ||
| ): | ||
| before = monorepo.read_bytes() | ||
| output = tmp_path / 'github-output' | ||
| monkeypatch.setenv('GITHUB_OUTPUT', str(output)) | ||
| assert run(release.PlanReleaseMatrix(), override) == 1 | ||
| assert run(release.ApplyReleaseVersion(), override) == 1 | ||
| assert monorepo.read_bytes() == before | ||
| assert not output.exists() | ||
|
|
||
|
|
||
| @pytest.mark.parametrize('override', ['', 'v1.2.3-rc1']) | ||
| def test_plan_tags_with_override(monorepo, tmp_path, monkeypatch, override): | ||
| output = tmp_path / 'github-output' | ||
| monkeypatch.setenv('GITHUB_OUTPUT', str(output)) | ||
| assert run(release.PlanReleaseMatrix(), override) == 0 | ||
| outputs = dict(line.split('=', 1) for line in output.read_text().splitlines()) | ||
| assert outputs['tag'] == (override or 'v0.6.0-rc2') |
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
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.