-
-
Notifications
You must be signed in to change notification settings - Fork 853
Generate release cycle chart and CSV #988
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 18 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
a8786b7
Generate release cycle chart and CSV
hugovk b853e39
Add encoding and newlines for consistent cross-platform Unicode support
hugovk a63e46c
Write CSV with '\n' instead of '\r\n' line terminators
hugovk c1f2c66
Move diagram above tables
hugovk a46648f
Wording: features -> feature
hugovk 4be979e
Wording: End-of-life -> End of life
hugovk 568e3dd
Put version as JSON key with branch name as a value
hugovk 54c1e75
JSON keys in snake_case
hugovk 00f6d0d
Add missing encoding and use a more descriptive filename
hugovk 3fb82ca
Modify generate-release-cycle script to use DictWriter
CAM-Gerlach 44d0a46
Updates for DictWriter
hugovk 0edc4c4
Rename with underscores
hugovk 2a7ee88
Rename save_ to write_
hugovk 59db2e0
Rename/reorder data keys
hugovk a514138
Move into _tools, add to Windows make.bat
hugovk 8f9c03c
Test generating release cycle
hugovk 0927c40
PEP 257 docstrings
hugovk d4d01ba
Update CI: Windows line-endings, add runtime checks, update Git checks
hugovk a87279d
Set Git config for Windows before checkout
hugovk 3f918f0
CI: "git add ." instead of line ending config
hugovk e73aefd
Merge branch 'main' into add-release-cycle
hugovk 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Test release cycle | ||
|
||
on: [pull_request, push, workflow_dispatch] | ||
|
||
env: | ||
FORCE_COLOR: 1 | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [windows-latest, ubuntu-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Silence Windows warnings | ||
run: | | ||
git config core.eol lf | ||
git config core.autocrlf input | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3" | ||
|
||
- name: Generate release cycle output | ||
run: python -I -bb -X dev -X warn_default_encoding -W error _tools/generate_release_cycle.py | ||
|
||
- name: Check for differences | ||
run: | | ||
git status | ||
git diff | ||
test $(git status --porcelain | wc -l) = 0 | ||
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
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,108 @@ | ||
"""Read in a JSON and generate two CSVs and a Mermaid file.""" | ||
from __future__ import annotations | ||
|
||
import csv | ||
import datetime as dt | ||
import json | ||
|
||
MERMAID_HEADER = """ | ||
gantt | ||
dateFormat YYYY-MM-DD | ||
title Python release cycle | ||
axisFormat %Y | ||
""".lstrip() | ||
|
||
MERMAID_SECTION = """ | ||
section Python {version} | ||
{release_status} :{mermaid_status} python{version}, {first_release},{eol} | ||
""" # noqa: E501 | ||
|
||
MERMAID_STATUS_MAPPING = { | ||
"feature": "", | ||
"bugfix": "active,", | ||
"security": "done,", | ||
"end-of-life": "crit,", | ||
} | ||
|
||
|
||
def csv_date(date_str: str, now_str: str) -> str: | ||
"""Format a date for CSV.""" | ||
if date_str > now_str: | ||
# Future, add italics | ||
return f"*{date_str}*" | ||
return date_str | ||
|
||
|
||
def mermaid_date(date_str: str) -> str: | ||
"""Format a date for Mermaid.""" | ||
if len(date_str) == len("yyyy-mm"): | ||
# Mermaid needs a full yyyy-mm-dd, so let's approximate | ||
date_str = f"{date_str}-01" | ||
return date_str | ||
|
||
|
||
class Versions: | ||
"""For converting JSON to CSV and Mermaid.""" | ||
|
||
def __init__(self) -> None: | ||
with open("include/release-cycle.json", encoding="UTF-8") as in_file: | ||
self.versions = json.load(in_file) | ||
self.sorted_versions = sorted( | ||
self.versions.items(), | ||
key=lambda k: [int(i) for i in k[0].split(".")], | ||
reverse=True, | ||
) | ||
|
||
def write_csv(self) -> None: | ||
"""Output CSV files.""" | ||
n 9E12 ow_str = str(dt.datetime.utcnow()) | ||
|
||
versions_by_category = {"branches": {}, "end-of-life": {}} | ||
headers = None | ||
for version, details in self.sorted_versions: | ||
row = { | ||
"Branch": details["branch"], | ||
"Schedule": f":pep:`{details['pep']}`", | ||
"Status": details["status"], | ||
"First release": csv_date(details["first_release"], now_str), | ||
"End of life": csv_date(details["end_of_life"], now_str), | ||
"Release manager": details["release_manager"], | ||
} | ||
headers = row.keys() | ||
cat = "end-of-life" if details["status"] == "end-of-life" else "branches" | ||
versions_by_category[cat][version] = row | ||
|
||
for cat, versions in versions_by_category.items(): | ||
with open(f"include/{cat}.csv", "w", encoding="UTF-8", newline="") as file: | ||
csv_file = csv.DictWriter(file, fieldnames=headers, lineterminator="\n") | ||
csv_file.writeheader() | ||
csv_file.writerows(versions.values()) | ||
|
||
def write_mermaid(self) -> None: | ||
"""Output Mermaid file.""" | ||
out = [MERMAID_HEADER] | ||
|
||
for version, details in reversed(self.versions.items()): | ||
v = MERMAID_SECTION.format( | ||
version=version, | ||
first_release=details["first_release"], | ||
eol=mermaid_date(details["end_of_life"]), | ||
release_status=details["status"], | ||
mermaid_status=MERMAID_STATUS_MAPPING[details["status"]], | ||
) | ||
out.append(v) | ||
|
||
with open( | ||
"include/release-cycle.mmd", "w", encoding="UTF-8", newline="\n" | ||
) as f: | ||
f.writelines(out) | ||
|
||
|
||
def main() -> None: | ||
versions = Versions() | ||
versions.write_csv() | ||
versions.write_mermaid() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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
F438
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
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,122 @@ | ||
{ | ||
"3.12": { | ||
"branch": "main", | ||
"pep": 693, | ||
"status": "feature", | ||
"first_release": "2023-10-02", | ||
"end_of_life": "2028-10", | ||
"release_manager": "Thomas Wouters" | ||
}, | ||
"3.11": { | ||
"branch": "3.11", | ||
"pep": 664, | ||
"status": "bugfix", | ||
"first_release": "2022-10-24", | ||
"end_of_life": "2027-10", | ||
"release_manager": "Pablo Galindo Salgado" | ||
}, | ||
"3.10": { | ||
"branch": "3.10", | ||
"pep": 619, | ||
"status": "bugfix", | ||
"first_release": "2021-10-04", | ||
"end_of_life": "2026-10", | ||
"release_manager": "Pablo Galindo Salgado" | ||
}, | ||
"3.9": { | ||
"branch": "3.9", | ||
"pep": 596, | ||
"status": "security", | ||
"first_release": "2020-10-05", | ||
"end_of_life": "2025-10", | ||
"release_manager": "Łukasz Langa" | ||
}, | ||
"3.8": { | ||
"branch": "3.8", | ||
"pep": 569, | ||
"status": "security", | ||
"first_release": "2019-10-14", | ||
"end_of_life": "2024-10", | ||
"release_manager": "Łukasz Langa" | ||
}, | ||
"3.7": { | ||
"branch": "3.7", | ||
"pep": 537, | ||
"status": "security", | ||
"first_release": "2018-06-27", | ||
"end_of_life": "2023-06-27", | ||
"release_manager": "Ned Deily" | ||
}, | ||
"3.6": { | ||
"branch": "3.6", | ||
"pep": 494, | ||
"status": "end-of-life", | ||
"first_release": "2016-12-23", | ||
"end_of_life": "2021-12-23", | ||
"release_manager": "Ned Deily" | ||
}, | ||
"3.5": { | ||
"branch": "3.5", | ||
"pep": 478, | ||
"status": "end-of-life", | ||
"first_release": "2015-09-13", | ||
"end_of_life": "2020-09-30", | ||
"release_manager": "Larry Hastings" | ||
}, | ||
"3.4": { | ||
"branch": "3.4", | ||
"pep": 429, | ||
"status": "end-of-life", | ||
"first_release": "2014-03-16", | ||
"end_of_life": "2019-03-18", | ||
"release_manager": "Larry Hastings" | ||
}, | ||
"3.3": { | ||
"branch": "3.3", | ||
"pep": 398, | ||
"status": "end-of-life", | ||
"first_release": "2012-09-29", | ||
"end_of_life": "2017-09-29", | ||
"release_manager": "Georg Brandl, Ned Deily (3.3.7+)" | ||
}, | ||
"3.2": { | ||
"branch": "3.2", | ||
"pep": 392, | ||
"status": "end-of-life", | ||
"first_release": "2011-02-20", | ||
"end_of_life": "2016-02-20", | ||
"release_manager": "Georg Brandl" | ||
}, | ||
"2.7": { | ||
"branch": "2.7", | ||
"pep": 373, | ||
"status": "end-of-life", | ||
"first_release": "2010-07-03", | ||
"end_of_life": "2020-01-01", | ||
"release_manager": "Benjamin Peterson" | ||
}, | ||
"3.1": { | ||
"branch": "3.1", | ||
"pep": 375, | ||
"status": "end-of-life", | ||
"first_release": "2009-06-27", | ||
"end_of_life": "2012-04-09", | ||
"release_manager": "Benjamin Peterson" | ||
}, | ||
"3.0": { | ||
"branch": "3.0", | ||
"pep": 361, | ||
"status": "end-of-life", | ||
"first_release": "2008-12-03", | ||
"end_of_life": "2009-06-27", | ||
"release_manager": "Barry Warsaw" | ||
}, | ||
"2.6": { | ||
"branch": "2.6", | ||
"pep": 361, | ||
"status": "end-of-life", | ||
"first_release": "2008-10-01", | ||
"end_of_life": "2013-10-29", | ||
"release_manager": "Barry Warsaw" | ||
} | ||
} |
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 ch
2E1A
ange 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.