Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ build --copt=-Wno-deprecated-declarations
build --copt=-Wno-return-type
build --copt=-Wno-unused-but-set-parameter

# Automatically apply build:macos on macOS, build:linux on Linux, etc.
build --enable_platform_specific_config

# Clang 17+ warns on GoogleSQL code; GCC doesn't recognize this flag.
build:macos --copt=-Wno-missing-template-arg-list-after-template-kw

# =============================================================================
# 5. TEST SETTINGS
# =============================================================================
Expand Down
371 changes: 371 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,371 @@
version: 2.1

executors:
linux:
machine:
image: ubuntu-2404:current
resource_class: xlarge
macos:
macos:
xcode: "26.4.0"
resource_class: m4pro.large

commands:
install-bazelisk:
steps:
- run:
name: Install Bazelisk
command: |
if [[ "$(uname)" == "Darwin" ]]; then
brew install bazelisk
else
sudo curl -fsSL https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 \
-o /usr/local/bin/bazel
sudo chmod +x /usr/local/bin/bazel
fi
bazel --version

restore-bazel-cache:
parameters:
platform:
type: string
steps:
- restore_cache:
keys:
- bazel-v1-<< parameters.platform >>-{{ checksum "WORKSPACE" }}-{{ checksum ".bazelversion" }}
- bazel-v1-<< parameters.platform >>-{{ checksum "WORKSPACE" }}
- bazel-v1-<< parameters.platform >>-
- run:
name: Prune large files from Bazel disk cache
command: |
CACHE_DIR=/tmp/bazel-disk-cache
if [[ -d "$CACHE_DIR" ]]; then
echo "Disk cache before prune: $(du -sh "$CACHE_DIR" | cut -f1)"
# Delete cached files over 100MB. These are linked test binaries
# that dominate cache size (~38GB) but are fast to re-link.
# Small compilation outputs (.o/.a ~1.7GB) are expensive to
# rebuild and are preserved.
find "$CACHE_DIR" -type f -size +100M -delete
echo "Disk cache after prune: $(du -sh "$CACHE_DIR" | cut -f1)"
fi

save-bazel-cache:
parameters:
platform:
type: string
steps:
- save_cache:
key: bazel-v1-<< parameters.platform >>-{{ checksum "WORKSPACE" }}-{{ checksum ".bazelversion" }}-{{ epoch }}
paths:
- /tmp/bazel-disk-cache

install-gcloud:
steps:
- run:
name: Install gcloud CLI
command: |
if [[ "$(uname)" == "Darwin" ]]; then
brew install --cask google-cloud-sdk
else
sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates gnupg curl
curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | \
sudo tee /etc/apt/sources.list.d/google-cloud-sdk.list
sudo apt-get update && sudo apt-get install -y google-cloud-cli
fi
echo "export GCLOUD_DIR=$(dirname $(which gcloud))" >> "$BASH_ENV"
gcloud --version

authenticate-gcloud:
steps:
- run:
name: Authenticate gcloud
command: |
echo "${OPS_GCLOUD_CREDS}" > /tmp/gcloud-key.json
gcloud auth activate-service-account --key-file=/tmp/gcloud-key.json
rm /tmp/gcloud-key.json

package-and-upload:
parameters:
platform:
type: string
steps:
- run:
name: Package binaries into tarball
command: |
version="${CIRCLE_TAG#v}"
if [[ "$(uname)" == "Darwin" ]]; then
host_os="darwin"
host_arch="arm64"
else
host_os="linux"
host_arch="amd64"
fi
tarball="spanner-emulator-v${version}-${host_os}-${host_arch}.tgz"

mkdir -p /tmp/release-staging
cp bazel-bin/binaries/emulator_main /tmp/release-staging/
cp bazel-bin/binaries/gateway_main_/gateway_main /tmp/release-staging/
tar -czf "/tmp/${tarball}" -C /tmp/release-staging .

echo "export TARBALL=/tmp/${tarball}" >> "$BASH_ENV"
echo "export GCS_PATH=gs://fs-build-ci-public/spanner-emulator/v${version}/${tarball}" >> "$BASH_ENV"
- run:
name: Upload tarball to GCS
command: |
gsutil cp "${TARBALL}" "${GCS_PATH}"
echo "Uploaded: ${GCS_PATH}"

free-disk-space:
steps:
- run:
name: Free disk space
command: |
echo "Disk usage before cleanup:"
df -h /

# Purge APFS snapshots and purgeable space (~30-70 GB)
# This reclaims the gap between "used + avail" and total disk size.
sudo tmutil deletelocalsnapshots / 2>/dev/null || true
sudo tmutil thinlocalsnapshots / 999999999999 2>/dev/null || true

# Remove simulators and device platforms (~10+ GB)
sudo rm -rf /Library/Developer/CoreSimulator
sudo rm -rf /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
sudo rm -rf /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform
sudo rm -rf /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform
sudo rm -rf /Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform

