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

chore(IDX): use github.ref_protected where applicable #3936

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .github/actions/bazel-test-all/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ runs:
MERGE_BASE_SHA: ${{ github.event.pull_request.base.sha }}
SSH_PRIVATE_KEY_BACKUP_POD: ${{ inputs.SSH_PRIVATE_KEY_BACKUP_POD }}
GPG_PASSPHRASE: ${{ inputs.GPG_PASSPHRASE }}
IS_PROTECTED_BRANCH: ${{ github.ref_protected }}
Copy link
Member

Choose a reason for hiding this comment

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

@nmattia it looks like we had this logic before, but it didn't work as expected:

#1504

I think we would need to test this first to make sure this variable does show up as true on protected branches.

1 change: 1 addition & 0 deletions .github/workflows-source/ci-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ jobs:
MERGE_BASE_SHA: ${{ github.event.pull_request.base.sha }}
BRANCH_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
RUN_ON_DIFF_ONLY: ${{ github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'CI_ALL_BAZEL_TARGETS') }}
IS_PROTECTED_BRANCH: ${{ github.ref_protected }}
- name: Upload build-ic.tar
uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ jobs:
MERGE_BASE_SHA: ${{ github.event.pull_request.base.sha }}
BRANCH_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
RUN_ON_DIFF_ONLY: ${{ github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'CI_ALL_BAZEL_TARGETS') }}
IS_PROTECTED_BRANCH: ${{ github.ref_protected }}
- name: Upload build-ic.tar
uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/schedule-rust-bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ jobs:
CI_JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
RUST_BACKTRACE: "full"
TARGETS: ${{ matrix.targets }}
IS_PROTECTED_BRANCH: ${{ github.ref_protected }}
10 changes: 0 additions & 10 deletions ci/bazel-scripts/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ ic_version_rc_only="0000000000000000000000000000000000000000"
release_build="false"
s3_upload="False"

protected_branches=("master" "rc--*" "hotfix-*" "master-private")

# if we are on a protected branch or targeting a rc branch we set ic_version to the commit_sha and upload to s3
for pattern in "${protected_branches[@]}"; do
if [[ "$BRANCH_NAME" == $pattern ]]; then
IS_PROTECTED_BRANCH="true"
break
fi
done

Comment on lines -14 to -23
Copy link
Collaborator

@basvandijk basvandijk Feb 13, 2025

Choose a reason for hiding this comment

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

Unfortunately and confusingly setting IS_PROTECTED_BRANCH=${{ github.ref_protected }} as an alternative to the above is not enough.

In ic-private the hotifx-* branch is not protected. This means that if folks follow the "How to handle fixes for IC security vulnerabilities?" procedure, which specifies to push the hotfix to a hotfix-* branch and then expects the artifacts to be uploaded (s3_upload="True"), their artifacts won't be uploaded.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@basvandijk arguably this is an issue in ic-private where protected_branches is then not aptly named, and/or an issue with the hotfix procedure. I'll see what I can do about that.

Copy link
Collaborator

@basvandijk basvandijk Feb 13, 2025

Choose a reason for hiding this comment

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

Note that we shouldn't protect hotfix-* in ic-private since that would prevent folks from creating hotfixes.

So I think it's indeed a naming issue. Maybe we should use a different wordt than "PROTECTED" above.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe:

  • protected_branches -> release_branches
  • IS_PROTECTED_BRANCH -> IS_RELEASE_BRANCH

# if we are on a protected branch or targeting a rc branch we set release build, ic_version to the commit_sha and
# upload to s3
if [[ "${IS_PROTECTED_BRANCH:-}" == "true" ]] || [[ "${CI_PULL_REQUEST_TARGET_BRANCH_NAME:-}" == "rc--"* ]]; then
Expand Down
10 changes: 0 additions & 10 deletions ci/scripts/run-build-ic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@ VERSION=$(git rev-parse HEAD)

cd "$CI_PROJECT_DIR"

protected_branches=("master" "rc--*" "hotfix-*" "master-private")

# if we are on a protected branch or targeting a rc branch we set ic_version to the commit_sha and upload to s3
for pattern in "${protected_branches[@]}"; do
if [[ "$BRANCH_NAME" == $pattern ]]; then
IS_PROTECTED_BRANCH="true"
break
fi
done

# run build with release on protected branches or if a pull_request is targeting an rc branch
if [ "${IS_PROTECTED_BRANCH:-}" == "true" ] || [[ "${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-}" == "rc--"* ]]; then
ci/container/build-ic.sh -i -c -b
Expand Down