-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: release identification in prepare_single_image_build_matrix.py (#…
…308) * fix(src/image/prepare_single_image_build_matrix.py): release identification * refactor: remove extra print * ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/12259827303 * trigger_tessts * trigger_tessts * trigger_tessts * ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/12260216075 * fix: permit optional track release field * ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/12273962224 * feat: add tests for checking the number of release * ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/12279591872 --------- Co-authored-by: clay-lake <clay-lake@localhost>
- Loading branch information
Showing
10 changed files
with
314 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,37 @@ | ||
version: 1 | ||
|
||
upload: | ||
- source: "canonical/rocks-toolbox" | ||
commit: 17916dd5de270e61a6a3fd3f4661a6413a50fd6f | ||
directory: mock_rock/1.0 | ||
release: | ||
1.0-22.04: | ||
end-of-life: "2020-05-01T00:00:00Z" | ||
risks: | ||
- candidate | ||
- edge | ||
- beta | ||
- source: "canonical/rocks-toolbox" | ||
commit: 17916dd5de270e61a6a3fd3f4661a6413a50fd6f | ||
directory: mock_rock/1.1 | ||
release: | ||
1.1-22.04: | ||
end-of-life: "2000-05-01T00:00:00Z" | ||
risks: | ||
- candidate | ||
- edge | ||
- beta | ||
1-22.04: | ||
end-of-life: "2000-05-01T00:00:00Z" | ||
risks: | ||
- candidate | ||
- edge | ||
- beta | ||
- source: "canonical/rocks-toolbox" | ||
commit: 17916dd5de270e61a6a3fd3f4661a6413a50fd6f | ||
directory: mock_rock/1.2 | ||
release: | ||
1.2-22.04: | ||
end-of-life: "2000-05-01T00:00:00Z" | ||
risks: | ||
- beta |
This file contains 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,45 @@ | ||
version: 1 | ||
|
||
release: | ||
latest: | ||
end-of-life: "2030-05-01T00:00:00Z" | ||
candidate: 1.2-22.04_beta | ||
test: | ||
end-of-life: "2030-05-01T00:00:00Z" | ||
beta: 1.1-22.04_beta | ||
|
||
upload: | ||
- source: "canonical/rocks-toolbox" | ||
commit: 17916dd5de270e61a6a3fd3f4661a6413a50fd6f | ||
directory: mock_rock/1.0 | ||
release: | ||
1.0-22.04: | ||
end-of-life: "2020-05-01T00:00:00Z" | ||
risks: | ||
- candidate | ||
- edge | ||
- beta | ||
- source: "canonical/rocks-toolbox" | ||
commit: 17916dd5de270e61a6a3fd3f4661a6413a50fd6f | ||
directory: mock_rock/1.1 | ||
release: | ||
1.1-22.04: | ||
end-of-life: "2000-05-01T00:00:00Z" | ||
risks: | ||
- candidate | ||
- edge | ||
- beta | ||
1-22.04: | ||
end-of-life: "2000-05-01T00:00:00Z" | ||
risks: | ||
- candidate | ||
- edge | ||
- beta | ||
- source: "canonical/rocks-toolbox" | ||
commit: 17916dd5de270e61a6a3fd3f4661a6413a50fd6f | ||
directory: mock_rock/1.2 | ||
release: | ||
1.2-22.04: | ||
end-of-life: "2000-05-01T00:00:00Z" | ||
risks: | ||
- beta |
This file contains 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,14 @@ | ||
version: 1 | ||
|
||
upload: | ||
- source: "canonical/rocks-toolbox" | ||
commit: 17916dd5de270e61a6a3fd3f4661a6413a50fd6f | ||
directory: mock_rock/1.0 | ||
|
||
- source: "canonical/rocks-toolbox" | ||
commit: 17916dd5de270e61a6a3fd3f4661a6413a50fd6f | ||
directory: mock_rock/1.1 | ||
|
||
- source: "canonical/rocks-toolbox" | ||
commit: 17916dd5de270e61a6a3fd3f4661a6413a50fd6f | ||
directory: mock_rock/1.2 |
This file contains 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,19 @@ | ||
version: 1 | ||
|
||
upload: | ||
- source: "canonical/rocks-toolbox" | ||
commit: 17916dd5de270e61a6a3fd3f4661a6413a50fd6f | ||
directory: mock_rock/1.0 | ||
|
||
- source: "canonical/rocks-toolbox" | ||
commit: 17916dd5de270e61a6a3fd3f4661a6413a50fd6f | ||
directory: mock_rock/1.1 | ||
|
||
- source: "canonical/rocks-toolbox" | ||
commit: 17916dd5de270e61a6a3fd3f4661a6413a50fd6f | ||
directory: mock_rock/1.2 | ||
release: | ||
1.2-22.04: | ||
end-of-life: "2030-05-01T00:00:00Z" | ||
risks: | ||
- beta |
This file contains 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,45 @@ | ||
version: 1 | ||
|
||
release: | ||
latest: | ||
end-of-life: "2030-05-01T00:00:00Z" | ||
candidate: 1.2-22.04_beta | ||
test: | ||
end-of-life: "2030-05-01T00:00:00Z" | ||
beta: 1.1-22.04_beta | ||
|
||
upload: | ||
- source: "canonical/rocks-toolbox" | ||
commit: 17916dd5de270e61a6a3fd3f4661a6413a50fd6f | ||
directory: mock_rock/1.0 | ||
release: | ||
1.0-22.04: | ||
end-of-life: "2024-05-01T00:00:00Z" | ||
risks: | ||
- candidate | ||
- edge | ||
- beta | ||
- source: "canonical/rocks-toolbox" | ||
commit: 17916dd5de270e61a6a3fd3f4661a6413a50fd6f | ||
directory: mock_rock/1.1 | ||
release: | ||
1.1-22.04: | ||
end-of-life: "2030-05-01T00:00:00Z" | ||
risks: | ||
- candidate | ||
- edge | ||
- beta | ||
1-22.04: | ||
end-of-life: "2030-05-01T00:00:00Z" | ||
risks: | ||
- candidate | ||
- edge | ||
- beta | ||
- source: "canonical/rocks-toolbox" | ||
commit: 17916dd5de270e61a6a3fd3f4661a6413a50fd6f | ||
directory: mock_rock/1.2 | ||
release: | ||
1.2-22.04: | ||
end-of-life: "2030-05-01T00:00:00Z" | ||
risks: | ||
- beta |
This file contains 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,37 @@ | ||
version: 1 | ||
|
||
upload: | ||
- source: "canonical/rocks-toolbox" | ||
commit: 17916dd5de270e61a6a3fd3f4661a6413a50fd6f | ||
directory: mock_rock/1.0 | ||
release: | ||
1.0-22.04: | ||
end-of-life: "2024-05-01T00:00:00Z" | ||
risks: | ||
- candidate | ||
- edge | ||
- beta | ||
- source: "canonical/rocks-toolbox" | ||
commit: 17916dd5de270e61a6a3fd3f4661a6413a50fd6f | ||
directory: mock_rock/1.1 | ||
release: | ||
1.1-22.04: | ||
end-of-life: "2030-05-01T00:00:00Z" | ||
risks: | ||
- candidate | ||
- edge | ||
- beta | ||
1-22.04: | ||
end-of-life: "2030-05-01T00:00:00Z" | ||
risks: | ||
- candidate | ||
- edge | ||
- beta | ||
- source: "canonical/rocks-toolbox" | ||
commit: 17916dd5de270e61a6a3fd3f4661a6413a50fd6f | ||
directory: mock_rock/1.2 | ||
release: | ||
1.2-22.04: | ||
end-of-life: "2030-05-01T00:00:00Z" | ||
risks: | ||
- beta |
86 changes: 86 additions & 0 deletions
86
tests/integration/test_prepare_single_image_build_matrix.py
This file contains 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,86 @@ | ||
# from pathlib import Path | ||
# import pytest | ||
|
||
import json | ||
import re | ||
import shutil | ||
import sys | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from src.image.prepare_single_image_build_matrix import \ | ||
main as prepare_build_matrix | ||
|
||
from .. import DATA_DIR | ||
|
||
|
||
@pytest.fixture | ||
def prep_execution(tmpdir, monkeypatch, request): | ||
|
||
image_trigger_sample = getattr(request, "param", None) | ||
|
||
# configure files/env requried for the test | ||
github_output = tmpdir / "github_output" | ||
monkeypatch.setenv("GITHUB_OUTPUT", str(github_output)) | ||
|
||
revision_data_dir = tmpdir / "revision-data" | ||
revision_data_dir.mkdir() | ||
|
||
oci_trigger_dir = tmpdir / "image_trigger" | ||
oci_trigger_dir.mkdir() | ||
shutil.copy( | ||
image_trigger_sample, | ||
oci_trigger_dir / "image.yaml", | ||
) | ||
|
||
# patch the arv for the test. script.py can be anything | ||
args = ( | ||
f"--oci-path {oci_trigger_dir} --revision-data-dir {revision_data_dir}".split( | ||
" " | ||
) | ||
) | ||
monkeypatch.setattr(sys, "argv", ["script.py"] + args) | ||
|
||
return revision_data_dir, github_output | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"prep_execution, expected_release_to, expected_release_count", | ||
[ | ||
(DATA_DIR / "image_all_eol_tracks_with_release.yaml", True, 0), | ||
(DATA_DIR / "image_all_eol_tracks.yaml", False, 0), | ||
(DATA_DIR / "image_no_track_releases.yaml", False, 0), | ||
(DATA_DIR / "image_single_track_release.yaml", True, 1), | ||
(DATA_DIR / "image_with_release.yaml", True, 3), | ||
(DATA_DIR / "image_without_release.yaml", True, 3), | ||
], | ||
indirect=["prep_execution"], | ||
) | ||
def test_release_to(prep_execution, expected_release_to, expected_release_count): | ||
"""Test state of release-to in github output after running prepare_single_image_build_matrix""" | ||
revision_data_dir, github_output = prep_execution | ||
|
||
# run main from prepare_single_image_build_matrix | ||
prepare_build_matrix() | ||
|
||
github_output_content = github_output.read_text("utf8") | ||
|
||
assert re.search( | ||
f'^release-to={"true" if expected_release_to else ""}$', | ||
github_output_content, | ||
re.M, | ||
), "Invalid release-to value" | ||
|
||
revision_files = Path(revision_data_dir).glob("*") | ||
|
||
release_count = 0 | ||
|
||
for file in revision_files: | ||
revision_data = json.loads(file.read_text()) | ||
if release_list := revision_data.get("release"): | ||
release_count += len(release_list) | ||
|
||
assert ( | ||
expected_release_count == release_count | ||
), "Invalid number of builds to release" |