Skip to content

Commit 3cda322

Browse files
authored
ci: update external account integration test to use bazel (googleapis#16137)
1 parent 0d6909f commit 3cda322

2 files changed

Lines changed: 26 additions & 73 deletions

File tree

.github/workflows/external-account-integration.yml

Lines changed: 18 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
required: true
88
description: "The ref we want to compile"
99
type: string
10+
push:
11+
branches:
12+
- "ci-gha-*"
1013

1114
permissions:
1215
contents: read
@@ -28,56 +31,25 @@ jobs:
2831
steps:
2932
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
3033
with:
31-
ref: ${{ inputs.checkout-ref }}
32-
- id: auth
33-
uses: google-github-actions/auth@v2
34-
with:
35-
create_credentials_file: true
36-
credentials_json: ${{ secrets.BUILD_CACHE_KEY }}
37-
- name: Set up Cloud SDK
38-
uses: google-github-actions/setup-gcloud@v2
39-
- name: vcpkg-version
40-
id: vcpkg-version
41-
run: |
42-
echo "version=$(cat ci/etc/vcpkg-version.txt)" >> "${GITHUB_OUTPUT}"
43-
shell: bash
44-
- name: install ninja and CMake
45-
run: |
46-
rm /usr/local/bin/cmake
47-
sudo apt install ninja-build cmake
48-
- name: download-sccache
49-
working-directory: "${{runner.temp}}"
50-
run: |
51-
curl -fsSL https://github.com/mozilla/sccache/releases/download/v0.7.1/sccache-v0.7.1-x86_64-unknown-linux-musl.tar.gz | \
52-
tar -zxf - --strip-components=1 && \
53-
sudo mv sccache /usr/bin/sccache && \
54-
sudo chmod +x /usr/bin/sccache
55-
- name: download-vcpkg
56-
working-directory: "${{runner.temp}}"
57-
run: |
58-
mkdir -p vcpkg
59-
curl -fsSL "https://github.com/microsoft/vcpkg/archive/${STEPS_VCPKG_VERSION_OUTPUTS_VERSION}.tar.gz" |
60-
tar -C vcpkg --strip-components=1 -zxf -
61-
vcpkg/bootstrap-vcpkg.sh -disableMetrics
62-
env:
63-
STEPS_VCPKG_VERSION_OUTPUTS_VERSION: ${{ steps.vcpkg-version.outputs.version }}
64-
# First compile the code using the identity with access to the build cache
65-
- run: |
66-
env VCPKG_ROOT="${{ runner.temp }}/vcpkg" ci/gha/builds/external-account.sh
67-
# Then switch to the BYOID identity and run the integration test
34+
ref: ${{ inputs.checkout-ref || github.sha }}
35+
# Use BYOID identity and run the integration test
6836
- id: byoid-auth
6937
if: '!github.event.pull_request.head.repo.fork'
7038
name: 'Authenticate to GCP'
71-
uses: 'google-github-actions/auth@v2'
39+
uses: 'google-github-actions/auth@v3'
7240
with:
7341
create_credentials_file: true
7442
workload_identity_provider: 'projects/49427430084/locations/global/workloadIdentityPools/github-wif-pool/providers/github-wif-provider'
7543
service_account: 'github-actions@cloud-cpp-identity-federation.iam.gserviceaccount.com'
76-
- run: |
77-
ctest --test-dir cmake-out --output-on-failure -R common_internal_external_account_integration_test
78-
env:
79-
SCCACHE_GCS_BUCKET: cloud-cpp-gha-cache
80-
SCCACHE_GCS_KEY_PREFIX: sccache/ubuntu-22.04/${{ github.job }}
81-
SCCACHE_GCS_RW_MODE: READ_WRITE
82-
SCCACHE_IGNORE_SERVER_IO_ERROR: 1
83-
VCPKG_BINARY_SOURCES: x-gcs,gs://cloud-cpp-gha-cache/vcpkg-cache/ubuntu-22.04/${{ github.job }},readwrite
44+
- name: Run integration tests
45+
if: '!github.event.pull_request.head.repo.fork'
46+
run: |
47+
bazelisk test \
48+
--test_output=all \
49+
--verbose_failures=true \
50+
--keep_going \
51+
--experimental_convenience_symlinks=ignore \
52+
--remote_upload_local_results=false \
53+
--test_env=GOOGLE_APPLICATION_CREDENTIALS="${GOOGLE_APPLICATION_CREDENTIALS}" \
54+
--test_env=GOOGLE_CLOUD_CPP_TEST_WIF_BUCKET="cloud-cpp-wif-test-bucket" \
55+
//google/cloud:internal_external_account_integration_test

ci/gha/builds/external-account.sh

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,17 @@ set -euo pipefail
1818

1919
source "$(dirname "$0")/../../lib/init.sh"
2020
source module ci/gha/builds/lib/linux.sh
21-
source module ci/gha/builds/lib/cmake.sh
22-
source module ci/gha/builds/lib/ctest.sh
21+
source module ci/gha/builds/lib/bazel.sh
22+
source module ci/lib/io.sh
2323

24-
mapfile -t args < <(cmake::common_args)
25-
mapfile -t vcpkg_args < <(cmake::vcpkg_args)
26-
mapfile -t ctest_args < <(ctest::common_args)
24+
mapfile -t args < <(bazel::common_args)
25+
mapfile -t test_args < <(bazel::test_args)
2726

28-
# This is a build to test External Accounts. This is a feature to use accounts
29-
# from providers other than Google to access Google services. In this case we
30-
# are using "GitHub Actions" as the provider.
31-
# The External Accounts feature is sometimes known as Workload Identity
32-
# Federation, and sometimes BYOID (Bring Your Own ID).
33-
features=(
34-
# Enable the smallest set of libraries libraries that will compile gRPC and
35-
# REST-based authentication components and tests.
36-
storage
37-
iam
38-
bigtable
27+
targets=(
28+
"//google/cloud:internal_external_account_integration_test"
3929
)
40-
enable=$(printf ";%s" "${features[@]}")
41-
enable=${enable:1}
4230

43-
io::log_h1 "Starting Build"
44-
TIMEFORMAT="==> 🕑 CMake configuration done in %R seconds"
31+
io::log_h1 "Building Targets"
4532
time {
46-
io::run cmake "${args[@]}" "${vcpkg_args[@]}" -DGOOGLE_CLOUD_CPP_ENABLE="${enable}"
47-
}
48-
49-
TIMEFORMAT="==> 🕑 CMake build done in %R seconds"
50-
time {
51-
# Compile only the integration test we need for this build
52-
io::run cmake --build cmake-out --target common_internal_external_account_integration_test
33+
io::run bazelisk "${args[@]}" build "${test_args[@]}" "${targets[@]}"
5334
}

0 commit comments

Comments
 (0)