-
Notifications
You must be signed in to change notification settings - Fork 334
Add make sanitize-pr
to github workflow.
#4765
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
base: develop
Are you sure you want to change the base?
Conversation
.github/workflows/build.yaml
Outdated
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.
Something is strange here: In line 25 we cd wire-docs
.
So, I'm under the impression that this job is about building the docs. Sanitizing the PR would in my head be a dedicated job - if we want to load stuff onto Github instead of Concourse (which I would endorse for simple stuff like this.)
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.
argh, you're right? thinking fast doesn't always mean thinking good... sorry, i'll try again!
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.
Thanks for taking care of our developer experience! However, this one might need a bit more thought 😸
b438b8b
to
8cf8a47
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.
Pull Request Overview
Adds execution of make sanitize-pr within the CI workflow to automatically apply PR sanitation rules.
- Introduces a new job step that clones the repository and runs make sanitize-pr
- Adds shell logic to derive the branch name from GITHUB_REF
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
CURRENT_REPO_URL="https://github.com/${GITHUB_REPOSITORY}.git" | ||
BRANCH_NAME=${GITHUB_REF##*/} | ||
git clone --branch develop "$CURRENT_REPO_URL" wire-server -b "$BRANCH_NAME" |
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.
The git clone command passes a second -b/--branch option after the destination directory, which git interprets as an extra argument and will fail (e.g. "fatal: repository '-b' does not exist"). Use a single --branch before the repo URL, or implement an explicit fallback. Example: git clone --branch "$BRANCH_NAME" "$CURRENT_REPO_URL" wire-server || git clone --branch develop "$CURRENT_REPO_URL" wire-server (with cleanup as needed).
git clone --branch develop "$CURRENT_REPO_URL" wire-server -b "$BRANCH_NAME" | |
# Try to clone with the PR branch, fall back to develop if it doesn't exist | |
if ! git clone --branch "$BRANCH_NAME" "$CURRENT_REPO_URL" wire-server; then | |
rm -rf wire-server | |
git clone --branch develop "$CURRENT_REPO_URL" wire-server | |
fi |
Copilot uses AI. Check for mistakes.
# if this fails, you need to run it on your PR and commit the changes it makes. | ||
run: | | ||
CURRENT_REPO_URL="https://github.com/${GITHUB_REPOSITORY}.git" | ||
BRANCH_NAME=${GITHUB_REF##*/} |
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.
Using ${GITHUB_REF##*/} will produce 'merge' for pull_request refs like refs/pull/123/merge, causing the subsequent clone to target a non-existent branch. Prefer GITHUB_HEAD_REF when the event is pull_request, falling back to GITHUB_REF for push events, e.g.: BRANCH_NAME="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}".
BRANCH_NAME=${GITHUB_REF##*/} | |
BRANCH_NAME="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" |
Copilot uses AI. Check for mistakes.
- name: Clone wire-server and `make sanitize-pr` | ||
# if this fails, you need to run it on your PR and commit the changes it makes. | ||
run: | | ||
CURRENT_REPO_URL="https://github.com/${GITHUB_REPOSITORY}.git" | ||
BRANCH_NAME=${GITHUB_REF##*/} | ||
git clone --branch develop "$CURRENT_REPO_URL" wire-server -b "$BRANCH_NAME" | ||
cd wire-server | ||
make sanitize-pr | ||
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.
This step reclones the same repository that has already been checked out earlier in the job, adding unnecessary network and I/O cost. You can run make sanitize-pr directly in the existing workspace (remove clone/cd) unless isolation is required; if isolation is needed, add a shallow clone (e.g. --depth 1) and fix the branch logic as noted.
- name: Clone wire-server and `make sanitize-pr` | |
# if this fails, you need to run it on your PR and commit the changes it makes. | |
run: | | |
CURRENT_REPO_URL="https://github.com/${GITHUB_REPOSITORY}.git" | |
BRANCH_NAME=${GITHUB_REF##*/} | |
git clone --branch develop "$CURRENT_REPO_URL" wire-server -b "$BRANCH_NAME" | |
cd wire-server | |
make sanitize-pr | |
- name: Run `make sanitize-pr` | |
# if this fails, you need to run it on your PR and commit the changes it makes. | |
run: | | |
make sanitize-pr |
Copilot uses AI. Check for mistakes.
Checklist
Add a new entry in an appropriate subdirectory ofchangelog.d