# Remove Xcode caches and device support files (~5-40 GB)
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~/Library/Developer/Xcode/iOS\ DeviceSupport
rm -rf ~/Library/Developer/Xcode/WatchOS\ DeviceSupport
rm -rf ~/Library/Developer/Xcode/tvOS\ DeviceSupport
rm -rf ~/Library/Developer/Xcode/Archives

# Remove Swift/DocC toolchains and documentation we don't need
sudo rm -rf /Library/Developer/Toolchains
rm -rf ~/Library/Developer/Shared/Documentation

echo "Disk usage after cleanup:"
df -h /

clean-homebrew-cache:
steps:
- run:
name: Clean Homebrew cache
command: |
brew cleanup --prune=all 2>/dev/null || true
rm -rf ~/Library/Caches/Homebrew
echo "Disk usage after Homebrew cleanup:"
df -h /

collect-test-results:
steps:
- run:
name: Collect test results
when: always
command: |
mkdir -p /tmp/test-results
testlogs_dir="$(bazel info bazel-testlogs 2>/dev/null)" || true
if [[ -d "${testlogs_dir}" ]]; then
find "${testlogs_dir}" -name "test.xml" | while read -r xml; do
rel="${xml#${testlogs_dir}/}"
target_name="$(echo "${rel}" | sed 's|/test.xml$||' | tr '/' '_')"
cp "${xml}" "/tmp/test-results/${target_name}.xml"
done
fi
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
destination: test-results

jobs:
build-linux:
executor: linux
steps:
- checkout
- install-bazelisk
- install-gcloud
- restore-bazel-cache:
platform: linux
- run:
name: Build all targets
command: |
bazel build \
--disk_cache=/tmp/bazel-disk-cache \
-- ... -third_party/...
no_output_timeout: 30m
- save-bazel-cache:
platform: linux

test-linux:
executor: linux
steps:
- checkout
- install-bazelisk
- install-gcloud
- restore-bazel-cache:
platform: linux
- run:
name: Run all tests
command: |
bazel test \
--disk_cache=/tmp/bazel-disk-cache \
--test_output=errors \
-- ... -third_party/...
no_output_timeout: 30m
- collect-test-results

build-macos:
executor: macos
steps:
- checkout
- free-disk-space
- install-bazelisk
- install-gcloud
- clean-homebrew-cache
- restore-bazel-cache:
platform: macos
- run:
name: Build all targets
command: |
bazel build \
--disk_cache=/tmp/bazel-disk-cache \
-- ... -third_party/...
no_output_timeout: 30m
- save-bazel-cache:
platform: macos

test-macos:
executor: macos
steps:
- checkout
- free-disk-space
- install-bazelisk
- install-gcloud
- clean-homebrew-cache
- restore-bazel-cache:
platform: macos
- run:
name: Run all tests
command: |
bazel test \
--disk_cache=/tmp/bazel-disk-cache \
--test_output=errors \
-- ... -third_party/...
no_output_timeout: 30m
- collect-test-results

release-linux:
executor: linux
steps:
- checkout
- install-bazelisk
- install-gcloud
- authenticate-gcloud
- restore-bazel-cache:
platform: linux
- run:
name: Build binaries
command: |
bazel build -c opt \
--disk_cache=/tmp/bazel-disk-cache \
//binaries:emulator_main //binaries:gateway_main
no_output_timeout: 30m
- save-bazel-cache:
platform: linux
- package-and-upload:
platform: linux

ci-complete:
docker:
- image: cimg/base:stable
resource_class: small
steps:
- run: echo "All CI checks passed."

release-macos:
executor: macos
steps:
- checkout
- free-disk-space
- install-bazelisk
- install-gcloud
- clean-homebrew-cache
- authenticate-gcloud
- restore-bazel-cache:
platform: macos
- run:
name: Build binaries
command: |
bazel build -c opt \
--disk_cache=/tmp/bazel-disk-cache \
//binaries:emulator_main //binaries:gateway_main
no_output_timeout: 30m
- save-bazel-cache:
platform: macos
- package-and-upload:
platform: macos

workflows:
build-and-test:
jobs:
- build-linux:
filters:
tags:
ignore: /.*/
- test-linux:
requires:
- build-linux
- build-macos:
filters:
tags:
ignore: /.*/
- test-macos:
requires:
- build-macos
- ci-complete:
requires:
- test-linux
- test-macos

release:
jobs:
- build-linux:
filters:
branches:
ignore: /.*/
tags:
only: /^v\d+\.\d+\.\d+-fs.*/
- test-linux:
requires:
- build-linux
filters:
tags:
only: /^v\d+\.\d+\.\d+-fs.*/
- build-macos:
filters:
branches:
ignore: /.*/
tags:
only: /^v\d+\.\d+\.\d+-fs.*/
- test-macos:
requires:
- build-macos
filters:
tags:
only: /^v\d+\.\d+\.\d+-fs.*/
- release-linux:
requires:
- test-linux
filters:
tags:
only: /^v\d+\.\d+\.\d+-fs.*/
- release-macos:
requires:
- test-macos
filters:
tags:
only: /^v\d+\.\d+\.\d+-fs.*/
Loading