Skip to content

Commit 2cfca1c

Browse files
authored
chore(ci): enable workflows and scripts on preview (googleapis#15581)
1 parent 317d87b commit 2cfca1c

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

.github/workflows/docs.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ on:
22
pull_request:
33
branches:
44
- main
5+
- preview
56
# Trigger workflow on GitHub merge queue events
67
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#merge_group
78
merge_group:
@@ -62,6 +63,7 @@ jobs:
6263
- name: Run docs
6364
env:
6465
BUILD_TYPE: presubmit
66+
TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }}
6567
TEST_TYPE: docs
6668
# 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.
6769
PY_VERSION: "unused"
@@ -91,6 +93,7 @@ jobs:
9193
- name: Run docs
9294
env:
9395
BUILD_TYPE: presubmit
96+
TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }}
9497
TEST_TYPE: docs
9598
# 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.
9699
PY_VERSION: "unused"
@@ -118,6 +121,7 @@ jobs:
118121
- name: Run docfx
119122
env:
120123
BUILD_TYPE: presubmit
124+
TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }}
121125
TEST_TYPE: docfx
122126
# 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.
123127
PY_VERSION: "unused"
@@ -147,6 +151,7 @@ jobs:
147151
- name: Run docfx
148152
env:
149153
BUILD_TYPE: presubmit
154+
TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }}
150155
TEST_TYPE: docfx
151156
# 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.
152157
PY_VERSION: "unused"

.github/workflows/lint.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ on:
22
pull_request:
33
branches:
44
- main
5+
- preview
56
# Trigger workflow on GitHub merge queue events
67
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#merge_group
78
merge_group:
@@ -33,6 +34,7 @@ jobs:
3334
- name: Run lint
3435
env:
3536
BUILD_TYPE: presubmit
37+
TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }}
3638
TEST_TYPE: lint
3739
# 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.
3840
PY_VERSION: "unused"
@@ -41,6 +43,7 @@ jobs:
4143
- name: Run lint_setup_py
4244
env:
4345
BUILD_TYPE: presubmit
46+
TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }}
4447
TEST_TYPE: lint_setup_py
4548
# 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.
4649
PY_VERSION: "unused"
@@ -67,6 +70,7 @@ jobs:
6770
- name: Run mypy
6871
env:
6972
BUILD_TYPE: presubmit
73+
TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }}
7074
TEST_TYPE: mypy
7175
# 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.
7276
PY_VERSION: "unused"

.github/workflows/unittest.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ on:
22
pull_request:
33
branches:
44
- main
5+
- preview
56
# Trigger workflow on GitHub merge queue events
67
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#merge_group
78
merge_group:
@@ -40,6 +41,7 @@ jobs:
4041
env:
4142
COVERAGE_FILE: .coverage-${{ matrix.python }}
4243
BUILD_TYPE: presubmit
44+
TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }}
4345
TEST_TYPE: unit
4446
PY_VERSION: ${{ matrix.python }}
4547
run: |
@@ -76,6 +78,7 @@ jobs:
7678
- name: Run ${{ matrix.option }} tests
7779
env:
7880
BUILD_TYPE: presubmit
81+
TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }}
7982
TEST_TYPE: ${{ matrix.option }}
8083
# 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.
8184
PY_VERSION: "unused"
@@ -107,6 +110,7 @@ jobs:
107110
- name: Run ${{ matrix.option }} tests
108111
env:
109112
BUILD_TYPE: presubmit
113+
TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }}
110114
TEST_TYPE: ${{ matrix.option }}
111115
# 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.
112116
PY_VERSION: "unused"

ci/run_conditional_tests.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,26 @@
3434
set -eo pipefail
3535

3636
export PROJECT_ROOT=$(realpath $(dirname "${BASH_SOURCE[0]}")/..)
37+
TARGET_BRANCH="${TARGET_BRANCH:-main}"
3738

3839
# A script file for running the test in a sub project.
3940
test_script="${PROJECT_ROOT}/ci/run_single_test.sh"
4041

41-
if [ ${BUILD_TYPE} == "presubmit" ]; then
42+
if [[ ${BUILD_TYPE} == "presubmit" ]]; then
4243
# For presubmit build, we want to know the difference from the
43-
# common commit in origin/main.
44-
GIT_DIFF_ARG="origin/main..."
44+
# common commit in the target branch.
45+
GIT_DIFF_ARG="origin/$TARGET_BRANCH..."
4546

4647
# Then fetch enough history for finding the common commit.
47-
git fetch origin main --deepen=200
48+
git fetch origin "$TARGET_BRANCH" --deepen=200
4849

49-
elif [ ${BUILD_TYPE} == "continuous" ]; then
50+
elif [[ ${BUILD_TYPE} == "continuous" ]]; then
5051
# For continuous build, we want to know the difference in the last
5152
# commit. This assumes we use squash commit when merging PRs.
5253
GIT_DIFF_ARG="HEAD~.."
5354

5455
# Then fetch one last commit for getting the diff.
55-
git fetch origin main --deepen=1
56+
git fetch origin "$TARGET_BRANCH" --deepen=1
5657

5758
else
5859
# Run everything.

0 commit comments

Comments
 (0)