-
Notifications
You must be signed in to change notification settings - Fork 44
Script: "Add Django EOL checker script (comment if <180 days to EOL)" #8068
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
Open
CarolineDenis
wants to merge
30
commits into
main
Choose a base branch
from
issue-8063
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
350bd00
Script: "Add Django EOL checker script (fail if <180 days to EOL)"
CarolineDenis a1a215f
Github: Add github CI for EOL dependencies
CarolineDenis 4578d8c
Fix: Improve run time out handling
CarolineDenis e986b74
Test: Create pr comments when warning triggered
CarolineDenis 1da6a28
Fix: Fix installation
CarolineDenis 7900e9a
Fix: Add timeout
CarolineDenis b4cdadb
Fix: Add timeout to CI
CarolineDenis 6202252
Fix: Alignement
CarolineDenis 2988b3d
Fix: Handle backticks
CarolineDenis 19e8703
Comment
CarolineDenis 28c95c8
Clean
CarolineDenis 4107146
Fix: test new install for dependecies
CarolineDenis bcb6164
Fix: Typo
CarolineDenis a61cb47
Fix: Create or Update github action comment
CarolineDenis e3737d4
Test
CarolineDenis db19719
Feat: Generalize EOL script
CarolineDenis 3e7f524
Fix: fix python version
CarolineDenis eac393f
Feat: Combine github comments
CarolineDenis 846ed30
Fix: Indentation
CarolineDenis af092af
Refactor: Allow expension of EOL tracking
CarolineDenis fc387f1
Fix: remove install
CarolineDenis c4e53cc
Fix: fix path
CarolineDenis 755dd58
Fix: Update imports
CarolineDenis fa88ada
Fix: Add init
CarolineDenis 863cdf0
Update .github/workflows/test.yml
CarolineDenis d83c2b5
fix: apply CodeRabbit auto-fixes
coderabbitai[bot] 3247410
Fix: Handle None dates
CarolineDenis c9a8ae5
Fix: Handle string and integer cycle
CarolineDenis a9cd34e
Fix: handle failed request
CarolineDenis c4165f8
Fix: Improve regex
CarolineDenis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Empty file.
Empty file.
This file contains hidden or 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,11 @@ | ||
| import sys | ||
|
|
||
| from scripts.eol.runner import run_all | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| if len(sys.argv) == 1: | ||
| run_all() | ||
| else: | ||
| from scripts.eol.runner import run_one | ||
| run_one(sys.argv[1].lower()) |
This file contains hidden or 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,32 @@ | ||
| import requests | ||
| import datetime | ||
| import sys | ||
| from requests import RequestException | ||
|
|
||
|
|
||
| def get_eol_date(api_url: str, cycle: str): | ||
| try: | ||
| response = requests.get(api_url, timeout=10) | ||
| response.raise_for_status() | ||
| except RequestException as exc: | ||
| print(f"ERROR: Failed to fetch EOL data: {exc}") | ||
| sys.exit(1) | ||
|
|
||
| for release in response.json(): | ||
| if str(release["cycle"]) == cycle: | ||
| return release["eol"] | ||
|
|
||
| print(f"ERROR: No EOL data found for cycle {cycle}") | ||
| sys.exit(1) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
|
|
||
| def calculate_days_remaining(eol_date: str): | ||
| if not isinstance(eol_date, str) or not eol_date or eol_date is False: | ||
| return None | ||
|
|
||
| try: | ||
| today = datetime.date.today() | ||
| eol = datetime.datetime.strptime(eol_date, "%Y-%m-%d").date() | ||
| return (eol - today).days | ||
| except ValueError: | ||
| return None | ||
This file contains hidden or 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,43 @@ | ||
| from scripts.eol.scanner import scan_repo | ||
| from scripts.eol.runtimes import RUNTIMES | ||
| from scripts.eol.eol_api import get_eol_date, calculate_days_remaining | ||
|
|
||
| THRESHOLD_DAYS = 180 | ||
|
|
||
|
|
||
| def run_one(product): | ||
| run_all(filter_product=product) | ||
|
|
||
|
|
||
| def run_all(filter_product=None): | ||
| detected = scan_repo() | ||
|
|
||
| if filter_product: | ||
| detected = {filter_product: detected.get(filter_product)} | ||
|
|
||
| for name, version in detected.items(): | ||
| if not version: | ||
| continue | ||
|
|
||
| runtime = RUNTIMES.get(name) | ||
| if not runtime: | ||
| continue | ||
|
|
||
| eol_date = get_eol_date(runtime.api, version) | ||
| days = calculate_days_remaining(eol_date) | ||
|
|
||
| if days is None: | ||
| status = "UNKNOWN" | ||
| else: | ||
| status = "WARNING" if days < THRESHOLD_DAYS else "OK" | ||
|
|
||
| print(f"STATUS={status}") | ||
| print(f"{name.upper()}_VERSION={version}") | ||
| print(f"{name.upper()}_CYCLE={version}") | ||
| print(f"EOL_DATE={eol_date}") | ||
| print(f"DAYS_REMAINING={days}") | ||
|
|
||
| print(f"\n--- {runtime.display_name} ---") | ||
| print(f"Version: {version}") | ||
| print(f"EOL: {eol_date}") | ||
| print(f"Status: {status}\n") |
This file contains hidden or 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,24 @@ | ||
| class Runtime: | ||
| def __init__(self, name, api, display_name): | ||
| self.name = name | ||
| self.api = api | ||
| self.display_name = display_name | ||
|
|
||
|
|
||
| RUNTIMES = { | ||
| "python": Runtime( | ||
| "python", | ||
| "https://endoflife.date/api/python.json", | ||
| "Python", | ||
| ), | ||
| "node": Runtime( | ||
| "node", | ||
| "https://endoflife.date/api/nodejs.json", | ||
| "Node.js", | ||
| ), | ||
| "django": Runtime( | ||
| "django", | ||
| "https://endoflife.date/api/django.json", | ||
| "Django", | ||
| ), | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.