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:
    - doxygen
    - doxygen-doc
    - ninja-build
- name: pipModules
  type: object
  default:
    - cget
    - cmake==3.20.5
    - ninja
    - rocm-docs-core
    - sphinx

- name: jobMatrix
  type: object
  default:
    buildJobs:
      - { os: ubuntu2204, packageManager: apt }
      - { os: ubuntu2404, packageManager: apt }
      - { os: almalinux8, packageManager: dnf }

jobs:
- ${{ each job in parameters.jobMatrix.buildJobs }}:
  - job: rocm_cmake_${{ job.os }}
    pool:
      ${{ if eq(job.os, 'ubuntu2404') }}:
        vmImage: 'ubuntu-24.04'
      ${{ else }}:
        vmImage: 'ubuntu-22.04'
    ${{ if eq(job.os, 'almalinux8') }}:
      container:
        image: rocmexternalcicd.azurecr.io/manylinux228:latest
        endpoint: ContainerService3
    variables:
    - group: common
    - template: /.azuredevops/variables-global.yml
    workspace:
      clean: all
    steps:
    - template: ${{ variables.CI_TEMPLATE_PATH }}/steps/dependencies-other.yml
      parameters:
        aptPackages: ${{ parameters.aptPackages }}
        pipModules: ${{ parameters.pipModules }}
        packageManager: ${{ job.packageManager }}
    - task: Bash@3
      displayName: Add CMake to PATH
      inputs:
        targetType: inline
        script: echo "##vso[task.prependpath]$(python3 -m site --user-base)/bin"
    - 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/build-cmake.yml
      parameters:
        os: ${{ job.os }}
        useAmdclang: false
    - task: Bash@3
      displayName: CTest setup
      inputs:
        targetType: inline
        script: |
          python -m pip install -r $(Build.SourcesDirectory)/docs/requirements.txt
          python -m pip install -r $(Build.SourcesDirectory)/test/docsphinx/docs/.sphinx/requirements.txt
          git config --global user.email "you@example.com"
          git config --global user.name "Your Name"
    - template: ${{ variables.CI_TEMPLATE_PATH }}/steps/test.yml
      parameters:
        componentName: rocm-cmake
        testParameters: '-E "pass-version-parent" --output-on-failure --force-new-ctest-process --output-junit test_output.xml'
        os: ${{ job.os }}
    - template: ${{ variables.CI_TEMPLATE_PATH }}/steps/manifest.yml
      parameters:
        os: ${{ job.os }}
    - template: ${{ variables.CI_TEMPLATE_PATH }}/steps/artifact-upload.yml
      parameters:
        os: ${{ job.os }}
    - template: ${{ variables.CI_TEMPLATE_PATH }}/steps/artifact-links.yml
    # - template: ${{ variables.CI_TEMPLATE_PATH }}/steps/docker-container.yml
    #   parameters:
    #     aptPackages: ${{ parameters.aptPackages }}
    #     pipModules: ${{ parameters.pipModules }}
    #     environment: combined
