Skip to content

Commit

Permalink
Migrate to Bzlmod. (#1449)
Browse files Browse the repository at this point in the history
This updates to Bazel 7.
  • Loading branch information
SanjayVas authored and ple13 committed Aug 16, 2024
1 parent f9ef673 commit 05a3d7c
Show file tree
Hide file tree
Showing 315 changed files with 142,683 additions and 2,315 deletions.
14 changes: 12 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Enable Bzlmod.
common --enable_bzlmod
common --registry=https://raw.githubusercontent.com/world-federation-of-advertisers/bazel-registry/main
common --registry=https://bcr.bazel.build

# Use clang as C++ compiler.
build --repo_env='CC=clang'

Expand All @@ -7,12 +12,17 @@ build --cxxopt='-std=c++17'
# Use JDK 11. See https://github.com/bazelbuild/bazel/issues/6245.
build --java_runtime_version=remotejdk_11

# Target Java 8.
build --java_language_version=8
# Target Java 9.
build --java_language_version=9

# Pass environment variables.
test --test_env TESTCONTAINERS_RYUK_DISABLED=true

# Configuration for continuous integration (CI).
common:ci --lockfile_mode=error
build:ci --compilation_mode=opt
build:ci --host_platform //build/platforms:ubuntu_20_04

# Configuration for GitHub Container Registry
build:ghcr --define container_registry=ghcr.io
build:ghcr --define image_repo_prefix=world-federation-of-advertisers
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.4.0
7.0.1
13 changes: 5 additions & 8 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ jobs:
- name: Write ~/.bazelrc
run: |
cat << EOF > ~/.bazelrc
build -c opt
build --host_platform //build/platforms:ubuntu_20_04
common --config=ci
build --define container_registry=localhost:5001
build --define image_repo_prefix=halo
build --define image_tag=latest
Expand All @@ -86,8 +85,6 @@ jobs:
- name: Get Bazel cache params
id: get-cache-params
uses: world-federation-of-advertisers/actions/bazel-get-cache-params@v2
with:
cache-version: 1

# This is a hack to utilize the undocumented relatively large empty
# scratch disk mounted at /mnt. It's currently needed to work around
Expand All @@ -103,7 +100,7 @@ jobs:
sudo mount --bind /mnt/bazel-cache "$BAZEL_CACHE_PATH"
- name: Restore Bazel cache
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: ${{ steps.get-cache-params.outputs.cache-path }}
key: ${{ steps.get-cache-params.outputs.cache-key }}
Expand Down Expand Up @@ -170,13 +167,13 @@ jobs:
run: |
bazel_out="$(bazelisk info output_path)"
find "${bazel_out}" -type f \( -iname '*.tar' -o -iname '*.tar.gz' \) -delete
find "${bazel_out}" -type d -name blobs -exec chmod -R +w "{}" \;
find "${bazel_out}" -type f -path '*/blobs/*' -delete
find "${bazel_out}" -type d -name sha256 -exec chmod -R +w "{}" \;
find "${bazel_out}" -type f -path '*/sha256/*' -delete
- name: Save Bazel cache
if: github.event_name == 'push'
uses: actions/cache/save@v3
uses: actions/cache/save@v4
continue-on-error: true
with:
path: ${{ steps.get-cache-params.outputs.cache-path }}
Expand Down
56 changes: 31 additions & 25 deletions .github/workflows/configure-aws-duchy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,49 +77,55 @@ jobs:
role-to-assume: ${{ vars.AWS_GHA_ROLE }}
role-session-name: GitHubAction

- name: Get EKS cluster credentials
run: aws eks update-kubeconfig --region $AWS_REGION --name ${DUCHY_NAME}-duchy

- name: Export BAZEL_BIN
run: echo "BAZEL_BIN=$(bazelisk info bazel-bin)" >> $GITHUB_ENV

- name: Configure metrics
uses: ./.github/actions/configure-metrics-aws
if: ${{ inputs.apply }}
with:
amp-ingest-endpoint: ${{ vars.AMP_INGEST_ENDPOINT }}
amp-region: ${{ vars.AWS_REGION }}

- name: Export DUCHY_CERT_ID
env:
AGGREGATOR_DUCHY_CERT_ID: ${{ vars.AGGREGATOR_DUCHY_CERT_ID }}
WORKER1_DUCHY_CERT_ID: ${{ vars.WORKER1_DUCHY_CERT_ID }}
WORKER2_DUCHY_CERT_ID: ${{ vars.WORKER2_DUCHY_CERT_ID }}
run: ./.github/workflows/export-duchy-cert-id.sh

- name: Generate archives
- name: Write ~/.bazelrc
env:
IMAGE_TAG: ${{ inputs.image-tag }}
POSTGRES_HOST: ${{ vars.AWS_POSTGRES_HOST }}
POSTGRES_CRED_SECRET_NAME: ${{ vars.AWS_POSTGRES_CRED_SECRET_NAME }}
KINGDOM_SYSTEM_API_TARGET: ${{ vars.KINGDOM_SYSTEM_API_TARGET }}
COMPUTATION_CONTROL_SERVER_EIPS: ${{ vars.AWS_COMPUTATION_CONTROL_SERVER_EIPS }}
S3_BUCKET: ${{ vars.AWS_S3_BUCKET }}
run: |
cat << EOF > ~/.bazelrc
common --config=ci
common --config=ghcr
build --define image_tag=$IMAGE_TAG
build --define kingdom_system_api_target=$KINGDOM_SYSTEM_API_TARGET
build --define s3_bucket=$S3_BUCKET
build --define s3_region=$AWS_REGION
build --define duchy_cert_id=$DUCHY_CERT_ID
build --define postgres_host=$POSTGRES_HOST
build --define postgres_port=5432
build --define postgres_region=$AWS_REGION
build --define postgres_credential_secret_name=$POSTGRES_CRED_SECRET_NAME
build --define computation_control_server_eips=$COMPUTATION_CONTROL_SERVER_EIPS
EOF
- name: Get EKS cluster credentials
run: aws eks update-kubeconfig --region $AWS_REGION --name ${DUCHY_NAME}-duchy

- name: Export BAZEL_BIN
run: echo "BAZEL_BIN=$(bazelisk info bazel-bin)" >> $GITHUB_ENV

- name: Configure metrics
uses: ./.github/actions/configure-metrics-aws
if: ${{ inputs.apply }}
with:
amp-ingest-endpoint: ${{ vars.AMP_INGEST_ENDPOINT }}
amp-region: ${{ vars.AWS_REGION }}

- name: Generate archives
run: >
bazelisk build
"//src/main/k8s/dev:${DUCHY_NAME}_duchy_aws.tar"
//src/main/k8s/testing/secretfiles:archive
--config ghcr
--define "image_tag=$IMAGE_TAG"
--define "kingdom_system_api_target=$KINGDOM_SYSTEM_API_TARGET"
--define "s3_bucket=$S3_BUCKET"
--define "s3_region=$AWS_REGION"
--define "duchy_cert_id=$DUCHY_CERT_ID"
--define "postgres_host=$POSTGRES_HOST"
--define "postgres_port=5432"
--define "postgres_region=$AWS_REGION"
--define "postgres_credential_secret_name=$POSTGRES_CRED_SECRET_NAME"
--define "computation_control_server_eips=$COMPUTATION_CONTROL_SERVER_EIPS"
- name: Make Kustomization dir
run: mkdir -p "$KUSTOMIZATION_PATH"
Expand Down
38 changes: 31 additions & 7 deletions .github/workflows/configure-duchy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,37 @@ jobs:
workload_identity_provider: ${{ vars.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ vars.GKE_CONFIG_SERVICE_ACCOUNT }}

- name: Export DUCHY_CERT_ID
env:
AGGREGATOR_DUCHY_CERT_ID: ${{ vars.AGGREGATOR_DUCHY_CERT_ID }}
WORKER1_DUCHY_CERT_ID: ${{ vars.WORKER1_DUCHY_CERT_ID }}
WORKER2_DUCHY_CERT_ID: ${{ vars.WORKER2_DUCHY_CERT_ID }}
run: ./.github/workflows/export-duchy-cert-id.sh

- name: Write ~/.bazelrc
env:
IMAGE_TAG: ${{ inputs.image-tag }}
POSTGRES_HOST: ${{ vars.AWS_POSTGRES_HOST }}
POSTGRES_CRED_SECRET_NAME: ${{ vars.AWS_POSTGRES_CRED_SECRET_NAME }}
KINGDOM_SYSTEM_API_TARGET: ${{ vars.KINGDOM_SYSTEM_API_TARGET }}
COMPUTATION_CONTROL_SERVER_EIPS: ${{ vars.AWS_COMPUTATION_CONTROL_SERVER_EIPS }}
S3_BUCKET: ${{ vars.AWS_S3_BUCKET }}
run: |
cat << EOF > ~/.bazelrc
common --config=ci
common --config=ghcr
build --define image_tag=$IMAGE_TAG
build --define kingdom_system_api_target=$KINGDOM_SYSTEM_API_TARGET
build --define s3_bucket=$S3_BUCKET
build --define s3_region=$AWS_REGION
build --define duchy_cert_id=$DUCHY_CERT_ID
build --define postgres_host=$POSTGRES_HOST
build --define postgres_port=5432
build --define postgres_region=$AWS_REGION
build --define postgres_credential_secret_name=$POSTGRES_CRED_SECRET_NAME
build --define computation_control_server_eips=$COMPUTATION_CONTROL_SERVER_EIPS
EOF
- name: Export BAZEL_BIN
run: echo "BAZEL_BIN=$(bazelisk info bazel-bin)" >> $GITHUB_ENV

Expand All @@ -90,13 +121,6 @@ jobs:
uses: ./.github/actions/configure-metrics
if: ${{ inputs.apply }}

- name: Export DUCHY_CERT_ID
env:
AGGREGATOR_DUCHY_CERT_ID: ${{ vars.AGGREGATOR_DUCHY_CERT_ID }}
WORKER1_DUCHY_CERT_ID: ${{ vars.WORKER1_DUCHY_CERT_ID }}
WORKER2_DUCHY_CERT_ID: ${{ vars.WORKER2_DUCHY_CERT_ID }}
run: ./.github/workflows/export-duchy-cert-id.sh

- name: Generate archives
env:
IMAGE_TAG: ${{ inputs.image-tag }}
Expand Down
20 changes: 13 additions & 7 deletions .github/workflows/configure-kingdom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ jobs:
workload_identity_provider: ${{ vars.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ vars.GKE_CONFIG_SERVICE_ACCOUNT }}

- name: Write ~/.bazelrc
env:
IMAGE_TAG: ${{ inputs.image-tag }}
SPANNER_INSTANCE: ${{ vars.SPANNER_INSTANCE }}
run: |
cat << EOF > ~/.bazelrc
common --config=ci
common --config=ghcr
build --define "image_tag=$IMAGE_TAG"
build --define "google_cloud_project=$GCLOUD_PROJECT"
build --define "spanner_instance=$SPANNER_INSTANCE"
EOF
- name: Export BAZEL_BIN
run: echo "BAZEL_BIN=$(bazelisk info bazel-bin)" >> $GITHUB_ENV

Expand All @@ -79,17 +92,10 @@ jobs:
if: ${{ inputs.apply }}

- name: Generate archives
env:
IMAGE_TAG: ${{ inputs.image-tag }}
SPANNER_INSTANCE: ${{ vars.SPANNER_INSTANCE }}
run: >
bazelisk build
//src/main/k8s/dev:kingdom.tar
//src/main/k8s/testing/secretfiles:archive
--config ghcr
--define "image_tag=$IMAGE_TAG"
--define "google_cloud_project=$GCLOUD_PROJECT"
--define "spanner_instance=$SPANNER_INSTANCE"
- name: Make Kustomization dir
run: mkdir -p "$KUSTOMIZATION_PATH"
Expand Down
28 changes: 17 additions & 11 deletions .github/workflows/configure-reporting-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ jobs:
workload_identity_provider: ${{ vars.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ vars.GKE_CONFIG_SERVICE_ACCOUNT }}

- name: Write ~/.bazelrc
env:
IMAGE_TAG: ${{ inputs.image-tag }}
POSTGRES_INSTANCE: ${{ vars.POSTGRES_INSTANCE }}
GCLOUD_REGION: ${{ vars.GCLOUD_REGION }}
KINGDOM_PUBLIC_API_TARGET: ${{ vars.KINGDOM_PUBLIC_API_TARGET }}
run: |
cat << EOF > ~/.bazelrc
common --config=ci
common --config=ghcr
build --define "image_tag=$IMAGE_TAG"
build --define "google_cloud_project=$GCLOUD_PROJECT"
build --define "postgres_instance=$POSTGRES_INSTANCE"
build --define "postgres_region=$GCLOUD_REGION"
build --define "kingdom_public_api_target=$KINGDOM_PUBLIC_API_TARGET"
EOF
- name: Export BAZEL_BIN
run: echo "BAZEL_BIN=$(bazelisk info bazel-bin)" >> $GITHUB_ENV

Expand All @@ -79,21 +96,10 @@ jobs:
if: ${{ inputs.apply }}

- name: Generate archives
env:
IMAGE_TAG: ${{ inputs.image-tag }}
POSTGRES_INSTANCE: ${{ vars.POSTGRES_INSTANCE }}
GCLOUD_REGION: ${{ vars.GCLOUD_REGION }}
KINGDOM_PUBLIC_API_TARGET: ${{ vars.KINGDOM_PUBLIC_API_TARGET }}
run: >
bazelisk build
//src/main/k8s/dev:reporting_v2.tar
//src/main/k8s/testing/secretfiles:archive
--config ghcr
--define "image_tag=$IMAGE_TAG"
--define "google_cloud_project=$GCLOUD_PROJECT"
--define "postgres_instance=$POSTGRES_INSTANCE"
--define "postgres_region=$GCLOUD_REGION"
--define "kingdom_public_api_target=$KINGDOM_PUBLIC_API_TARGET"
- name: Make Kustomization dir
run: mkdir -p "$KUSTOMIZATION_PATH"
Expand Down
29 changes: 18 additions & 11 deletions .github/workflows/configure-reporting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,24 @@ jobs:
workload_identity_provider: ${{ vars.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ vars.GKE_CONFIG_SERVICE_ACCOUNT }}

- name: Write ~/.bazelrc
env:
IMAGE_TAG: ${{ inputs.image-tag }}
POSTGRES_INSTANCE: ${{ vars.POSTGRES_INSTANCE }}
GCLOUD_REGION: ${{ vars.GCLOUD_REGION }}
KINGDOM_PUBLIC_API_TARGET: ${{ vars.KINGDOM_PUBLIC_API_TARGET }}
run: |
cat << EOF > ~/.bazelrc
common --config=ci
common --config=ghcr
build --define "image_tag=$IMAGE_TAG"
build --define "google_cloud_project=$GCLOUD_PROJECT"
build --define "postgres_instance=$POSTGRES_INSTANCE"
build --define "postgres_region=$GCLOUD_REGION"
build --define "kingdom_public_api_target=$KINGDOM_PUBLIC_API_TARGET"
EOF
- name: Export BAZEL_BIN
run: echo "BAZEL_BIN=$(bazelisk info bazel-bin)" >> $GITHUB_ENV

Expand All @@ -79,21 +97,10 @@ jobs:
if: ${{ inputs.apply }}

- name: Generate archives
env:
IMAGE_TAG: ${{ inputs.image-tag }}
POSTGRES_INSTANCE: ${{ vars.POSTGRES_INSTANCE }}
GCLOUD_REGION: ${{ vars.GCLOUD_REGION }}
KINGDOM_PUBLIC_API_TARGET: ${{ vars.KINGDOM_PUBLIC_API_TARGET }}
run: >
bazelisk build
//src/main/k8s/dev:reporting.tar
//src/main/k8s/testing/secretfiles:archive
--config ghcr
--define "image_tag=$IMAGE_TAG"
--define "google_cloud_project=$GCLOUD_PROJECT"
--define "postgres_instance=$POSTGRES_INSTANCE"
--define "postgres_region=$GCLOUD_REGION"
--define "kingdom_public_api_target=$KINGDOM_PUBLIC_API_TARGET"
- name: Make Kustomization dir
run: mkdir -p "$KUSTOMIZATION_PATH"
Expand Down
Loading

0 comments on commit 05a3d7c

Please sign in to comment.