From 364c256bb20defdbcf53c8237bf8369a6cd8645b Mon Sep 17 00:00:00 2001 From: Noah Dietz Date: Thu, 19 Feb 2026 09:48:15 -0800 Subject: [PATCH] chore(ci): enable workflows and scripts on preview (#15581) --- .github/workflows/docs.yml | 5 +++++ .github/workflows/lint.yml | 4 ++++ .github/workflows/unittest.yml | 4 ++++ ci/run_conditional_tests.sh | 13 +++++++------ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index f7317674b360..62fe3f2b6105 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -2,6 +2,7 @@ on: pull_request: branches: - main + - preview # Trigger workflow on GitHub merge queue events # See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#merge_group merge_group: @@ -62,6 +63,7 @@ jobs: - name: Run docs env: BUILD_TYPE: presubmit + TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }} TEST_TYPE: docs # TODO(https://github.com/googleapis/google-cloud-python/issues/13775): Specify `PY_VERSION` rather than relying on the default python version of the nox session. PY_VERSION: "unused" @@ -91,6 +93,7 @@ jobs: - name: Run docs env: BUILD_TYPE: presubmit + TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }} TEST_TYPE: docs # TODO(https://github.com/googleapis/google-cloud-python/issues/13775): Specify `PY_VERSION` rather than relying on the default python version of the nox session. PY_VERSION: "unused" @@ -118,6 +121,7 @@ jobs: - name: Run docfx env: BUILD_TYPE: presubmit + TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }} TEST_TYPE: docfx # TODO(https://github.com/googleapis/google-cloud-python/issues/13775): Specify `PY_VERSION` rather than relying on the default python version of the nox session. PY_VERSION: "unused" @@ -147,6 +151,7 @@ jobs: - name: Run docfx env: BUILD_TYPE: presubmit + TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }} TEST_TYPE: docfx # TODO(https://github.com/googleapis/google-cloud-python/issues/13775): Specify `PY_VERSION` rather than relying on the default python version of the nox session. PY_VERSION: "unused" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5ae1548efbef..690664b22769 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,6 +2,7 @@ on: pull_request: branches: - main + - preview # Trigger workflow on GitHub merge queue events # See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#merge_group merge_group: @@ -33,6 +34,7 @@ jobs: - name: Run lint env: BUILD_TYPE: presubmit + TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }} TEST_TYPE: lint # TODO(https://github.com/googleapis/google-cloud-python/issues/13775): Specify `PY_VERSION` rather than relying on the default python version of the nox session. PY_VERSION: "unused" @@ -41,6 +43,7 @@ jobs: - name: Run lint_setup_py env: BUILD_TYPE: presubmit + TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }} TEST_TYPE: lint_setup_py # TODO(https://github.com/googleapis/google-cloud-python/issues/13775): Specify `PY_VERSION` rather than relying on the default python version of the nox session. PY_VERSION: "unused" @@ -67,6 +70,7 @@ jobs: - name: Run mypy env: BUILD_TYPE: presubmit + TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }} TEST_TYPE: mypy # TODO(https://github.com/googleapis/google-cloud-python/issues/13775): Specify `PY_VERSION` rather than relying on the default python version of the nox session. PY_VERSION: "unused" diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index c7d2fe26f44b..d783dca883ff 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -2,6 +2,7 @@ on: pull_request: branches: - main + - preview # Trigger workflow on GitHub merge queue events # See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#merge_group merge_group: @@ -40,6 +41,7 @@ jobs: env: COVERAGE_FILE: .coverage-${{ matrix.python }} BUILD_TYPE: presubmit + TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }} TEST_TYPE: unit PY_VERSION: ${{ matrix.python }} run: | @@ -76,6 +78,7 @@ jobs: - name: Run ${{ matrix.option }} tests env: BUILD_TYPE: presubmit + TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }} TEST_TYPE: ${{ matrix.option }} # TODO(https://github.com/googleapis/google-cloud-python/issues/13775): Specify `PY_VERSION` rather than relying on the default python version of the nox session. PY_VERSION: "unused" @@ -107,6 +110,7 @@ jobs: - name: Run ${{ matrix.option }} tests env: BUILD_TYPE: presubmit + TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }} TEST_TYPE: ${{ matrix.option }} # TODO(https://github.com/googleapis/google-cloud-python/issues/13775): Specify `PY_VERSION` rather than relying on the default python version of the nox session. PY_VERSION: "unused" diff --git a/ci/run_conditional_tests.sh b/ci/run_conditional_tests.sh index 91e34a6de1e3..d7a62a999ed2 100755 --- a/ci/run_conditional_tests.sh +++ b/ci/run_conditional_tests.sh @@ -34,25 +34,26 @@ set -eo pipefail export PROJECT_ROOT=$(realpath $(dirname "${BASH_SOURCE[0]}")/..) +TARGET_BRANCH="${TARGET_BRANCH:-main}" # A script file for running the test in a sub project. test_script="${PROJECT_ROOT}/ci/run_single_test.sh" -if [ ${BUILD_TYPE} == "presubmit" ]; then +if [[ ${BUILD_TYPE} == "presubmit" ]]; then # For presubmit build, we want to know the difference from the - # common commit in origin/main. - GIT_DIFF_ARG="origin/main..." + # common commit in the target branch. + GIT_DIFF_ARG="origin/$TARGET_BRANCH..." # Then fetch enough history for finding the common commit. - git fetch origin main --deepen=200 + git fetch origin "$TARGET_BRANCH" --deepen=200 -elif [ ${BUILD_TYPE} == "continuous" ]; then +elif [[ ${BUILD_TYPE} == "continuous" ]]; then # For continuous build, we want to know the difference in the last # commit. This assumes we use squash commit when merging PRs. GIT_DIFF_ARG="HEAD~.." # Then fetch one last commit for getting the diff. - git fetch origin main --deepen=1 + git fetch origin "$TARGET_BRANCH" --deepen=1 else # Run everything.