Skip to content

Commit

Permalink
add triaged issues workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tudorpopams committed May 16, 2024
1 parent 311d1ca commit 1826f45
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 7 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/weekly-triaged-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
on:
workflow_dispatch:
schedule:
# Every Monday at 08:00 UTC
- cron: "0 8 * * 1"

jobs:
triage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: 3.12

- name: cache poetry install
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-1.7.1-0

- name: install poetry
uses: snok/install-poetry@v1
with:
version: 1.7.1
virtualenvs-create: true
virtualenvs-in-project: true

- name: cache deps
id: cache-deps
uses: actions/cache@v2
with:
path: .venv
key: pydeps-${{ hashFiles('**/poetry.lock') }}

- run: poetry install --no-interaction --no-root
if: steps.cache-deps.outputs.cache-hit != 'true'

- run: poetry install --no-interaction

- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m')"

- name: run charts script
run: poetry run python charts.py ${{ steps.date.outputs.date }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22 changes: 15 additions & 7 deletions charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def fetch_issues(repo, token):

with alive_bar(0, title="Fetching issues", unit=" pages") as bar:
while True:
url = f"https://api.github.com/repos/{repo}/issues?state=all&page={page}&per_page=100&labels=Fluent UI react-components (v9)"
url = f"https://api.github.com/repos/{repo}/issues?state=all&page={
page}&per_page=100&labels=Fluent UI react-components (v9)"
headers = {"Authorization": f"Bearer {token}"}

response = requests.get(url, headers=headers)
Expand Down Expand Up @@ -297,13 +298,15 @@ def plot_closed_epics_line(df_issues_closed, label_v9, label_epic):

def plot_triage_issues_line(df_issues):
created_issues = df_issues.sort_values(by="created_at", ascending=False)
created_issues["created_at"] = pd.to_datetime(created_issues["created_at"] - pd.to_timedelta(1, unit="w"))
created_issues["created_at"] = pd.to_datetime(
created_issues["created_at"] - pd.to_timedelta(1, unit="w"))

triage_df = df_issues[
df_issues["labels"].apply(lambda x: label_needs_triage in x)
].sort_values(by="created_at", ascending=False)

triage_df["created_at"] = pd.to_datetime(triage_df["created_at"] - pd.to_timedelta(1, unit="w"))
triage_df["created_at"] = pd.to_datetime(
triage_df["created_at"] - pd.to_timedelta(1, unit="w"))

data_created = (
created_issues.groupby(
Expand Down Expand Up @@ -331,7 +334,8 @@ def plot_triage_issues_line(df_issues):
)

created_values = list(data_created.values)
created_labels = [k[2].strftime("%Y-%m-%d") for k in list(data_created.index)]
created_labels = [k[2].strftime("%Y-%m-%d")
for k in list(data_created.index)]

values = list(data.values)
labels = [k[2].strftime("%Y-%m-%d") for k in list(data.index)]
Expand All @@ -358,14 +362,17 @@ def plot_triage_issues_line(df_issues):
ha="center",
)

plt.plot(labels, values, label="Issues needing triage", linestyle="-", marker="o")
plt.plot(created_labels, created_values, label="Created issues", linestyle="--", marker="o")
plt.plot(labels, values, label="Issues needing triage",
linestyle="-", marker="o")
plt.plot(created_labels, created_values,
label="Created issues", linestyle="--", marker="o")

plt.xticks(rotation=45)
plt.legend()

return plt


def _generate_and_save_plots(issues):
_, issues_minimal, df_issues, df_issues_closed, issue_labels = get_charts_data(
issues)
Expand All @@ -381,7 +388,8 @@ def _generate_and_save_plots(issues):

bar()

plt = plot_issues_in_the_past_12_months_line(df_issues, df_issues_closed)
plt = plot_issues_in_the_past_12_months_line(
df_issues, df_issues_closed)
plt.savefig("images/stats-03.png")

bar()
Expand Down
Binary file modified images/stats-01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/stats-03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/stats-06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1826f45

Please sign in to comment.