-
Notifications
You must be signed in to change notification settings - Fork 698
chore: test sharding with one package #9027
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
Closed
+254
−66
Closed
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
5da7791
feat(ci): run unit-tests in parallel to speed them up
bshaffer 0d9eb53
chore(ci): reduce unit-test output due to log truncation
bshaffer 6a14237
chore(ci): rename conformance tests for clarity
bshaffer 740552b
chore: run all ci tests
bshaffer 3d37a2c
fix(ci): failing unit-tests
bshaffer 24763d2
feat(ci): add matrix sharding
bshaffer 0c5f19a
fix bash syntax error, better job names
bshaffer 5b0a4a4
reduce fetch-depth for github actions runs, remove concurrency
bshaffer 37e6bcf
remove c8 text output
bshaffer dd49119
feat: add conditional sharding using DRY_RUN_SHARDS envvar
bshaffer 90754d4
fix(ci): common and pack-and-play tests
bshaffer e42dd27
Revert "remove c8 text output" - we will handle this in a future PR
bshaffer f12544e
add parent job for unit test shards (by node version), remove firesto…
bshaffer 9d358d3
add dummy shards and extend test timeout for windows
bshaffer 127374f
improve bigtable unit-test performance
bshaffer 9ebd7db
increase timeout to 10 minutes for windows tests
bshaffer ce4850e
fix bigtable-system-tests
bshaffer cb703c9
skip pack-n-play tests on windows
bshaffer 52cbb6c
skip trigger for running all tests
bshaffer 3960dab
modify google-cloud-vision to run tests in only one component
bshaffer 0240ec2
fix bigtable unit tests
bshaffer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,25 +31,27 @@ fi | |||||||||||||||||||||
| test_script="${PROJECT_ROOT}/ci/run_single_test.sh" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| 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..." | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Then fetch enough history for finding the common commit. | ||||||||||||||||||||||
| git fetch origin main --deepen=300 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| 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 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| else | ||||||||||||||||||||||
| # Run everything. | ||||||||||||||||||||||
| GIT_DIFF_ARG="" | ||||||||||||||||||||||
| if [ -z "${GIT_DIFF_ARG}" ]; 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..." | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Then fetch enough history for finding the common commit. | ||||||||||||||||||||||
| git fetch origin main --deepen=300 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| 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 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| else | ||||||||||||||||||||||
| # Run everything. | ||||||||||||||||||||||
| GIT_DIFF_ARG="" | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Then detect changes in the test scripts. | ||||||||||||||||||||||
|
|
@@ -62,10 +64,10 @@ if [[ "${changed}" -eq 0 ]]; then | |||||||||||||||||||||
| echo "no change detected in ci" | ||||||||||||||||||||||
| else | ||||||||||||||||||||||
| echo "skipping trigger of tests for now: tracking in #7540" | ||||||||||||||||||||||
| # echo "change detected in ci, we should test everything" | ||||||||||||||||||||||
| # echo "result of git diff ${GIT_DIFF_ARG} ci:" | ||||||||||||||||||||||
| # git diff ${GIT_DIFF_ARG} ci | ||||||||||||||||||||||
| # GIT_DIFF_ARG="" | ||||||||||||||||||||||
| #echo "change detected in ci, we should test everything" | ||||||||||||||||||||||
| #echo "result of git diff ${GIT_DIFF_ARG} ci:" | ||||||||||||||||||||||
| #git diff ${GIT_DIFF_ARG} ci | ||||||||||||||||||||||
| #GIT_DIFF_ARG="" | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Now we have a fixed list, but we can change it to autodetect if | ||||||||||||||||||||||
|
|
@@ -82,18 +84,21 @@ subdirs=( | |||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| RETVAL=0 | ||||||||||||||||||||||
| # These following APIs need an explicit credential file to run properly (or oAuth2, which we don't support in this repo). | ||||||||||||||||||||||
| # These following APIs need an explicit credential file to run properly (or oAuth2, which we don't support in this repo). | ||||||||||||||||||||||
| # When we hit these packages, we will run the "samples with credentials" trigger, which contains the credentials as an env variable | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| tests_with_credentials="core/packages/google-auth-library-nodejs/ packages/google-analytics-admin/ packages/google-area120-tables/ packages/google-analytics-data/ packages/google-iam-credentials/ packages/google-apps-meet/ packages/google-chat/ packages/google-streetview-publish/ packages/google-cloud-developerconnect/" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Some packages are only used by our bots and automation. These packages do not need to run on Windows and | ||||||||||||||||||||||
| # often employ platform specific code like file system interaction. Some packages may also fail | ||||||||||||||||||||||
| # on Windows due to incompatible npm scripts. | ||||||||||||||||||||||
| # | ||||||||||||||||||||||
| # | ||||||||||||||||||||||
| # Until these packages can be updated to be OS agnostic, we will skip them on Windows. | ||||||||||||||||||||||
| windows_exempt_tests="core/ core/packages/ core/dev-packages/ .github/scripts/fixtures/ .github/scripts/tests/ core/packages/gapic-node-processing/ core/packages/typeless-sample-bot/ handwritten/cloud-profiler/" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Gather all test directories into an array | ||||||||||||||||||||||
| test_dirs=() | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| for subdir in ${subdirs[@]}; do | ||||||||||||||||||||||
| for d in `ls -d ${subdir}/*/`; do | ||||||||||||||||||||||
| if [ -s "ignore.json" ] && jq -e ".ignored[] | select(. == \"$d\")" ignore.json > /dev/null 2>&1; then | ||||||||||||||||||||||
|
|
@@ -116,7 +121,7 @@ for subdir in ${subdirs[@]}; do | |||||||||||||||||||||
| # System tests for packages are broken and blocking PRs. | ||||||||||||||||||||||
| # See https://github.com/googleapis/google-cloud-node/issues/7976. | ||||||||||||||||||||||
| # | ||||||||||||||||||||||
| # Per https://github.com/googleapis/google-cloud-node/issues/7921, | ||||||||||||||||||||||
| # Per https://github.com/googleapis/google-cloud-node/issues/7921, | ||||||||||||||||||||||
| # we are likely to permanently remove these tests in the near future. | ||||||||||||||||||||||
| if [[ "${subdir}" == "packages" && "${TEST_TYPE}" == "system" ]]; then | ||||||||||||||||||||||
| echo "Skipping ${TEST_TYPE} test for packages: ${d}" | ||||||||||||||||||||||
|
|
@@ -126,7 +131,7 @@ for subdir in ${subdirs[@]}; do | |||||||||||||||||||||
| # Sample tests for packages are broken/flaky and blocking PRs. | ||||||||||||||||||||||
| # See https://github.com/googleapis/google-cloud-node/issues/7976#issuecomment-4210458096. | ||||||||||||||||||||||
| # | ||||||||||||||||||||||
| # Per https://github.com/googleapis/google-cloud-node/issues/7921, | ||||||||||||||||||||||
| # Per https://github.com/googleapis/google-cloud-node/issues/7921, | ||||||||||||||||||||||
| # we are likely to permanently remove these tests in the near future. | ||||||||||||||||||||||
| if [[ "${subdir}" == "packages" && "${TEST_TYPE}" == "samples" ]]; then | ||||||||||||||||||||||
| echo "Skipping ${TEST_TYPE} test for packages: ${d}" | ||||||||||||||||||||||
|
|
@@ -204,21 +209,44 @@ for subdir in ${subdirs[@]}; do | |||||||||||||||||||||
| fi | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
| if [ "${should_test}" = true ]; then | ||||||||||||||||||||||
| echo "running test in ${d}" | ||||||||||||||||||||||
| pushd ${d} | ||||||||||||||||||||||
| # Temporarily allow failure. | ||||||||||||||||||||||
| set +e | ||||||||||||||||||||||
| ${test_script} | ||||||||||||||||||||||
| ret=$? | ||||||||||||||||||||||
| set -e | ||||||||||||||||||||||
| if [ ${ret} -ne 0 ]; then | ||||||||||||||||||||||
| RETVAL=${ret} | ||||||||||||||||||||||
| # Since there are so many APIs, we should exit early if there's an error | ||||||||||||||||||||||
| exit ${RETVAL} | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
| popd | ||||||||||||||||||||||
| test_dirs+=("${d}") | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
| done | ||||||||||||||||||||||
| done | ||||||||||||||||||||||
| # If DRY_RUN_SHARDS is set, output dynamic matrix values to GitHub Actions and exit | ||||||||||||||||||||||
| if [[ "${DRY_RUN_SHARDS}" == "true" ]]; then | ||||||||||||||||||||||
| count=${#test_dirs[@]} | ||||||||||||||||||||||
| if [[ $count -gt 15 ]]; then | ||||||||||||||||||||||
| echo "shard_matrix=[0, 1, 2, 3, 4]" >> $GITHUB_OUTPUT | ||||||||||||||||||||||
| echo "shard_total=5" >> $GITHUB_OUTPUT | ||||||||||||||||||||||
| else | ||||||||||||||||||||||
| echo "shard_matrix=[0]" >> $GITHUB_OUTPUT | ||||||||||||||||||||||
| echo "shard_total=1" >> $GITHUB_OUTPUT | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # If SHARD_TOTAL and SHARD_INDEX are provided, we will only run a subset of the tests. | ||||||||||||||||||||||
| for i in "${!test_dirs[@]}"; do | ||||||||||||||||||||||
| d="${test_dirs[$i]}" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if [[ -n "${SHARD_TOTAL}" && -n "${SHARD_INDEX}" ]]; then | ||||||||||||||||||||||
| if (( i % SHARD_TOTAL != SHARD_INDEX )); then | ||||||||||||||||||||||
| continue | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
Comment on lines
+233
to
+237
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| echo "running test in ${d}" | ||||||||||||||||||||||
| pushd ${d} >/dev/null | ||||||||||||||||||||||
| # Temporarily allow failure. | ||||||||||||||||||||||
| set +e | ||||||||||||||||||||||
| ${test_script} | ||||||||||||||||||||||
| ret=$? | ||||||||||||||||||||||
| set -e | ||||||||||||||||||||||
| if [ ${ret} -ne 0 ]; then | ||||||||||||||||||||||
| exit ${ret} | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
| popd >/dev/null | ||||||||||||||||||||||
| done | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| exit ${RETVAL} | ||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
$GITHUB_OUTPUTis unset or empty (for example, when running the script locally or in a non-GitHub Actions environment), redirecting to it via>> $GITHUB_OUTPUTwill fail with anambiguous redirecterror. Checking if the variable is set before redirecting prevents this failure.