# Copyright 2023 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
#
#     https://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:
# If the terragrunt linter fails, run the following from the repo root to
# correctly format your terraform files:
#     terragrunt hclfmt
- id: terragrunt_lint
  name: 'alpine/terragrunt'
  args: [ 'terragrunt', 'hclfmt', '--check' ]
  waitFor: [ '-' ]

# If the terraform linter fails, run the following from the repo root to
# correctly format your terraform files:
#     terragrunt run-all fmt
- id: terraform_lint
  name: 'alpine/terragrunt'
  args: [ 'terraform', 'fmt', '-recursive', '-check' ]
  waitFor: [ '-' ]

# If the python linter fails, run the following from the repo root to
# correctly format your terraform files:
#     pip install --user --upgrade nox
#     nox --session=format_all
- id: python_lint
  name: 'gcr.io/cloud-devrel-public-resources/python-multi'
  args: [ 'bash', './ci/build.sh' ]
  env:
  - 'NOX_SESSION=lint'
  waitFor: [ '-' ]

- id: unittest
  name: 'gcr.io/cloud-devrel-public-resources/python-multi'
  args: [ 'bash', './ci/build.sh' ]
  env:
  - 'NOX_SESSION=unit'
  waitFor: [ '-' ]

- id: integrationtest
  name: 'gcr.io/cloud-devrel-public-resources/python-multi'
  args: [ 'bash', './ci/build.sh' ]
  env:
  - 'NOX_SESSION=integration'
  - 'PROJECT_ID=pso-data-migration-tool-test'
  - 'TERADATA_IP=10.128.0.3'
  - 'TERADATA_UNAME=dbc'
  - 'TERADATA_SCHEMA=tpch'
  - 'ORACLE_IP=10.128.0.2'
  - 'ORACLE_UNAME=edw_odb'
  - 'ORACLE_SCHEMA=EDW_ODB'
  - 'ORACLE_DATABASE=ORCLPDB1'
  - 'BUILD_ID=$BUILD_ID'
  - PR_NUMBER=${_PR_NUMBER}
  waitFor: [ '-' ]
# substitutions:
#   _PR_NUMBER: "na"

timeout: 3600s # 1 hr
options:
  machineType: N1_HIGHCPU_8