Skip to content
Merged
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
15 changes: 13 additions & 2 deletions .cloudbuild/cd/test_e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,28 @@ steps:
args:
- "-c"
- |
# Skip E2E tests for dependency updates (e.g., Dependabot PRs)
if [[ "${_COMMIT_MESSAGE}" == build\(deps\)* ]]; then
echo "Skipping E2E tests for dependency update: ${_COMMIT_MESSAGE}"
touch /workspace/.skip-e2e
exit 0
fi
uv sync --dev --locked

# Run unit tests using pytest
# Run E2E tests using pytest
- name: "europe-west4-docker.pkg.dev/production-ai-template/starter-pack/e2e-tests"
id: e2e-tests
entrypoint: /bin/bash
args:
- "-c"
- |
if [ -f /workspace/.skip-e2e ]; then
echo "Skipping E2E tests - dependency update commit"
exit 0
fi
GH_TOKEN=$$GITHUB_PAT uv run pytest tests/cicd/test_e2e_deployment.py -v
secretEnv: ['GITHUB_PAT', 'GITHUB_APP_INSTALLATION_ID']

availableSecrets:
secretManager:
- versionName: projects/${_SECRETS_PROJECT_ID}/secrets/github-pat/versions/latest
Expand All @@ -51,3 +61,4 @@ options:
timeout: 43200s
substitutions:
_SECRETS_PROJECT_ID: 'asp-e2e-vars'
_COMMIT_MESSAGE: ''
20 changes: 20 additions & 0 deletions .cloudbuild/cd/test_gemini_enterprise.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ steps:
args:
- "-c"
- |
# Skip tests for dependency updates (e.g., Dependabot PRs)
if [[ "${_COMMIT_MESSAGE}" == build\(deps\)* ]]; then
echo "Skipping tests for dependency update: ${_COMMIT_MESSAGE}"
touch /workspace/.skip-e2e
exit 0
fi
uv sync --dev --locked

# Set gcloud project to dev environment
Expand All @@ -29,6 +35,10 @@ steps:
args:
- "-c"
- |
if [ -f /workspace/.skip-e2e ]; then
echo "Skipping - dependency update commit"
exit 0
fi
Comment on lines +38 to +41
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This skip logic is repeated in two other steps within this file (lines 51-54 and 64-67). This duplication can make the configuration harder to maintain in the long run.

To improve this, you could use a YAML anchor to define the script block once and then reuse it in each step. This follows the DRY (Don't Repeat Yourself) principle.

For example, you could define an anchor at the top of the file:

x-skip-check: &skip-check |
  if [ -f /workspace/.skip-e2e ]; then
    echo "Skipping step due to dependency update commit."
    exit 0
  fi

And then apply it in each relevant step:

- name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
  id: set-gcloud-project
  entrypoint: /bin/bash
  args:
    - "-c"
    - |
      <<: *skip-check
      gcloud config set project ${_E2E_DEV_PROJECT}

gcloud config set project ${_E2E_DEV_PROJECT}

# Fetch identity token for Cloud Run authentication
Expand All @@ -38,6 +48,10 @@ steps:
args:
- "-c"
- |
if [ -f /workspace/.skip-e2e ]; then
echo "Skipping - dependency update commit"
exit 0
fi
gcloud auth print-identity-token -q > /workspace/id_token.txt

# Run Gemini Enterprise registration test
Expand All @@ -47,6 +61,10 @@ steps:
args:
- "-c"
- |
if [ -f /workspace/.skip-e2e ]; then
echo "Skipping Gemini Enterprise test - dependency update commit"
exit 0
fi
export ID_TOKEN=$(cat /workspace/id_token.txt)
uv run pytest tests/cicd/test_gemini_enterprise_registration.py -v
secretEnv: ['GEMINI_ENTERPRISE_APP_ID']
Expand All @@ -62,3 +80,5 @@ options:
env:
- "RUN_GEMINI_ENTERPRISE_TEST=1"
timeout: 3600s # 1 hour timeout
substitutions:
_COMMIT_MESSAGE: ''
2 changes: 2 additions & 0 deletions .cloudbuild/terraform/build_triggers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ resource "google_cloudbuild_trigger" "main_e2e_deployment_test" {
_E2E_STAGING_PROJECT = var.e2e_test_project_mapping.staging
_E2E_PROD_PROJECT = var.e2e_test_project_mapping.prod
_SECRETS_PROJECT_ID = "asp-e2e-vars"
_COMMIT_MESSAGE = "$(push.head_commit.message)"
}
}

Expand Down Expand Up @@ -579,5 +580,6 @@ resource "google_cloudbuild_trigger" "main_e2e_gemini_enterprise_test" {

substitutions = {
_E2E_DEV_PROJECT = var.e2e_test_project_mapping.dev
_COMMIT_MESSAGE = "$(push.head_commit.message)"
}
}