parameters:
- name: checkoutRepo
  type: string
  default: 'self'
- name: checkoutRef
  type: string
  default: ''
# set to true if doing full build of ROCm stack
# and dependencies are pulled from same pipeline
- name: aggregatePipeline
  type: boolean
  default: false
- name: aptPackages
  type: object
  default:
    - python3-pip
    - cmake
    - ninja-build
- name: rocmDependencies
  type: object
  default:
    - rocm-cmake
    - llvm-project
    - ROCR-Runtime
    - clr
    - rocminfo

jobs:
- job: half
  variables:
  - group: common
  - template: /.azuredevops/variables-global.yml
  pool:
    vmImage: ${{ variables.BASE_BUILD_POOL }}
  workspace:
    clean: all
  steps:
  - template: ${{ variables.CI_TEMPLATE_PATH }}/steps/dependencies-other.yml
    parameters:
      aptPackages: ${{ parameters.aptPackages }}
  - template: ${{ variables.CI_TEMPLATE_PATH }}/steps/preamble.yml
  - template: ${{ variables.CI_TEMPLATE_PATH }}/steps/checkout.yml
    parameters:
      checkoutRepo: ${{ parameters.checkoutRepo }}
  - template: ${{ variables.CI_TEMPLATE_PATH }}/steps/dependencies-rocm.yml
    parameters:
      checkoutRef: ${{ parameters.checkoutRef }}
      dependencyList: ${{ parameters.rocmDependencies }}
      aggregatePipeline: ${{ parameters.aggregatePipeline }}
  - template: ${{ variables.CI_TEMPLATE_PATH }}/steps/build-cmake.yml
    parameters:
      extraBuildFlags: >-
        -DCMAKE_PREFIX_PATH=$(Agent.BuildDirectory)/rocm
        -DBUILD_FILE_REORG_BACKWARD_COMPATIBILITY=OFF
        -GNinja
  - template: ${{ variables.CI_TEMPLATE_PATH }}/steps/manifest.yml
  - template: ${{ variables.CI_TEMPLATE_PATH }}/steps/artifact-upload.yml
  # only run test03 because test11 has too many test cases, taking way too long
  - task: Bash@3
    displayName: test03
    inputs:
      targetType: inline
      script: |
        make clean
        make test03
        ./bin/test
      workingDirectory: $(Build.SourcesDirectory)/test
  - template: ${{ variables.CI_TEMPLATE_PATH }}/steps/artifact-links.yml
  # - template: ${{ variables.CI_TEMPLATE_PATH }}/steps/docker-container.yml
  #   parameters:
  #     aptPackages: ${{ parameters.aptPackages }}
  #     environment: combined
