-
Notifications
You must be signed in to change notification settings - Fork 51
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
40 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 d3078d1
Merge branch 'main' into issue-8063
grantfitzsimmons 4c28212
Potential fix for pull request finding 'CodeQL / Empty except'
CarolineDenis c1290a7
Potential fix for pull request finding 'CodeQL / Empty except'
CarolineDenis b3ea1d5
Potential fix for pull request finding 'CodeQL / Empty except'
CarolineDenis 603ba88
Potential fix for pull request finding 'CodeQL / Empty except'
CarolineDenis 0a590c8
Merge branch 'main' into issue-8063
CarolineDenis 817d766
Merge branch 'main' into issue-8063
grantfitzsimmons 26e652d
fix: use pass instead of continue in scanner
grantfitzsimmons fa0f315
Merge branch 'issue-8063' of https://github.com/specify/specify7 into…
grantfitzsimmons 36a8657
chore: minor style adjustment
grantfitzsimmons 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
Some comments aren't visible on the classic Files Changed page.
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
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,92 @@ | ||
| import requests | ||
| import datetime | ||
| import sys | ||
| import subprocess | ||
| import re | ||
| from requests import RequestException | ||
|
|
||
| THRESHOLD_DAYS = 180 | ||
|
|
||
|
|
||
| def get_django_version(): | ||
| result = subprocess.run( | ||
| [sys.executable, "-m", "django", "--version"], | ||
| capture_output=True, | ||
| text=True | ||
| ) | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| if result.returncode != 0: | ||
| print("ERROR: Unable to determine Django version") | ||
| sys.exit(1) | ||
|
|
||
| full_version = result.stdout.strip() | ||
|
|
||
| # Example: | ||
| # 4.2.16 -> 4.2 | ||
| m = re.match(r"^(\d+)\.(\d+)", full_version) | ||
| if not m: | ||
| print(f"ERROR: Unexpected Django version format: {full_version}") | ||
| sys.exit(1) | ||
|
|
||
| cycle = f"{m.group(1)}.{m.group(2)}" | ||
|
|
||
| return full_version, cycle | ||
|
|
||
|
|
||
| def get_django_eol(cycle): | ||
| url = "https://endoflife.date/api/django.json" | ||
|
|
||
| try: | ||
| response = requests.get(url, timeout=10) | ||
| response.raise_for_status() | ||
| except RequestException as exc: | ||
| print(f"ERROR: Failed to fetch EOL data: {exc}") | ||
| sys.exit(1) | ||
|
|
||
| data = response.json() | ||
|
|
||
| for release in data: | ||
| if release["cycle"] == cycle: | ||
| return release["eol"] | ||
|
|
||
| print(f"ERROR: No EOL data found for Django {cycle}") | ||
| sys.exit(1) | ||
|
|
||
|
|
||
| def calculate_days_remaining(eol_date): | ||
| today = datetime.date.today() | ||
| eol = datetime.datetime.strptime(eol_date, "%Y-%m-%d").date() | ||
| return (eol - today).days | ||
|
|
||
|
|
||
| def main(): | ||
| full_version, cycle = get_django_version() | ||
|
|
||
| eol_date = get_django_eol(cycle) | ||
| days_remaining = calculate_days_remaining(eol_date) | ||
|
|
||
| status = "OK" | ||
| if days_remaining < THRESHOLD_DAYS: | ||
| status = "WARNING" | ||
|
|
||
| # ---- structured output for GitHub Actions ---- | ||
| print(f"STATUS={status}") | ||
| print(f"DJANGO_VERSION={full_version}") | ||
| print(f"DJANGO_CYCLE={cycle}") | ||
| print(f"EOL_DATE={eol_date}") | ||
| print(f"DAYS_REMAINING={days_remaining}") | ||
|
|
||
| # ---- human-readable log ---- | ||
| print("\n--- Django EOL Report ---") | ||
| print(f"Version: {full_version}") | ||
| print(f"Cycle: {cycle}") | ||
| print(f"EOL date: {eol_date}") | ||
| print(f"Days remaining: {days_remaining}") | ||
| print(f"Status: {status}") | ||
|
|
||
| # keep non-blocking behavior (CI should NOT fail) | ||
| sys.exit(0) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
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.