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

Tracking airflow-github changelog activities using progress bar #36610

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Changes from 1 commit
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
40 changes: 24 additions & 16 deletions dev/airflow-github
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import git
import rich_click as click
from github import Github
from packaging import version
from rich.console import Console
from rich.progress import Progress

if TYPE_CHECKING:
from github.Issue import Issue
Expand All @@ -40,7 +42,6 @@ GIT_COMMIT_FIELDS = ["id", "author_name", "author_email", "date", "subject", "bo
GIT_LOG_FORMAT = "%x1f".join(["%h", "%an", "%ae", "%ad", "%s", "%b"]) + "%x1e"
pr_title_re = re.compile(r".*\((#[0-9]{1,6})\)$")


STATUS_COLOR_MAP = {
"Closed": "green",
"Open": "red",
Expand Down Expand Up @@ -322,9 +323,6 @@ def changelog(previous_version, target_version, github_token):
repo = git.Repo(".", search_parent_directories=True)
# Get a list of issues/PRs that have been committed on the current branch.
log = get_commits_between(repo, previous_version, target_version)

print("Number of commits", len(log))

gh = Github(github_token)
gh_repo = gh.get_repo("apache/airflow")
sections = defaultdict(list)
Expand All @@ -335,18 +333,28 @@ def changelog(previous_version, target_version, github_token):
if match:
existing_commits.add(match.group(1))

for commit in log:
tickets = pr_title_re.findall(commit["subject"])
if tickets:
issue = gh_repo.get_issue(number=int(tickets[0][1:]))
issue_type = get_issue_type(issue)
files = files_touched(repo, commit["id"])
if commit["id"] in existing_commits:
continue
if is_core_commit(files):
sections[issue_type].append(commit["subject"])
else:
sections[DEFAULT_SECTION_NAME].append(commit["subject"])
# To disable the progress bar, set to True
disable_progress = False
potiuk marked this conversation as resolved.
Show resolved Hide resolved
console = Console(width=180)

with Progress(console=console, disable=disable_progress) as progress:
task = progress.add_task("Processing commits from changelog", total=len(log))
for commit in progress.track(log, description="Processing commits from changelog"):
tickets = pr_title_re.findall(commit["subject"])
if tickets:
issue = gh_repo.get_issue(number=int(tickets[0][1:]))
issue_type = get_issue_type(issue)
files = files_touched(repo, commit["id"])
if commit["id"] in existing_commits:
continue
if is_core_commit(files):
sections[issue_type].append(commit["subject"])
progress.update(task, advance=1)
else:
sections[DEFAULT_SECTION_NAME].append(commit["subject"])
progress.update(task, advance=1)

console.print("\n")
print_changelog(sections)


Expand Down