diff --git a/.github/workflows-source/ci-main.yml b/.github/workflows-source/ci-main.yml index 1e940b5554c..e45a7a72d90 100644 --- a/.github/workflows-source/ci-main.yml +++ b/.github/workflows-source/ci-main.yml @@ -89,7 +89,6 @@ jobs: # Only run ci/bazel-scripts/diff.sh on PRs that are not labeled with "CI_ALL_BAZEL_TARGETS". OVERRIDE_DIDC_CHECK: ${{ contains(github.event.pull_request.labels.*.name, 'CI_OVERRIDE_DIDC_CHECK') }} CI_OVERRIDE_BUF_BREAKING: ${{ contains(github.event.pull_request.labels.*.name, 'CI_OVERRIDE_BUF_BREAKING') }} - RUN_ON_DIFF_ONLY: ${{ github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'CI_ALL_BAZEL_TARGETS') }} steps: - <<: *checkout - name: Set BAZEL_EXTRA_ARGS @@ -109,7 +108,7 @@ jobs: nns_tests_nightly ) if [[ "$CI_EVENT_NAME" =~ ^(pull_request|merge_group)$ ]]; then - if [[ "$CI_EVENT_NAME" == "merge_group" || "${RUN_ON_DIFF_ONLY:-}" == "true" ]]; then + if [[ "$CI_EVENT_NAME" == "merge_group" ]]; then EXCLUDED_TEST_TAGS+=(long_test) fi elif [[ "$CI_EVENT_NAME" == "push" ]] && [[ "$BRANCH_NAME" =~ ^dev-gh-.* ]]; then @@ -269,7 +268,6 @@ jobs: BAZEL_TARGETS: //... 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') }} - name: Upload SHA256SUMS (nocache) uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index 909bbd7b43e..c9549930e9a 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -44,7 +44,6 @@ jobs: # Only run ci/bazel-scripts/diff.sh on PRs that are not labeled with "CI_ALL_BAZEL_TARGETS". OVERRIDE_DIDC_CHECK: ${{ contains(github.event.pull_request.labels.*.name, 'CI_OVERRIDE_DIDC_CHECK') }} CI_OVERRIDE_BUF_BREAKING: ${{ contains(github.event.pull_request.labels.*.name, 'CI_OVERRIDE_BUF_BREAKING') }} - RUN_ON_DIFF_ONLY: ${{ github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'CI_ALL_BAZEL_TARGETS') }} steps: - name: Checkout uses: actions/checkout@v4 @@ -67,7 +66,7 @@ jobs: nns_tests_nightly ) if [[ "$CI_EVENT_NAME" =~ ^(pull_request|merge_group)$ ]]; then - if [[ "$CI_EVENT_NAME" == "merge_group" || "${RUN_ON_DIFF_ONLY:-}" == "true" ]]; then + if [[ "$CI_EVENT_NAME" == "merge_group" ]]; then EXCLUDED_TEST_TAGS+=(long_test) fi elif [[ "$CI_EVENT_NAME" == "push" ]] && [[ "$BRANCH_NAME" =~ ^dev-gh-.* ]]; then @@ -304,7 +303,6 @@ jobs: BAZEL_TARGETS: //... 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') }} - name: Upload SHA256SUMS (nocache) uses: actions/upload-artifact@v4 with: diff --git a/ci/bazel-scripts/diff.sh b/ci/bazel-scripts/diff.sh deleted file mode 100755 index a6395d07a9d..00000000000 --- a/ci/bazel-scripts/diff.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env bash - -# This script helps us only build bazel targets that have been affected by file -# changes in the branch merging to target branch. -# -# We get the list of files from the diff, query for the ones that are part of any bazel target, -# and then query for the targets that depend on these files. -# -# This scripts is inspired by https://github.com/bazelbuild/bazel/blob/master/scripts/ci/ci.sh - -set -euo pipefail - -set -x -cd "$(git rev-parse --show-toplevel)" - -MERGE_BASE="${MERGE_BASE_SHA:-HEAD}" -# we can't use HEAD here because that is the merge commit which contains the changes of the current HEAD of master -COMMIT_RANGE="$MERGE_BASE..${BRANCH_HEAD_SHA:-}" -DIFF_FILES=$(git diff --name-only "${COMMIT_RANGE}") - -if grep -qE "(.*\.bazel|.*\.bzl|\.bazelrc|\.bazelversion|mainnet-canister-revisions\.json|^\.github)" <<<"$DIFF_FILES"; then - echo "Changes detected in bazel files. Considering all targets." >&2 - echo ${BAZEL_TARGETS:-"//..."} - exit 0 -fi - -files=() -for file in $DIFF_FILES; do - if f="$(bazel query "$file")"; then - files+=("$f") - fi -done - -if grep -qE ".*\.sh" <<<"$DIFF_FILES"; then - files+=(//pre-commit:shfmt-check) -fi - -if grep -qE ".*\.py" <<<"$DIFF_FILES"; then - files+=(//pre-commit:ruff-lint) -fi - -if grep -qE ".*\.hs" <<<"$DIFF_FILES"; then - files+=(//pre-commit:ormolu-lint) -fi - -if grep -qE ".*\.proto" <<<"$DIFF_FILES"; then - files+=( - //pre-commit:protobuf-format-check - //pre-commit:buf-breaking - ) -fi - -if [ ${#files[@]} -eq 0 ]; then - echo "Changes not detected in bazel targets. No bazel targets to build or test." >&2 - exit 0 -fi - -if [[ $BAZEL_COMMAND =~ ^build[[:space:]] ]]; then - TARGETS=$(bazel query "rdeps(//..., set(${files[*]}))") -elif [[ $BAZEL_COMMAND =~ ^test[[:space:]] ]]; then - EXCLUDED_TAGS=(manual $EXCLUDED_TEST_TAGS) - EXCLUDED_TAGS=$( - IFS='|' - echo "${EXCLUDED_TAGS[*]}" - ) - TARGETS=$(bazel query "kind(test, rdeps(//..., set(${files[*]}))) except attr('tags', '$EXCLUDED_TAGS', //...)") -else - echo "Cannot infer command from BAZEL_COMMAND: ${BAZEL_COMMAND:-}" >&2 - exit 1 -fi - -echo "$TARGETS" | tr '\n' ' ' | sed -e 's/,$//' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -set +x diff --git a/ci/bazel-scripts/main.sh b/ci/bazel-scripts/main.sh index a91a08b2fa1..368fb576d34 100755 --- a/ci/bazel-scripts/main.sh +++ b/ci/bazel-scripts/main.sh @@ -23,16 +23,6 @@ done # (with versioning) if [[ "${IS_PROTECTED_BRANCH:-}" == "true" ]]; then release_build="true" - RUN_ON_DIFF_ONLY="false" -fi - -if [[ "${CI_EVENT_NAME:-}" == "merge_group" ]]; then - RUN_ON_DIFF_ONLY="false" -fi - -if [[ "${RUN_ON_DIFF_ONLY:-}" == "true" ]]; then - # get bazel targets that changed within the MR - BAZEL_TARGETS=$("${CI_PROJECT_DIR:-}"/ci/bazel-scripts/diff.sh) fi # if bazel targets is empty we don't need to run any tests diff --git a/ci/scripts/run-build-ic.sh b/ci/scripts/run-build-ic.sh index 0777b302869..0f85bddfdb5 100755 --- a/ci/scripts/run-build-ic.sh +++ b/ci/scripts/run-build-ic.sh @@ -18,35 +18,7 @@ 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 -# check if the job requested running only on diff, otherwise run full build with no release -elif [[ "${RUN_ON_DIFF_ONLY:-}" == "true" ]]; then - TARGETS=$(ci/bazel-scripts/diff.sh) - ARGS=(--no-release) - - if [ "$TARGETS" == "//..." ]; then - ARGS+=(-i -c -b) - else - if grep -q "ic-os" <<<"$TARGETS"; then - ARGS+=(-i) - fi - if grep -q "publish/canisters" <<<"$TARGETS"; then - ARGS+=(-c) - fi - if grep -q "publish/binaries" <<<"$TARGETS"; then - ARGS+=(-b) - fi - fi - - if [ ${#ARGS[@]} -eq 1 ]; then - if [ "${IS_PROTECTED_BRANCH:-}" == "true" ]; then - echo "Error: No changes to build on protected branch. Aborting." - exit 1 - fi - echo "No changes that require building IC-OS, binaries or canisters." - exit 0 - fi - ci/container/build-ic.sh "${ARGS[@]}" -# otherwise run full build but with no release +# otherwise build with no release else ci/container/build-ic.sh -i -c -b --no-release fi