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

Add workflow for updating durations #6519

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open

Conversation

mudit2812
Copy link
Contributor

@mudit2812 mudit2812 commented Nov 5, 2024

Third attempt at creating a workflow that updates the durations files automatically.

Working workflow run here
PR opened by workflow here

[sc-72992]

Copy link
Contributor

github-actions bot commented Nov 5, 2024

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@mudit2812 mudit2812 marked this pull request as ready for review November 6, 2024 17:55
Copy link
Contributor

@rashidnhm rashidnhm 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! Would we be able to test this within this PR? Maybe temporarily add the pull_request trigger and then remove? (or has testing already been done?)

Other than that, LGTM

.github/workflows/check_in_artifact.yml Outdated Show resolved Hide resolved
@mudit2812
Copy link
Contributor Author

Overall looks good! Would we be able to test this within this PR? Maybe temporarily add the pull_request trigger and then remove? (or has testing already been done?)

Other than that, LGTM

@rashidnhm I linked a workflow run in the description of this PR.

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.34%. Comparing base (e0949ed) to head (e9b19a0).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6519      +/-   ##
==========================================
- Coverage   99.65%   99.34%   -0.32%     
==========================================
  Files         455      455              
  Lines       43193    43193              
==========================================
- Hits        43044    42909     -135     
- Misses        149      284     +135     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 135 to 155
PR_BODY: ${{ inputs.pull_request_body }}
run: |
EXISTING_PR="$(gh pr list --state open --base master --head $HEAD_BRANCH_NAME --json 'url' --jq '.[].url' | head -n 1)"
EXISTING_CLOSED_PR="$(gh pr list --state closed --base master --head $HEAD_BRANCH_NAME --json 'mergedAt,url' --jq '.[] | select(.mergedAt == null).url' | head -n 1)"

if [ -n "${EXISTING_PR}" ]; then
echo "PR already exists ==> ${EXISTING_PR}"
echo "Open PR already exists ==> ${EXISTING_PR"
echo "Editing with provided title and body..."
gh pr edit --title "$PR_TITLE" --body "$PR_BODY"
exit 0
elif [ -n "${EXISTING_CLOSED_PR}" ] && [ ${{ steps.prep_commit.outputs.branch_exists }}=='true' ]; then
echo "Reopening PR... ${EXISTING_CLOSED_PR}"
gh pr reopen "${EXISTING_CLOSED_PR}"
echo "Editing with provided title and body..."
gh pr edit --title "$PR_TITLE" --body "$PR_BODY"
exit 0
else
echo "Creating PR..."
gh pr create --title "$PR_TITLE" --body "$PR_BODY"
exit 0
fi
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new logic does the following:

  • If there is an existing PR, just edit the title and body with what was given as inputs to this action and do nothing else
  • Else if there is a closed PR and the branch for the closed PR was not deleted, then reopen the PR and edit the title and body. I added the 2nd condition because the reopen command failed on an old run when the branch of the closed PR had been deleted and we had to create a new branch.
  • Else, open a new PR with the provided title and body

Comment on lines 105 to 114
EXISTING_BRANCH=$(git ls-remote --exit-code origin "refs/heads/$HEAD_BRANCH_NAME")

if [ -n $EXISTING_BRANCH ]; then
echo "$HEAD_BRANCH_NAME exists! Checking out..."
git checkout "$HEAD_BRANCH_NAME"
echo "branch_exists='true'" >> $GITHUB_OUTPUT
else
echo "$HEAD_BRANCH_NAME does not exist! Creating..."
git checkout -b "$HEAD_BRANCH_NAME"
echo "branch_exists='false'" >> $GITHUB_OUTPUT
Copy link
Contributor Author

@mudit2812 mudit2812 Nov 8, 2024

Choose a reason for hiding this comment

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

branch_exists, a new output of this step which happens before the step that creates a PR, is used for the 2nd condition in the previous comment.

@mudit2812 mudit2812 requested review from rashidnhm and removed request for rashidnhm November 12, 2024 21:07
Copy link
Contributor

@rashidnhm rashidnhm 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, is the stash method working consistently now?

.github/workflows/check_in_artifact.yml Outdated Show resolved Hide resolved
.github/workflows/check_in_artifact.yml Outdated Show resolved Hide resolved
@mudit2812
Copy link
Contributor Author

is the stash method working consistently now?

@rashidnhm Yep, it's working well 😄 . I got it to work by using git checkout stash instead of git stash pop, which essentially just forces git to use the stashed changes as the source of truth rather than asking users to manually resolve merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants