Skip to content

Commit d601ca1

Browse files
committed
Rewrite dockerhub_doc_config_update in Python and remove hardcoded config
- Rename config/hotspot.yml to config/temurin.yml - Replace dockerhub_doc_config_update.sh with a Python equivalent - Create shared adoptium_api module to fetch supported versions and latest LTS from https://api.adoptium.net/v3/info/available_releases - Use adoptium_api in both generate_dockerfiles.py and dockerhub_doc_config_update.py, eliminating duplicated version lists - Derive default_linux_image and default_alpine_image from the first entry in each OS family config rather than hardcoding them - Remove supported_distributions section from temurin.yml - Update CI workflow and README to reference the new Python script
1 parent b737cdb commit d601ca1

9 files changed

Lines changed: 775 additions & 268 deletions

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ name: Jinja CI
22
on:
33
pull_request:
44
paths:
5+
- adoptium_api.py
6+
- dockerhub_doc_config_update.py
57
- generate_dockerfiles.py
8+
- test_dockerhub_doc_config_update.py
69
- test_generate_dockerfiles.py
710
- requirements.txt
811
branches: [ main ]
@@ -24,4 +27,6 @@ jobs:
2427
run: "pip3 install -r requirements.txt"
2528

2629
- name: Run tests
27-
run: "python3 test_generate_dockerfiles.py"
30+
run: |
31+
python3 -m unittest test_generate_dockerfiles -v
32+
python3 -m unittest test_dockerhub_doc_config_update -v

.github/workflows/test-pr.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ jobs:
2121
strategy: ${{ steps.generate-jobs.outputs.strategy }}
2222
steps:
2323
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
24+
- run: pip install pyyaml
2425
- uses: docker-library/bashbrew@a519e31d2ed9cb229ff38ab4488e78bfa09d7a2a # v0.1.14
2526
- id: generate-jobs
2627
name: Generate Jobs
2728
run: |
28-
export GENERATE_STACKBREW_LIBRARY='./dockerhub_doc_config_update.sh /dev/stdout'
29+
export GENERATE_STACKBREW_LIBRARY='python3 dockerhub_doc_config_update.py /dev/stdout'
2930
export GITHUB_REPOSITORY="eclipse-temurin"
3031
strategy="$("$BASHBREW_SCRIPTS/github-actions/generate.sh")"
3132
echo "strategy=$strategy" >> "$GITHUB_OUTPUT"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Once you've merged the PR, you can update the official Docker Hub manifest. This
6363
git fetch --all
6464
# Checkout the main branch
6565
git checkout main
66-
./dockerhub_doc_config_update.sh
66+
python3 dockerhub_doc_config_update.py
6767
```
6868

6969
This script will create a file called _eclipse-temurin_ by default.

adoptium_api.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License");
2+
# you may not use this file except in compliance with the License.
3+
# You may obtain a copy of the License at
4+
#
5+
# https://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS,
9+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
# See the License for the specific language governing permissions and
11+
# limitations under the License.
12+
#
13+
14+
import json
15+
import urllib.request
16+
17+
ADOPTIUM_API_URL = "https://api.adoptium.net/v3/info/available_releases"
18+
19+
20+
def _fetch_release_data():
21+
"""Fetch release info from the Adoptium API."""
22+
req = urllib.request.Request(
23+
ADOPTIUM_API_URL,
24+
headers={"User-Agent": "Adoptium Dockerfile Updater"},
25+
)
26+
with urllib.request.urlopen(req) as response:
27+
return json.loads(response.read().decode("utf-8"))
28+
29+
30+
def get_supported_versions():
31+
"""Fetch supported versions from the Adoptium API.
32+
33+
Returns all LTS versions plus any non-LTS versions between the most
34+
recent LTS and the most recent feature release (inclusive).
35+
36+
For example, if LTS versions are [8, 11, 17, 21, 25] and the most
37+
recent feature release is 26, this returns [8, 11, 17, 21, 25, 26].
38+
"""
39+
data = _fetch_release_data()
40+
41+
lts_versions = set(data["available_lts_releases"])
42+
most_recent_lts = data["most_recent_lts"]
43+
most_recent_feature = data["most_recent_feature_release"]
44+
45+
# All LTS versions + anything between latest LTS and most recent feature release
46+
versions = set(lts_versions)
47+
for v in range(most_recent_lts + 1, most_recent_feature + 1):
48+
if v in data["available_releases"]:
49+
versions.add(v)
50+
51+
return sorted(versions)
52+
53+
54+
def get_latest_lts():
55+
"""Return the most recent LTS version number."""
56+
data = _fetch_release_data()
57+
return data["most_recent_lts"]

config/temurin.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
# limitations under the License.
1313
#
1414

15-
supported_distributions:
16-
Versions: [8, 11, 17, 21, 25, 26]
17-
1815
configurations:
1916
linux:
2017
# EOL April 2029

0 commit comments

Comments
 (0)