From d74e760b0d84b52439972931a6a1d8d264bc1608 Mon Sep 17 00:00:00 2001 From: Anas Husseini Date: Fri, 21 Jun 2024 15:42:36 +0300 Subject: [PATCH 1/3] add 'deprecated' field for depreacted section generation in image docs --- src/docs/generate_oci_doc_yaml.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/docs/generate_oci_doc_yaml.py b/src/docs/generate_oci_doc_yaml.py index c159e2b0..9a1ba959 100755 --- a/src/docs/generate_oci_doc_yaml.py +++ b/src/docs/generate_oci_doc_yaml.py @@ -12,7 +12,9 @@ import subprocess import sys import tempfile +import timezone from typing import Any, Dict, List +from datetime import datetime from dateutil import parser import boto3 @@ -269,6 +271,11 @@ def build_releases_data( "until": eol.strftime("%m/%Y") } + if eol > datetime.now(timezone.utc): + release_data["deprecated"] = { + "date": eol.strftime("%m/%Y") + } + releases.append(release_data) return releases From 11521c5d185b9e53eb67c9076210a4d9fdc952e9 Mon Sep 17 00:00:00 2001 From: linostar Date: Fri, 21 Jun 2024 13:01:12 +0000 Subject: [PATCH 2/3] ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/9613833853 --- oci/mock-rock/_releases.json | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/oci/mock-rock/_releases.json b/oci/mock-rock/_releases.json index 9e312931..dcbeeee0 100644 --- a/oci/mock-rock/_releases.json +++ b/oci/mock-rock/_releases.json @@ -1,68 +1,68 @@ { "latest": { "candidate": { - "target": "283" + "target": "1.0-22.04_candidate" }, "beta": { - "target": "283" + "target": "latest_candidate" }, "edge": { - "target": "283" + "target": "latest_beta" }, "end-of-life": "2025-05-01T00:00:00Z" }, "1.0-22.04": { "candidate": { - "target": "283" + "target": "316" }, "beta": { - "target": "283" + "target": "316" }, "edge": { - "target": "283" + "target": "316" }, "end-of-life": "2025-05-01T00:00:00Z" }, "test": { "beta": { - "target": "283" + "target": "1.0-22.04_beta" }, "edge": { - "target": "283" + "target": "test_beta" }, "end-of-life": "2026-05-01T00:00:00Z" }, "1.1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "284" + "target": "317" }, "beta": { - "target": "284" + "target": "317" }, "edge": { - "target": "284" + "target": "317" } }, "1-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "candidate": { - "target": "284" + "target": "317" }, "beta": { - "target": "284" + "target": "317" }, "edge": { - "target": "284" + "target": "317" } }, "1.2-22.04": { "end-of-life": "2025-05-01T00:00:00Z", "beta": { - "target": "285" + "target": "318" }, "edge": { - "target": "285" + "target": "1.2-22.04_beta" } } } \ No newline at end of file From 22b17eba3fc1eeb056474f7690fa299603ea402a Mon Sep 17 00:00:00 2001 From: Linostar Date: Mon, 30 Sep 2024 14:39:06 +0300 Subject: [PATCH 3/3] Do not build/release/test/scan tracks with expired end-of-life values (#241) --- oci/mock-rock/image.yaml | 2 +- .../prepare_single_image_build_matrix.py | 23 +++++++++++++++---- src/image/utils/schema/triggers.py | 18 ++------------- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/oci/mock-rock/image.yaml b/oci/mock-rock/image.yaml index 72a34809..d8670ad5 100644 --- a/oci/mock-rock/image.yaml +++ b/oci/mock-rock/image.yaml @@ -14,7 +14,7 @@ upload: directory: examples/mock-rock/1.0 release: 1.0-22.04: - end-of-life: "2025-05-01T00:00:00Z" + end-of-life: "2024-05-01T00:00:00Z" risks: - candidate - edge diff --git a/src/image/prepare_single_image_build_matrix.py b/src/image/prepare_single_image_build_matrix.py index a3857838..9047d0bd 100755 --- a/src/image/prepare_single_image_build_matrix.py +++ b/src/image/prepare_single_image_build_matrix.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import argparse +from datetime import datetime, timezone import glob import json import os @@ -53,8 +54,10 @@ def validate_image_trigger(data: dict) -> None: builds = image_trigger.get("upload", []) release_to = "true" if "release" in image_trigger else "" + + img_number = 0 # inject some extra metadata into the matrix data - for img_number, _ in enumerate(builds): + while img_number < len(builds): builds[img_number]["name"] = args.oci_path.rstrip("/").split("/")[-1] builds[img_number]["path"] = args.oci_path # make sure every build of this image has a unique identifier @@ -69,13 +72,23 @@ def validate_image_trigger(data: dict) -> None: # set an output as a marker for later knowing if we need to release if "release" in builds[img_number]: - release_to = "true" - # the workflow GH matrix has a problem parsing nested JSON dicts - # so let's remove this field since we don't need it for the builds - builds[img_number]["release"] = "true" + min_eol = datetime.strptime(min( + v["end-of-life"] for v in builds[img_number]["release"].values() + ), "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=timezone.utc) + if min_eol < datetime.now(timezone.utc): + print("Track skipped because it reached its end of life") + del builds[img_number] + continue + else: + release_to = "true" + # the workflow GH matrix has a problem parsing nested JSON dicts + # so let's remove this field since we don't need it for the builds + builds[img_number]["release"] = "true" else: builds[img_number]["release"] = "" + img_number += 1 + matrix = {"include": builds} print(f"{args.oci_path} - build matrix:\n{json.dumps(matrix, indent=4)}") with open(os.environ["GITHUB_OUTPUT"], "a") as gh_out: diff --git a/src/image/utils/schema/triggers.py b/src/image/utils/schema/triggers.py index 221c9ce0..e9e6a4d2 100644 --- a/src/image/utils/schema/triggers.py +++ b/src/image/utils/schema/triggers.py @@ -1,6 +1,6 @@ import pydantic -from datetime import datetime, timezone +from datetime import datetime from typing import Dict, List, Literal, Optional @@ -25,13 +25,6 @@ class ImageUploadReleaseSchema(pydantic.BaseModel): class Config: extra = pydantic.Extra.forbid - @pydantic.validator("end_of_life") - def ensure_still_supported(cls, v: datetime) -> datetime: - """ensure that the end of life isn't reached.""" - if v < datetime.now(timezone.utc): - raise ImageReachedEol("This track has reached its end of life") - return v - class ImageUploadSchema(pydantic.BaseModel): """Schema of each upload within the image.yaml files.""" @@ -58,7 +51,7 @@ class Config: extra = pydantic.Extra.forbid @pydantic.validator("stable", "candidate", "beta", "edge", pre=True) - def _check_risks(cls, values: List) -> str: + def _check_risks(cls, values: List) -> List: """There must be at least one risk specified.""" error = "At least one risk must be specified per track." if not any(values): @@ -66,13 +59,6 @@ def _check_risks(cls, values: List) -> str: return values - @pydantic.validator("end_of_life") - def ensure_still_supported(cls, v: datetime) -> datetime: - """ensure that the end of life isn't reached.""" - if v < datetime.now(timezone.utc): - raise ImageReachedEol("This track has reached its end of life") - return v - class ImageSchema(pydantic.BaseModel): """Validates the schema of the image.yaml files."""