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

Use EOL data to curate the list of supported versions #29

Merged
merged 3 commits into from
Feb 2, 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
23 changes: 14 additions & 9 deletions update-versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@
import json
import os
import pathlib
import semver
import requests
import subprocess


def get_maintained_cycles():
eol_data = requests.get("https://endoflife.date/api/terraform.json").json()
return [cycle['cycle'] for cycle in eol_data if not cycle['eol']]


def read_versions():
with open("versions.json", "r") as f:
return json.load(f)


def is_stable(release):
def is_stable(release, maintained_cycles):
version = release.tag_name.removeprefix("v")
return semver.compare(version, "1.6.0") >= 0 and not (
version_major_minor = '.'.join(version.split('.')[:2])
return version_major_minor in maintained_cycles and not (
release.draft or release.prerelease
)

Expand Down Expand Up @@ -103,16 +109,15 @@ def nix_prefetch(args):
g = github.Github(auth=auth)
repo = g.get_repo("hashicorp/terraform")
# TODO: Drop "v" prefix first
# TODO: Combine the output of the following endpoints to get a list of active
# versions
# https://api.github.com/repos/hashicorp/terraform/tags
# https://endoflife.date/api/terraform.json
Comment on lines -106 to -109
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I captured the whole idea presented here. In any case, using the tags endpoint could be problematic since we wouldn't be able to filter out draft tags.

releases = list(filter(is_stable, repo.get_releases()))

# Craft list of maintaned releases by filtering the release list with the EOL data
maintained_releases = list(filter(lambda version: is_stable(version, get_maintained_cycles()), repo.get_releases()))

current_versions = read_versions()
versions = collections.OrderedDict(
sorted(
functools.reduce(
to_version(args.vendor_hash), releases, current_versions
to_version(args.vendor_hash), maintained_releases, current_versions
).items(),
reverse=True,
)
Expand Down
4 changes: 4 additions & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"1.7.2": {
"hash": "sha256-jTzZWmYeKF87Er2i7XHquM8oQyF4q/qoBf4DdMqv7L8=",
"vendorHash": "sha256-DI4YTjdFFvfby8ExEY3KoK4J9YKK5LPpMbelzFMDVVs="
},
"1.7.1": {
"hash": "sha256-e+YXOqXgiUXtm6P8PulZowRK0OLA8ekmS+MZRQP/srg=",
"vendorHash": "sha256-77W0x6DENB+U3yB4LI3PwJU9bTuH7Eqz2a9FNoERuJg="
Expand Down