# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

steps:
  - name: 'node:22'
    id: 'js-quickstart-test'
    entrypoint: 'bash'
    args:
      # The '-c' flag tells bash to execute the following string as a command.
      # The 'set -ex' enables debug output and exits on error for easier troubleshooting.
      - -c
      - |
        set -ex
        export VERSION=$(cat ./cmd/version.txt)
        chmod +x .ci/quickstart_test/run_js_tests.sh
        .ci/quickstart_test/run_js_tests.sh
    env:
      - 'CLOUD_SQL_INSTANCE=${_CLOUD_SQL_INSTANCE}'
      - 'GCP_PROJECT=${_GCP_PROJECT}'
      - 'DATABASE_NAME=${_DATABASE_NAME}'
      - 'DB_USER=${_DB_USER}'
    secretEnv: ['TOOLS_YAML_CONTENT', 'GOOGLE_API_KEY', 'DB_PASSWORD']

availableSecrets:
  secretManager:
  - versionName: projects/${_GCP_PROJECT}/secrets/${_TOOLS_YAML_SECRET}/versions/6
    env: 'TOOLS_YAML_CONTENT'
  - versionName: projects/${_GCP_PROJECT_NUMBER}/secrets/${_API_KEY_SECRET}/versions/latest
    env: 'GOOGLE_API_KEY'
  - versionName: projects/${_GCP_PROJECT}/secrets/${_DB_PASS_SECRET}/versions/latest
    env: 'DB_PASSWORD'

timeout: 1000s

options:
  logging: CLOUD_LOGGING_ONLY
