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

Never cancel branch builds for main and release branches #11750

Merged
merged 1 commit into from
Mar 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/cancel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ jobs:
name: Cancel
'on':
workflow_run:
branches-ignore:
- main
- 2.*.x
types:
- requested
workflows:
Expand Down
9 changes: 8 additions & 1 deletion build-support/bin/generate_github_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,14 @@ def generate() -> dict[Path, str]:
# Note that this job runs in the context of the default branch, so its token
# has permission to cancel workflows (i.e., it is not the PR's read-only token).
"name": "Cancel",
"on": {"workflow_run": {"workflows": [test_workflow_name], "types": ["requested"]}},
"on": {
"workflow_run": {
"workflows": [test_workflow_name],
"types": ["requested"],
# Never cancel branch builds for `main` and release branches.
"branches-ignore": ["main", "2.*.x"],
}
},
"jobs": {
"cancel": {
"runs-on": "ubuntu-latest",
Expand Down
16 changes: 4 additions & 12 deletions build-support/githooks/prepare-commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ MERGE_BASE="$(git_merge_base)"
# new build.
CHANGED_FILES="$(git diff --name-only "${MERGE_BASE}")"

NUM_NON_MD_FILES=$(echo "${CHANGED_FILES})" | grep -c -v ".\md$")

# Ensure that this stays in sync with `build-support/bin/rust/calculate_engine_hash.sh`.
NUM_RUST_FILES=$(echo "${CHANGED_FILES})" | grep -c -E \
-e "^src/rust/engine" \
-e "^rust-toolchain" \
-e "^build-support/bin/rust" \
-e "^build-support/bin/generate_travis_yml.py")
-e "^build-support/bin/generate_travis_yml.py" \
-e "^build-support/bin/generate_github_workflows.py")
Comment on lines 20 to +25
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I want to replace this with GitHub Action's first-class support for this, but in the meantime..


NUM_RELEASE_FILES=$(echo "${CHANGED_FILES})" | grep -c -E \
-e "^src/python/pants/VERSION" \
-e "^src/python/pants/notes" \
-e "^src/rust/engine/fs/fs_util" \
-e "^build-support/bin/release.sh" \
-e "^build-support/bin/packages.py" \
-e "^build-support/bin/generate_travis_yml.py")
-e "^build-support/bin/generate_travis_yml.py" \
-e "^build-support/bin/generate_github_workflows.py")

# To avoid putting skip labels multiple times, check if the labels already exist
# in the commit message.
Expand All @@ -42,14 +42,6 @@ HAS_RUST_SKIP=$?
grep "\[ci skip-build-wheels\]" "${COMMIT_MSG_FILEPATH}" > /dev/null
HAS_WHEELS_SKIP=$?

if [[ "${HAS_CI_SKIP}" -eq 1 ]] && [ "${NUM_NON_MD_FILES}" -eq 0 ]; then
cat <<EOF >> "${COMMIT_MSG_FILEPATH}"

# All CI will be skipped. Delete if not intended.
[ci skip]
EOF
fi
Comment on lines -45 to -51
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unconsumed in GitHub config. Also we rarely update .md files anymore, so not really relevant.


if [[ "${HAS_RUST_SKIP}" -eq 1 ]] && [ "${NUM_RUST_FILES}" -eq 0 ]; then
cat <<EOF >> "${COMMIT_MSG_FILEPATH}"

Expand Down