steps:
# Install top-level deps.
- name: 'gcr.io/learnjs-174218/release'
  entrypoint: 'yarn'
  id: 'yarn-common'
  args: ['install']
  waitedForByPackages: true

# Test generate_cloudbuild.js
# See #4523 for why this is special-cased into every cloudbuild.
- name: 'gcr.io/learnjs-174218/release'
  dir: 'scripts'
  id: 'test-generate-cloudbuild'
  entrypoint: 'yarn'
  args: ['test-generate-cloudbuild']
  waitFor: ['yarn-common']

# Test run_flaky.js
# The flaky test runner is important enough to test every time and takes less
# than 5 seconds.
- name: 'gcr.io/learnjs-174218/release'
  id: 'test-run-flaky'
  entrypoint: 'yarn'
  args: ['test-run-flaky']
  waitFor: ['yarn-common']

# Lint bazel files.
- name: 'gcr.io/learnjs-174218/release'
  id: 'buildifier'
  entrypoint: 'yarn'
  args: ['buildifier-ci']
  waitFor: ['yarn-common']

# Lint Bazel package typescript files.
- name: 'gcr.io/learnjs-174218/release'
  id: 'tslint'
  entrypoint: 'yarn'
  args: ['lint']
  waitFor: ['yarn-common']

# Bazel tests
# These use a remote cache and only re-run if changes occurred, so we run them
# in every build.
- name: 'gcr.io/learnjs-174218/release'
  id: 'bazel-tests'
  waitFor: ['yarn-common']
  entrypoint: 'bash'
  args:
    - './scripts/run_bazel_ci_tests.sh'
  env:
    - 'BROWSERSTACK_USERNAME=deeplearnjs1'
    - 'NIGHTLY=$_NIGHTLY'
  secretEnv: ['BROWSERSTACK_KEY']

# The following step builds the link package, which is a temporary package
# that helps packages that don't build with Bazel load outputs from packages
# that build with Bazel.
- name: 'gcr.io/learnjs-174218/release'
  dir: 'link-package'
  entrypoint: 'yarn'
  id: 'yarn-link-package'
  args: ['install']
  waitFor: ['bazel-tests']

- name: 'gcr.io/learnjs-174218/release'
  dir: 'link-package'
  entrypoint: 'yarn'
  id: 'yarn-link-package-build'
  args: ['build', '--bazel_options=--config=ci']
  waitFor: ['yarn-link-package']
  waitedForByPackages: true

# General configuration
secrets:
- kmsKeyName: projects/learnjs-174218/locations/global/keyRings/tfjs/cryptoKeys/enc
  secretEnv:
    BROWSERSTACK_KEY: CiQAkwyoIW0LcnxymzotLwaH4udVTQFBEN4AEA5CA+a3+yflL2ASPQAD8BdZnGARf78MhH5T9rQqyz9HNODwVjVIj64CTkFlUCGrP1B2HX9LXHWHLmtKutEGTeFFX9XhuBzNExA=
    FIREBASE_KEY: CiQAkwyoIXmET39jOD3ywloCIa6+WUpu3w49twpMmkMqy0vS+YsSUAAD8BdZQGOL8FKEBxr/1jl0G78OigwlNVHjD3usZobNtlOp8tV/9iacb8zPFqy0SwIO1gvz3HRr+VU7c7LS2qqaTCdacZF+dx3VJNewvdZu
timeout: 7200s
logsBucket: 'gs://tfjs-build-logs'
substitutions:
  _NIGHTLY: ''
options:
  logStreamingOption: 'STREAM_ON'
  machineType: 'E2_HIGHCPU_32'
  substitution_option: 'ALLOW_LOOSE'
