|
| 1 | +steps: |
| 2 | +# 1. Set up Node.js environment |
| 3 | +- name: 'node:24' |
| 4 | + entrypoint: 'bash' |
| 5 | + args: |
| 6 | + - '-c' |
| 7 | + - | |
| 8 | + npm install |
| 9 | + dir: 'handwritten/bigquery' |
| 10 | + id: 'install-dependencies' |
| 11 | + |
| 12 | +# 2. Configure environment variables for the tests and run system tests |
| 13 | +# - GOOGLE_APPLICATION_CREDENTIALS: GCB steps run as a service account |
| 14 | +# that is typically granted permissions directly. Explicitly setting |
| 15 | +# GOOGLE_APPLICATION_CREDENTIALS might not be needed if the GCB service |
| 16 | +# account has the right roles (e.g., BigQuery Admin, BigQuery User). |
| 17 | +# If you need to use specific service account key JSON, you'd store it |
| 18 | +# in Secret Manager and mount it here. For simplicity, we'll rely on |
| 19 | +# the GCB service account's inherent permissions. |
| 20 | +# - GCLOUD_PROJECT: Can be passed as a build variable. |
| 21 | +- name: 'node:24' |
| 22 | + entrypoint: 'bash' |
| 23 | + args: |
| 24 | + - '-c' |
| 25 | + - | |
| 26 | + npm run system-test |
| 27 | + dir: 'handwritten/bigquery' |
| 28 | + env: |
| 29 | + - 'GCLOUD_PROJECT=${_GCP_PROJECT_ID}' # Pass project ID via build variable |
| 30 | + # If you need specific credentials from Secret Manager, uncomment these: |
| 31 | + # - 'GOOGLE_APPLICATION_CREDENTIALS=/secrets/sa-key.json' |
| 32 | + id: 'run-system-tests' |
| 33 | + waitFor: ['install-dependencies'] |
| 34 | + # For Secret Manager, uncomment these (adjust secret name and volume path as needed): |
| 35 | + # secretEnv: ['SA_KEY'] |
| 36 | + # volumes: |
| 37 | + # - name: 'sa-keys' |
| 38 | + # path: '/secrets' |
| 39 | + |
| 40 | +# 3. (Optional) Code Coverage Reporting |
| 41 | +- name: 'node:24' |
| 42 | + entrypoint: 'bash' |
| 43 | + args: |
| 44 | + - '-c' |
| 45 | + - | |
| 46 | + # Check if nyc is installed and run report |
| 47 | + if [ -f ./node_modules/nyc/bin/nyc.js ]; then |
| 48 | + ./node_modules/nyc/bin/nyc.js report || true # `|| true` prevents build failure if nyc report itself exits non-zero |
| 49 | + else |
| 50 | + echo "nyc not found, skipping coverage report." |
| 51 | + fi |
| 52 | + # The original codecov.sh script from Kokoro needs to be made available to GCB. |
| 53 | + # Options: |
| 54 | + # a) Commit codecov.sh into your repo (e.g., .kokoro/codecov.sh) and call it: |
| 55 | + # if [ -f .kokoro/codecov.sh ]; then . ./.kokoro/codecov.sh; fi |
| 56 | + # b) Replicate its functionality directly in this step. |
| 57 | + # c) Store it in a GCS bucket and fetch it. |
| 58 | + echo "Codecov reporting (if desired) would be integrated here." |
| 59 | + dir: 'handwritten/bigquery' |
| 60 | + id: 'coverage-report' |
| 61 | + waitFor: ['run-system-tests'] |
| 62 | + |
| 63 | +# If you use Secret Manager for credentials, uncomment and configure: |
| 64 | +# availableSecrets: |
| 65 | +# secretManager: |
| 66 | +# - versionName: projects/${PROJECT_ID}/secrets/YOUR_SERVICE_ACCOUNT_KEY_SECRET_NAME/versions/latest |
| 67 | +# env: 'SA_KEY' # This env var will hold the secret value. Use it as GOOGLE_APPLICATION_CREDENTIALS in step 3 if needed. |
| 68 | + |
| 69 | +# Define a substitution variable for your project ID |
| 70 | +# Replace 'long-door-651' with the actual GCP Project ID your system tests should run against. |
| 71 | +substitutions: |
| 72 | + _GCP_PROJECT_ID: 'long-door-651' |
| 73 | + |
| 74 | +timeout: '3600s' |
0 commit comments