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

chore: add weekly workflow for github issues/pr metrics #29444

Merged
merged 7 commits into from
Mar 12, 2024

Conversation

paulhcsun
Copy link
Contributor

@paulhcsun paulhcsun commented Mar 11, 2024

Issue # (if applicable)

Closes #.

Reason for this change

Generate weekly version of the PR/issues metrics.

Description of changes

Add new workflow that runs weekly on Mondays @ 9 AM to generate a PR/Issue metrics report for the past week (Monday - Sunday).

Description of how you validated changes

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team March 11, 2024 17:57
@github-actions github-actions bot added the p2 label Mar 11, 2024
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Mar 11, 2024
@paulhcsun paulhcsun marked this pull request as ready for review March 11, 2024 21:59

# Set an environment variable with the date range
echo "$PREVIOUS_MONDAY..$CURRENT_SUNDAY"
echo "last_week=$first_day..$last_day" >> "$GITHUB_ENV"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems the variable needs to be updated with previous monday and current sunday

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

PREVIOUS_MONDAY=$(date -d "last monday" "+%Y-%m-%d")

# Calculate the current Sunday's date
CURRENT_SUNDAY=$(date -d "next Sunday" "+%Y-%m-%d")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QQ: Just would like to know if "next sunday" provides the current sunday or the upcoming sunday? Since the script runs every monday, does this gives the current sunday? We could also get the current sunday may be using "yesterday"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point as this would be run every monday, I'll update the naming.

Copy link
Member

@godwingrs22 godwingrs22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. Just few minor comments.

Comment on lines 23 to 26
PREVIOUS_MONDAY=$(date -d "last monday" "+%Y-%m-%d")

# Calculate the current Sunday's date
CURRENT_SUNDAY=$(date -d "current Sunday" "+%Y-%m-%d")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering if this command returns the correct previous monday and current sunday? Because to me seems both identical +%Y-%m-%d. Do you have any reference doc or any sample?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: consider renaming last monday to previous monday or vice versa to be consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait you're right that's not actually doing anything right now, let me have a look

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed updated shell script. Here's some docs to reference: https://ioflood.com/blog/bash-date-format/

Comment on lines 23 to 32
CURRENT_DAY_OF_WEEK=$(date +%u)

# Calculate the number of days to subtract to get to the previous Monday
DAYS_TO_MONDAY=$((CURRENT_DAY_OF_WEEK - 1))

# Calculate the date of the previous Monday
PREVIOUS_MONDAY=$(date -d "$DAYS_TO_MONDAY days ago" "+%Y-%m-%d")

# Calculate the date of the current Sunday (assuming today is not Sunday)
CURRENT_SUNDAY=$(date -d "$DAYS_TO_MONDAY days ago +6 day" "+%Y-%m-%d")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may not work since the DAYS_TO_MONDAY will return 0 if the script is running on monday.
Moreover, since we already know the script will be executed only every monday based on the cron job scheduled, we can simplify as below to get last week (last monday to last sunday)

LAST_MONDAY=$(date -d "7 days ago" "+%Y-%m-%d")
LAST_SUNDAY=$(date -d "1 day ago" "+%Y-%m-%d")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Mar 11, 2024
Copy link
Member

@godwingrs22 godwingrs22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Left a comment

SEARCH_QUERY: 'repo:aws/aws-cdk is:pr created:${{ env.last_week }} -is:draft'

- name: Create report for PRs
uses: peter-evans/create-issue-from-file@v5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker. Would like to know is it normal and safe to use third party github actions for aws owned repos? As I can see this action is not from a Verified creator label which usually GITHUB does.

peter-evans/create-issue-from-file@v5 -> https://github.com/marketplace/actions/create-issue-from-file

Sample verified action: https://github.com/marketplace/actions/checkout
image

Copy link
Contributor

mergify bot commented Mar 12, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Mar 12, 2024
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 638d356
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit bd41b9f into aws:main Mar 12, 2024
12 checks passed
Copy link
Contributor

mergify bot commented Mar 12, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants