Skip to content
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

Support release-level data #297

Merged
merged 2 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions latest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,18 @@ def __init__(self, product: "Product", data: dict) -> None:
self.matched = False
self.updated = False

def update_with(self, version: str, date: datetime.date) -> None:
def update_with(self, release: dict) -> None:
for key, value in release.items():
if isinstance(value, str) and re.fullmatch(r'^\d{4}-\d{2}-\d{2}$', value):
value = datetime.date.fromisoformat(value)

old_value = self.data.get(key, None)
if old_value != value:
logging.info(f"{self} {key} updated from {old_value} to {value}")
self.data[key] = value
self.updated = True

def update_with_version(self, version: str, date: datetime.date) -> None:
logging.debug(f"will try to update {self} with {version} ({date})")
self.matched = True
self.__update_release_date(version, date)
Expand Down Expand Up @@ -120,6 +131,7 @@ def __init__(self, name: str, product_dir: Path, versions_dir: Path) -> None:

self.releases = [ReleaseCycle(self, release) for release in self.data["releases"]]
self.updated = False
self.unmatched_releases = []
self.unmatched_versions = {}

# Placeholder function for mass-upgrading the structure of the product files.
Expand All @@ -133,6 +145,19 @@ def check_latest(self) -> None:
if release.matched and latest not in self.release_data["versions"]:
logging.info(f"latest version {latest} for {release} not found in {self.release_data_path}")

def process_release(self, release_data: dict) -> None:
name = release_data.pop("name") # name must not appear in updates

release_matched = False
for release in self.releases:
if release.name == name:
release_matched = True
release.update_with(release_data)
self.updated = self.updated or release.updated

if not release_matched:
self.unmatched_releases.append(name)

def process_version(self, version_data: dict) -> None:
name = version_data["name"]
date = datetime.date.fromisoformat(version_data["date"])
Expand All @@ -141,7 +166,7 @@ def process_version(self, version_data: dict) -> None:
for release in self.releases:
if release.includes(name):
version_matched = True
release.update_with(name, date)
release.update_with_version(name, date)
self.updated = self.updated or release.updated

if not version_matched:
Expand All @@ -166,7 +191,9 @@ def update_product(name: str, product_dir: Path, releases_dir: Path, output: Git
product.upgrade_structure()

if product.release_data:
for version_data in product.release_data["versions"].values():
for release_data in product.release_data.get("releases", {}).values():
product.process_release(release_data)
for version_data in product.release_data.get("versions", {}).values():
product.process_version(version_data)
product.check_latest()

Expand All @@ -183,6 +210,11 @@ def update_product(name: str, product_dir: Path, releases_dir: Path, output: Git
logging.warning(f"{name}:{version} ({date}) not included")
output.println(f"{name}:{version} ({date})")

if len(product.unmatched_releases) != 0:
for release in product.unmatched_releases:
logging.warning(f"{name}:{release} not included")
output.println(f"{name}:{release}")


if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Update product releases.')
Expand Down
1 change: 1 addition & 0 deletions releases/akeneo-pim.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"7.0.50": {
"name": "7.0.50",
Expand Down
1 change: 1 addition & 0 deletions releases/alibaba-dragonwell.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"8.17.18": {
"name": "8.17.18",
Expand Down
1 change: 1 addition & 0 deletions releases/almalinux.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"9.3": {
"name": "9.3",
Expand Down
1 change: 1 addition & 0 deletions releases/alpinelinux.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"3.19.1": {
"name": "3.19.1",
Expand Down
1 change: 1 addition & 0 deletions releases/amazon-cdk.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"2.127.0": {
"name": "2.127.0",
Expand Down
1 change: 1 addition & 0 deletions releases/amazon-corretto.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"21.0.2.14.1": {
"name": "21.0.2.14.1",
Expand Down
1 change: 1 addition & 0 deletions releases/amazon-linux.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"2023.3.20240131.0": {
"name": "2023.3.20240131.0",
Expand Down
1 change: 1 addition & 0 deletions releases/amazon-neptune.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"1.3.0.0": {
"name": "1.3.0.0",
Expand Down
1 change: 1 addition & 0 deletions releases/amazon-rds-mysql.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"8.0.35": {
"name": "8.0.35",
Expand Down
1 change: 1 addition & 0 deletions releases/amazon-rds-postgresql.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"16.1": {
"name": "16.1",
Expand Down
1 change: 1 addition & 0 deletions releases/angular.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"17.1.3": {
"name": "17.1.3",
Expand Down
1 change: 1 addition & 0 deletions releases/angularjs.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"1.8.3": {
"name": "1.8.3",
Expand Down
1 change: 1 addition & 0 deletions releases/ansible-core.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"2.16.3": {
"name": "2.16.3",
Expand Down
1 change: 1 addition & 0 deletions releases/ansible.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"9.2.0": {
"name": "9.2.0",
Expand Down
1 change: 1 addition & 0 deletions releases/antixlinux.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"8.5": {
"name": "8.5",
Expand Down
1 change: 1 addition & 0 deletions releases/apache-activemq.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"6.0.1": {
"name": "6.0.1",
Expand Down
1 change: 1 addition & 0 deletions releases/apache-airflow.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"2.8.1": {
"name": "2.8.1",
Expand Down
1 change: 1 addition & 0 deletions releases/apache-camel.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"4.0.4": {
"name": "4.0.4",
Expand Down
1 change: 1 addition & 0 deletions releases/apache-cassandra.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"4.0.12": {
"name": "4.0.12",
Expand Down
1 change: 1 addition & 0 deletions releases/apache-groovy.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"4.0.18": {
"name": "4.0.18",
Expand Down
1 change: 1 addition & 0 deletions releases/apache-hadoop.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"3.3.6": {
"name": "3.3.6",
Expand Down
1 change: 1 addition & 0 deletions releases/apache-hop.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"2.7.0": {
"name": "2.7.0",
Expand Down
1 change: 1 addition & 0 deletions releases/apache-http-server.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"2.4.58": {
"name": "2.4.58",
Expand Down
1 change: 1 addition & 0 deletions releases/apache-kafka.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"3.5.2": {
"name": "3.5.2",
Expand Down
1 change: 1 addition & 0 deletions releases/apache-maven.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"3.9.6": {
"name": "3.9.6",
Expand Down
1 change: 1 addition & 0 deletions releases/apache-spark.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"3.3.4": {
"name": "3.3.4",
Expand Down
1 change: 1 addition & 0 deletions releases/apache-struts.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"6.3.0.2": {
"name": "6.3.0.2",
Expand Down
1 change: 1 addition & 0 deletions releases/api-platform.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"3.2.13": {
"name": "3.2.13",
Expand Down
1 change: 1 addition & 0 deletions releases/arangodb.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"3.11.7.1": {
"name": "3.11.7.1",
Expand Down
1 change: 1 addition & 0 deletions releases/argocd.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"releases": {},
"versions": {
"2.10.0": {
"name": "2.10.0",
Expand Down
Loading