-
Notifications
You must be signed in to change notification settings - Fork 2
Update Github draft release workflow #338
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
Conversation
|
It would be easier to compare workflows if this is a change of the existing file rather than a separate file. As mentioned in #336 , we should move ahead either with that one or this one, but not both. Please let me know which you prefer. |
|
Sorry for the new file, I meant to replace the original one after copying the functionality. If this one works I would prefer this over the more complicated git commands in the current implementation. I'll test it in a fork before continuing. |
1439d15 to
4896caf
Compare
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.
Great work. I think this is a much more elegant and easy to understand workflow than we had before!
I pushed one commit where I made the formatting consistent and added some names to the steps (feel free to revert if you disagree).
Apart from that a few comments/questions below.
def8a73 to
d063aa4
Compare
|
@DaniBodor I again rewrote a significant part of the workflow. You were right in that the workflow would be partly executed but then halt if merging to develop was not possible. There is a solution thinkable where you merge to main, but revert that if main cannot be merged to develop. This feels error-prone and could result in superfluous revert commits. Instead, I chose to do all merging and bumping actions before pushing the results back to GitHub. If at any stage merging to main or from main to develop fails, the repo will not be pushed and the action fails. By merging the PR it is automatically closed. This does not remove the branch, so that is done separately in cleanup. I also rewrote/added checks. They now:
I tested all this in a fork of the repo. The situations I tested:
Lastly I removed the CITATION file validation. This failed for a reason I could not explain. Also, this validation is done for every PR using another action. This felt superfluous at this stage. |
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.
Even better and clearer changes now!
And great that you tested all those possibilities. I can't think of other situations now that are not covered.
I still added a few things to address below :)
.github/workflows/release_github.yml
Outdated
| if: ${{ github.ref_name != 'develop' }} | ||
| run: | | ||
| gh pr checks ${{ github.ref_name }} --watch --fail-fast | ||
| gh pr checks ${{ github.ref_name }} --json state -q 'if . | length == 0 then "No checks found." elif map(.state == "SUCCESS") | all then "All checks passed" else error("Not all checks passed") end' |
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.
is there a way to set the if length==0 then succeed?
I think it's rare, but can imagine minor changes that trigger no checks (e.g. because most checks are only triggered on certain file type changes). In that case, it seems like there are no ways to allow a release...
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.
Yes, this is possible (I implemented it at some point), but there are two reasons I didn't put it in the last version.
The main reason is that if you're fast enough after pushing changes to a PR, you can trigger the action before GitHub has detected that it should do checks. It will give an error that there were no checks for this branch. This happened to me once during testing the workflows.
If we would make it so it skips this when there are no checks, it could skip it unintentionally.
The second reason is that it's quite verbose, something like (thanks to ChatGPT):
if [ $exit_code -ne 0 ]; then
# Look for the specific error message
if echo "$output" | grep -q "no checks reported on "; then
echo "Caught the expected error: no checks reported on the branch"
# Handle the specific error here
else
# Re-raise other errors
echo "An unexpected error occurred: $output"
exit $exit_code
fi
else
echo "Command succeeded: $output"
# Handle success case here
fi
I don't think it's possible no check is triggered in the current repo. If there will be such a case, it is easy to add a simple check that always succeeds just to make sure that there is always a check to make this succeed.
| matrix: | ||
| os: ["ubuntu-latest"] |
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 don't think there's anything specific to linux in this package, right? Maybe it would be nice to add OSX and windows to the matrix as well, to ensure cross-platform compatibility?
| matrix: | |
| os: ["ubuntu-latest"] | |
| matrix: | |
| os: ["ubuntu-latest", "windows-latest", "macos-latest"] |
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.
Yes! And no. But mostly yes.
Doing all versions on all platforms is (unnecessarily?) expensive and slow. Should we test the lowest supported version on all platforms, and up to the newest supported version on linux?
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 given that it's only done rarely (upon release) it's fine to have a large matrix.
If you feel it's overkill, I would leave it like it was. I think it would create more confusion than clarity to create some versions on some platforms and all versions on another (plus would again become quite verbose).
| if: ${{ github.ref_name != 'develop' }} | ||
| run: gh pr view ${{ github.ref_name }} --json baseRefName -q 'if .baseRefName == "main" then "PR base is main" else error("PR base is not main") end' | ||
|
|
||
| - name: Check if PR is mergeable |
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.
Shouldn't this check happen here, also if the release branch is develop? See also this comment
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.
If the release branch is develop, there is no PR. This only works on PRs.
If the release branch is develop, there are no checks. These checks are done before PRs are merged into develop. As long as that is always the case, there are no checks required for develop.
Alternatively, we could also create a PR for merging develop into main. That would simplify this workflow a bit, but also add a step when creating a release. I don't dislike the idea, though. The workflow for making a release would change to:
- create PR (either from branch or develop)
- trigger action
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.
If the release branch is develop, there are no checks. These checks are done before PRs are merged into develop. As long as that is always the case, there are no checks required for develop.
I think there is no formal restriction for develop to have conflicts to main. This could either happen due to non-careful PR review, or e.g. after a hotfix was made directly to main.
Alternatively, we could also create a PR for merging develop into main. That would simplify this workflow a bit, but also add a step when creating a release. I don't dislike the idea, though. The workflow for making a release would change to:
- create PR (either from branch or develop)
- trigger action
I also like this workflow. Also makes things more 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.
Agreed. I implemented this in 379316b.
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.
in fact, the documentation already says to this: step 0 😉
On second thought, is this what we want? I think the most elegant solution (which is maybe too much effort to implement for the rare occurrence) would be to have an optional |
why only do all this if it's a hotfix branch, but not develop? |
There would be rare occasions where this is an issue. That is when develop contains changes that overlap with the hotfix. For example, when a fix is already merged with develop, but we don't want to make a full release of all changes to develop yet, so we want to merge a slightly different fix to main. This is so rare (hasn't occurred yet) that I don't think it's worth complicating this workflow for. |
This is a choice we made a while ago. I think our idea was: create PR, merge into develop (times x), then merge develop into main. Later we thought of hotfixes that should bypass this, creating the distinction. |
Is it at least worthwhile adding a note at the point where the action failed that this is the reason and that the merge+release should be done manually? Or is that also overkill? |
Good suggestion. Added in 388021a. |
- Check for a main branch first - Separate jobs for merging develop or a PR - Use gh CLI for merging PR - Bump version as separate job - Other small improvements
Co-authored-by: Dani Bodor <d.bodor@esciencecenter.nl>
When any step in this job fails, the repo is never pushed back. This should make sure the any failure will result in no actual changes to the repo.
388021a to
8bed368
Compare
This PR was extensively tested in a separate repo. This workflow update cleans up the workflow and more clearly splits merging a PR from merging develop. The main improvement is explicitly closing a PR using the gh CLI.
This supports either creating a release from develop -> main or from a branch associated with a PR -> main. If you select a branch with no PR associated, the merge PR job will fail.