Skip to content

Commit 6c1be8b

Browse files
committed
added github tag to test all packages
1 parent e34b654 commit 6c1be8b

14 files changed

Lines changed: 30 additions & 16 deletions

File tree

.github/workflows/unittest.yml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,20 @@ jobs:
1717
runs-on: ubuntu-latest
1818
outputs:
1919
matrix: ${{ steps.set-matrix.outputs.matrix }}
20+
is_full_run: ${{ steps.check-label.outputs.is_full_run }}
2021
steps:
2122
- name: Checkout
2223
uses: actions/checkout@v4
2324
with:
2425
fetch-depth: 0
26+
- name: Check for unit_test:all_packages label
27+
id: check-label
28+
run: |
29+
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'unit_test:all_packages') }}" == "true" ]]; then
30+
echo "is_full_run=true" >> $GITHUB_OUTPUT
31+
else
32+
echo "is_full_run=false" >> $GITHUB_OUTPUT
33+
fi
2534
- name: Setup Python
2635
uses: actions/setup-python@v5
2736
with:
@@ -31,6 +40,7 @@ jobs:
3140
env:
3241
BUILD_TYPE: presubmit
3342
TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }}
43+
TEST_ALL_PACKAGES: ${{ steps.check-label.outputs.is_full_run }}
3444
run: |
3545
if [ -n "$TARGET_BRANCH" ]; then
3646
git fetch origin "$TARGET_BRANCH" --deepen=200 || true
@@ -102,6 +112,7 @@ jobs:
102112
runs-on: ubuntu-latest
103113
needs:
104114
- unit
115+
- initialize
105116
steps:
106117
- name: Checkout
107118
uses: actions/checkout@v4
@@ -116,10 +127,16 @@ jobs:
116127
python-version: "3.10"
117128
- name: Set number of files changes in packages directory
118129
id: packages
130+
env:
131+
TEST_ALL_PACKAGES: ${{ needs.initialize.outputs.is_full_run }}
119132
run: |
120-
git diff HEAD~1 -- packages > /dev/null
121-
num_files_changed=$(git diff HEAD~1 -- packages | wc -l | tr -d ' ')
122-
echo "num_files_changed=${num_files_changed}" >> "$GITHUB_OUTPUT"
133+
if [[ "${TEST_ALL_PACKAGES}" == "true" ]]; then
134+
echo "num_files_changed=1" >> "$GITHUB_OUTPUT"
135+
else
136+
git diff HEAD~1 -- packages > /dev/null
137+
num_files_changed=$(git diff HEAD~1 -- packages | wc -l | tr -d ' ')
138+
echo "num_files_changed=${num_files_changed}" >> "$GITHUB_OUTPUT"
139+
fi
123140
- name: Install coverage
124141
if: ${{ steps.packages.outputs.num_files_changed > 0 }}
125142
run: |
@@ -136,6 +153,7 @@ jobs:
136153
# TODO: default to 100% coverage after next gapic-generator release
137154
# https://github.com/googleapis/google-cloud-python/issues/17459
138155
DEFAULT_FAIL_UNDER: 99
156+
TEST_ALL_PACKAGES: ${{ needs.initialize.outputs.is_full_run }}
139157
run: |
140158
if [ -d .coverage-results ]; then
141159
# Unzip any zipped coverage results
@@ -152,7 +170,11 @@ jobs:
152170
fi
153171
154172
# Find all modified packages
155-
modified_packages=$(git diff --name-only HEAD~1 -- packages | cut -d/ -f1,2 | sort -u)
173+
if [[ "${TEST_ALL_PACKAGES}" == "true" ]]; then
174+
modified_packages=$(ls -d packages/*/ | cut -d/ -f1,2 | sort -u)
175+
else
176+
modified_packages=$(git diff --name-only HEAD~1 -- packages | cut -d/ -f1,2 | sort -u)
177+
fi
156178
157179
failed_packages=()
158180
passed_packages=()

ci/get_package_shards.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ def get_packages():
1818
def get_packages_to_test():
1919
build_type = os.environ.get('BUILD_TYPE', 'presubmit')
2020
target_branch = os.environ.get('TARGET_BRANCH', 'main')
21+
test_all_packages = os.environ.get('TEST_ALL_PACKAGES', 'false').lower() == 'true'
2122

2223
all_packages = get_packages()
2324

25+
if test_all_packages:
26+
return all_packages
27+
2428
if build_type == 'presubmit':
2529
git_diff_arg = f"origin/{target_branch}..."
2630
elif build_type == 'continuous':

packages/google-backstory/SHARD_TEST.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/google-cloud-apiregistry/SHARD_TEST.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/google-cloud-bigtable/SHARD_TEST.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/google-cloud-ces/SHARD_TEST.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/google-cloud-chronicle/SHARD_TEST.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/google-cloud-dataproc/SHARD_TEST.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/google-cloud-firestore/SHARD_TEST.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/google-cloud-gke-multicloud/SHARD_TEST.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)