Skip to content

Commit 77bbdeb

Browse files
authored
ci(gha): enable minimal integration tests (#13855)
Add new tests to `google/cloud/storage` that do some minimal RPCs (write, read, and delete an object). These are intended to run as part of the GitHub Action builds. I chose storage for these tests because storage uses both REST and gRPC.
1 parent 86b0e85 commit 77bbdeb

15 files changed

Lines changed: 282 additions & 13 deletions

.github/workflows/macos-bazel.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ jobs:
3737
run: ci/gha/builds/macos-bazel.sh
3838
env:
3939
BAZEL_REMOTE_CACHE: https://storage.googleapis.com/cloud-cpp-gha-cache/bazel-cache/${{ matrix.os }}
40+
GHA_TEST_BUCKET: "gcs-grpc-team-cloud-cpp-testing-bucket"

.github/workflows/macos-cmake.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,4 @@ jobs:
128128
SCCACHE_GCS_RW_MODE: READ_WRITE
129129
SCCACHE_IGNORE_SERVER_IO_ERROR: 1
130130
VCPKG_BINARY_SOURCES: x-gcs,gs://cloud-cpp-gha-cache/vcpkg-cache/${{ matrix.os }},readwrite
131+
GHA_TEST_BUCKET: "gcs-grpc-team-cloud-cpp-testing-bucket"

.github/workflows/windows-bazel.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ jobs:
5555
ci/gha/builds/windows-bazel.sh ${{ matrix.compilation_mode }}
5656
env:
5757
BAZEL_REMOTE_CACHE: https://storage.googleapis.com/cloud-cpp-gha-cache/bazel-cache/${{ matrix.msvc }}/${{ matrix.compilation_mode }}
58+
GHA_TEST_BUCKET: "gcs-grpc-team-cloud-cpp-testing-bucket"

.github/workflows/windows-cmake.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,4 @@ jobs:
134134
SCCACHE_IGNORE_SERVER_IO_ERROR: 1
135135
VCPKG_BINARY_SOURCES: x-gcs,gs://cloud-cpp-gha-cache/vcpkg-cache/${{ matrix.msvc }},readwrite
136136
VCPKG_TRIPLET: ${{ matrix.arch }}-windows
137+
GHA_TEST_BUCKET: "gcs-grpc-team-cloud-cpp-testing-bucket"

ci/gha/builds/lib/bazel.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ function bazel::msvc_args() {
7676
printf "%s\n" "${args[@]}"
7777
}
7878

79+
# Outputs a list of args to use with integration tests
80+
function bazel::integration_test_args() {
81+
local args=(
82+
--flaky_test_attempts=3
83+
--test_tag_filters=integration-test-gha
84+
--test_env=GOOGLE_CLOUD_CPP_STORAGE_TEST_BUCKET_NAME="${GHA_TEST_BUCKET:-}"
85+
--test_env=GOOGLE_APPLICATION_CREDENTIALS="${GOOGLE_APPLICATION_CREDENTIALS:-}"
86+
--test_env=HOME="${HOME:-}"
87+
)
88+
printf "%s\n" "${args[@]}"
89+
}
90+
7991
# Bazel downloads all the dependencies of a project, as well as a number of
8092
# development tools during startup. In automated builds these downloads fail
8193
# from time to time due to transient network problems. Running `bazel fetch` at

ci/gha/builds/macos-bazel.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,27 @@
1717
set -euo pipefail
1818

1919
source "$(dirname "$0")/../../lib/init.sh"
20-
source module ci/gha/builds/lib/bazel.sh
2120
source module ci/gha/builds/lib/macos.sh
21+
# Define the os::* functions used in bazel.sh
22+
source module ci/gha/builds/lib/bazel.sh
2223
source module ci/lib/io.sh
2324

2425
# Usage: macos-bazel.sh
2526

2627
mapfile -t args < <(bazel::common_args)
2728
mapfile -t test_args < <(bazel::test_args)
28-
# Do not run the integration tests
29-
test_args+=(--test_tag_filters=-integration-test)
30-
TIMEFORMAT="==> 🕑 bazel test done in %R seconds"
29+
mapfile -t integration_test_args < <(bazel::integration_test_args)
3130

31+
TIMEFORMAT="==> 🕑 bazel test done in %R seconds"
3232
io::log_h1 "Starting Build"
3333
time {
34-
io::run bazelisk "${args[@]}" test "${test_args[@]}" //...
34+
io::run bazelisk "${args[@]}" test "${test_args[@]}" --test_tag_filters=-integration-test //...
3535
}
36+
37+
TIMEFORMAT="==> 🕑 Storage integration tests done in %R seconds"
38+
if [[ -n "${GHA_TEST_BUCKET:-}" ]]; then
39+
time {
40+
io::run bazelisk "${args[@]}" test "${test_args[@]}" "${integration_test_args[@]}" \
41+
//google/cloud/storage/tests/...
42+
}
43+
fi

ci/gha/builds/macos-cmake.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,12 @@ TIMEFORMAT="==> 🕑 CMake test done in %R seconds"
5151
time {
5252
io::run ctest "${ctest_args[@]}" --test-dir cmake-out -LE integration-test
5353
}
54+
55+
TIMEFORMAT="==> 🕑 Storage integration tests done in %R seconds"
56+
if [[ -n "${GHA_TEST_BUCKET:-}" ]]; then
57+
time {
58+
export GOOGLE_CLOUD_CPP_STORAGE_TEST_BUCKET_NAME="${GHA_TEST_BUCKET}"
59+
io::run ctest "${ctest_args[@]}" --repeat until-pass:3 \
60+
--test-dir cmake-out -L integration-test-gha
61+
}
62+
fi

ci/gha/builds/windows-bazel.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
set -euo pipefail
1818

1919
source "$(dirname "$0")/../../lib/init.sh"
20+
# Define the os::* functions used in bazel.sh
2021
source module ci/gha/builds/lib/windows.sh
2122
source module ci/gha/builds/lib/bazel.sh
2223

@@ -27,12 +28,11 @@ mapfile -t args < <(bazel::common_args)
2728
mapfile -t test_args < <(bazel::test_args)
2829
mapfile -t msvc_args < <(bazel::msvc_args)
2930
test_args+=("${msvc_args[@]}")
30-
# Do not run the integration tests
31-
test_args+=(--test_tag_filters=-integration-test)
3231
if [[ $# -gt 1 ]]; then
3332
test_args+=("--compilation_mode=${1}")
3433
shift
3534
fi
35+
mapfile -t integration_test_args < <(bazel::integration_test_args)
3636

3737
if [[ -z "${VCINSTALLDIR}" ]]; then
3838
echo "ERROR: Missing VCINSTALLDIR, this is needed to configure Bazel+MSVC"
@@ -43,7 +43,18 @@ export BAZEL_VC="${VCINSTALLDIR}"
4343
io::log_h1 "Starting Build"
4444
TIMEFORMAT="==> 🕑 bazel test done in %R seconds"
4545
time {
46-
# Always run //google/cloud:status_test in case the list of targets has
47-
# no unit tests.
48-
io::run bazelisk "${args[@]}" test "${test_args[@]}" -- //...
46+
io::run bazelisk "${args[@]}" test "${test_args[@]}" --test_tag_filters=-integration-test -- //...
4947
}
48+
49+
TIMEFORMAT="==> 🕑 Storage integration tests done in %R seconds"
50+
if [[ -n "${GHA_TEST_BUCKET:-}" ]]; then
51+
time {
52+
# gRPC requires a local roots.pem on Windows
53+
# https://github.com/grpc/grpc/issues/16571
54+
curl -fsSL -o "${HOME}/roots.pem" https://pki.google.com/roots.pem
55+
56+
io::run bazelisk "${args[@]}" test "${test_args[@]}" "${integration_test_args[@]}" \
57+
--test_env=GRPC_DEFAULT_SSL_ROOTS_FILE_PATH="${HOME}/roots.pem" \
58+
//google/cloud/storage/tests/...
59+
}
60+
fi

ci/gha/builds/windows-cmake.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,23 @@ fi
6767

6868
TIMEFORMAT="==> 🕑 CMake build done in %R seconds"
6969
time {
70-
# Always run //google/cloud:status_test in case the list of targets has
71-
# no unit tests.
7270
io::run cmake --build "${CMAKE_OUT}"
7371
}
7472

7573
TIMEFORMAT="==> 🕑 CMake test done in %R seconds"
7674
time {
7775
io::run ctest "${ctest_args[@]}" --test-dir "${CMAKE_OUT}" -LE integration-test
7876
}
77+
78+
TIMEFORMAT="==> 🕑 Storage integration tests done in %R seconds"
79+
if [[ -n "${GHA_TEST_BUCKET:-}" ]]; then
80+
time {
81+
# gRPC requires a local roots.pem on Windows
82+
# https://github.com/grpc/grpc/issues/16571
83+
curl -fsSL -o "${HOME}/roots.pem" https://pki.google.com/roots.pem
84+
export GRPC_DEFAULT_SSL_ROOTS_FILE_PATH="${HOME}/roots.pem"
85+
86+
export GOOGLE_CLOUD_CPP_STORAGE_TEST_BUCKET_NAME="${GHA_TEST_BUCKET}"
87+
io::run ctest "${ctest_args[@]}" --test-dir "${CMAKE_OUT}" -L integration-test-gha
88+
}
89+
fi

google/cloud/storage/tests/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ VARIATIONS = {
5454
tags = [
5555
"integration-test",
5656
"integration-test-" + v_label,
57-
],
57+
] + (["integration-test-gha"] if test.startswith("smoke_test") else []),
5858
deps = [
5959
":storage_conformance_tests_cc_proto",
6060
"//:common",

0 commit comments

Comments
 (0)