-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Conversation
|
||
# Set an environment variable with the date range | ||
echo "$PREVIOUS_MONDAY..$CURRENT_SUNDAY" | ||
echo "last_week=$first_day..$last_day" >> "$GITHUB_ENV" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
PREVIOUS_MONDAY=$(date -d "last monday" "+%Y-%m-%d") | ||
|
||
# Calculate the current Sunday's date | ||
CURRENT_SUNDAY=$(date -d "current Sunday" "+%Y-%m-%d") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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/
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") |
There was a problem hiding this comment.
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")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
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 CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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). |
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