type: Group
instructions:
    - type: EnvironmentVariable
      variableName: QTEST_ENVIRONMENT
      variableValue: "ci"
    - type: EnvironmentVariable
      variableName: PYTHON_BUILD_MIRROR_URL
      variableValue: "https://ci-files01-hki.ci.qt.io/input/python/"
    - type: EnvironmentVariable
      variableName: PYTHON_BUILD_MIRROR_URL_SKIP_CHECKSUM
      variableValue: "1"
    - type: EnvironmentVariable
      variableName: PYSIDE_VIRTUALENV
      variableValue: "{{.AgentWorkingDir}}\\pyside\\pyside-setup\\env"
      enable_if:
          condition: property
          property: host.os
          equals_value: Windows
    - type: EnvironmentVariable
      variableName: PYSIDE_VIRTUALENV
      variableValue: "{{.AgentWorkingDir}}/pyside/pyside-setup/env"
      enable_if:
        condition: or
        conditions:
          - condition: property
            property: host.os
            equals_value: MacOS
          - condition: property
            property: host.os
            equals_value: Linux
    - type: EnvironmentVariable
      variableName: TARGET_ARCHITECTURE
      variableValue: amd64
      enable_if:
        condition: and
        conditions:
          - condition: property
            property: target.arch
            equals_value: X86_64
          - condition: property
            property: host.os
            equals_value: Windows
    - type: EnvironmentVariable
      variableName: PYTHON3_PATH
      variableValue: "{{ index .Env \"PYTHON3.10.0-64_PATH\"}}"
      enable_if:
        condition: and
        conditions:
          - condition: property
            property: host.osVersion
            equals_value: Windows_11_22H2
          - condition: property
            property: host.os
            equals_value: Windows
          - condition: property
            property: host.arch
            not_equals_value: AARCH64
    - type: EnvironmentVariable
      variableName: PYTHON3_PATH
      variableValue: "{{ index .Env \"PYTHON3.11.9-64_PATH\"}}"
      enable_if:
        condition: and
        conditions:
          - condition: property
            property: host.os
            equals_value: Windows
          - condition: property
            property: host.arch
            equals_value: AARCH64
    - type: EnvironmentVariable
      variableName: TARGET_ARCHITECTURE
      variableValue: arm64
      enable_if:
        condition: and
        conditions:
          - condition: property
            property: target.arch
            equals_value: AARCH64
          - condition: property
            property: host.os
            equals_value: Windows
    - type: EnvironmentVariable
      variableName: TARGET_ARCHITECTURE
      variableValue: amd64_x86
      enable_if:
        condition: and
        conditions:
          - condition: property
            property: target.arch
            equals_value: X86
          - condition: property
            property: host.os
            equals_value: Windows
    - type: EnvironmentVariable
      variableName: CI_TARGET_ARCHITECTURE
      variableValue: X86_64
      enable_if:
          condition: property
          property: target.arch
          equals_value: X86_64
    - type: EnvironmentVariable
      variableName: CI_TARGET_ARCHITECTURE
      variableValue: X86
      enable_if:
          condition: property
          property: target.arch
          equals_value: X86
    - type: EnvironmentVariable
      variableName: CI_PACKAGING_FEATURE
      variableValue: "--packaging"
      enable_if:
          condition: property
          property: features
          contains_value: Packaging
    - type: EnvironmentVariable
      variableName: CI_USE_SCCACHE
      variableValue: "--compiler-launcher=sccache"
      enable_if:
          condition: property
          property: features
          contains_value: Sccache
    - type: EnvironmentVariable
      variableName: CI_OS
      variableValue: "MacOS"
      enable_if:
          condition: property
          property: host.os
          equals_value: MacOS
    - type: EnvironmentVariable
      variableName: CI_OS
      variableValue: "Linux"
      enable_if:
          condition: property
          property: host.os
          equals_value: Linux
    - type: EnvironmentVariable
      variableName: CI_OS
      variableValue: "Windows"
      enable_if:
          condition: property
          property: host.os
          equals_value: Windows
    - type: EnvironmentVariable
      variableName: MAKEFLAGS
      variableValue: ""
      enable_if:
         condition: property
         property: host.os
         equals_value: Windows
    - type: AppendToEnvironmentVariable
      variableName: PATH
      variableValue: ;%CI_JOM_PATH%
      enable_if:
         condition: property
         property: host.os
         equals_value: Windows
    - type: PrependToEnvironmentVariable
      variableName: PATH
      variableValue: "{{.Env.PYTHON3_PATH}}:"
      enable_if:
         condition: property
         property: host.os
         equals_value: MacOS
    - type: PrependToEnvironmentVariable
      variableName: PATH
      variableValue: "{{ index .Env \"PYTHON3.10.0-64_PATH\"}};"
      enable_if:
         condition: property
         property: host.os
         equals_value: Windows
    - type: PrependToEnvironmentVariable
      variableName: PATH
      variableValue: "/Users/qt/.local/bin/:"
      enable_if:
         condition: property
         property: host.os
         equals_value: MacOS
    - type: PrependToEnvironmentVariable
      variableName: PATH
      variableValue: "/Users/qt/work/install/bin:"
      enable_if:
         condition: property
         property: host.os
         equals_value: MacOS
    - type: PrependToEnvironmentVariable
      variableName: PATH
      variableValue: "/home/qt/work/install/bin:"
      enable_if:
         condition: property
         property: host.os
         equals_value: Linux
    - type: PrependToEnvironmentVariable
      variableName: PATH
      variableValue: "\\Users\\qt\\work\\install\\bin;"
      enable_if:
         condition: property
         property: host.os
         equals_value: Windows
    - type: EnvironmentVariable
      variableName: ICC64_18_LDLP
      variableValue: /opt/intel/lib/intel64
      enable_if:
         condition: property
         property: target.compiler
         equals_value: ICC_18
    - type: EnvironmentVariable
      variableName: PYTHON3_PATH
      variableValue: "{{ index .Env \"PYTHON3.10.0-64_PATH\"}}"
      enable_if:
          condition: and
          conditions:
            - condition: property
              property: host.os
              equals_value: Windows
            - condition: property
              property: host.arch
              equals_value: X86_64
    - type: EnvironmentVariable
      variableName: ICC64_18_PATH # Seems a bit hard to maintain
      variableValue: /opt/intel/compilers_and_libraries_2018.1.163/linux/bin/intel64:/opt/intel/bin
      enable_if:
         condition: property
         property: target.compiler
         equals_value: ICC_18
    - type: AppendToEnvironmentVariable
      variableName: LD_LIBRARY_PATH
      variableValue: :/opt/intel/lib/intel64
      enable_if:
         condition: property
         property: target.compiler
         equals_value: ICC_18
    - type: AppendToEnvironmentVariable
      variableName: PATH
      variableValue: ":{{.Env.ICC64_18_PATH}}"
      enable_if:
         condition: property
         property: target.compiler
         equals_value: ICC_18
    - type: ExecuteCommand
      command: "sudo apt-get install python3-pip -y"
      maxTimeInSeconds: 14400
      maxTimeBetweenOutput: 1200
      enable_if:
          condition: and
          conditions:
            - condition: property
              property: host.os
              equals_value: Linux
            - condition: property
              property: host.arch
              equals_value: AARCH64
      userMessageOnFailure: >
          Failed to install dependencies
    - type: ExecuteCommand
      command: "chmod +x coin/fetch_libclang_arm64.sh"
      maxTimeInSeconds: 14400
      maxTimeBetweenOutput: 1200
      enable_if:
          condition: and
          conditions:
            - condition: property
              property: host.os
              equals_value: Linux
            - condition: property
              property: host.arch
              equals_value: AARCH64
      userMessageOnFailure: >
          Failed to make coin/fetch_libclang_arm64.sh executable
    - type: ExecuteCommand
      command: "coin/fetch_libclang_arm64.sh"
      maxTimeInSeconds: 14400
      maxTimeBetweenOutput: 1200
      enable_if:
          condition: and
          conditions:
            - condition: property
              property: host.os
              equals_value: Linux
            - condition: property
              property: host.arch
              equals_value: AARCH64
      userMessageOnFailure: >
          Failed to download libclang from Qt servers
    - type: ExecuteCommand
      command: ["powershell", "-ExecutionPolicy", "Bypass", "-File", "coin\\fetch_libclang_arm64.ps1"]
      maxTimeInSeconds: 14400
      maxTimeBetweenOutput: 1200
      enable_if:
          condition: and
          conditions:
            - condition: property
              property: host.os
              equals_value: Windows
            - condition: property
              property: host.arch
              equals_value: AARCH64
      userMessageOnFailure: >
          Failed to download libclang from Qt servers
    - type: EnvironmentVariable
      variableName: LLVM_INSTALL_DIR
      variableValue: "/home/qt/libclang"
      enable_if:
        condition: and
        conditions:
          - condition: property
            property: target.arch
            equals_value: AARCH64
          - condition: property
            property: host.os
            equals_value: Linux
    - type: EnvironmentVariable
      variableName: LLVM_INSTALL_DIR
      variableValue: "\\utils\\libclang"
      enable_if:
        condition: and
        conditions:
          - condition: property
            property: target.arch
            equals_value: AARCH64
          - condition: property
            property: host.os
            equals_value: Windows
    - type: EnvironmentVariable
      variableName: interpreter
      variableValue: "python3.11"
      enable_if:
         condition: property
         property: host.osVersion
         in_values: [RHEL_8_6, RHEL_8_8, RHEL_8_10]
    - type: EnvironmentVariable
      variableName: interpreter
      variableValue: "python3"
      enable_if: # Enable for others than rhl 8.*
        condition: property
        property: host.osVersion
        not_in_values: [RHEL_8_6, RHEL_8_8, RHEL_8_10]


    - type: ExecuteCommand
      command: "pyenv install 3.11.9"
      maxTimeInSeconds: 14400
      maxTimeBetweenOutput: 1200
      ignoreExitCode: true
      enable_if:
          condition: and
          conditions:
          - condition: property
            property: host.osVersion
            in_values: [MacOS_13, MacOS_14]
          - condition: property
            property: host.arch
            equals_value: ARM64
      userMessageOnFailure: >
          Failed to install python 3.11
    - type: PrependToEnvironmentVariable
      variableName: PATH
      variableValue: "/Users/qt/.pyenv/versions/3.11.9/bin:"
      enable_if:
          condition: and
          conditions:
          - condition: property
            property: host.osVersion
            in_values: [MacOS_13, MacOS_14]
          - condition: property
            property: host.arch
            equals_value: ARM64
    - type: EnvironmentVariable
      variableName: interpreter
      variableValue: "python3.11"
      enable_if:
          condition: and
          conditions:
          - condition: property
            property: host.osVersion
            in_values: [MacOS_13, MacOS_14]
          - condition: property
            property: host.arch
            equals_value: ARM64

    - type: ExecuteCommand
      command: "pyenv install 3.13.7"
      maxTimeInSeconds: 14400
      maxTimeBetweenOutput: 1200
      ignoreExitCode: true
      enable_if:
          condition: and
          conditions:
          - condition: property
            property: host.osVersion
            equals_value: MacOS_15
          - condition: property
            property: host.arch
            equals_value: ARM64
      userMessageOnFailure: >
          Failed to install python 3.13
    - type: PrependToEnvironmentVariable
      variableName: PATH
      variableValue: "/Users/qt/.pyenv/versions/3.13.7/bin:"
      enable_if:
          condition: and
          conditions:
          - condition: property
            property: host.osVersion
            equals_value: MacOS_15
          - condition: property
            property: host.arch
            equals_value: ARM64
    - type: EnvironmentVariable
      variableName: interpreter
      variableValue: "python3.13"
      enable_if:
          condition: and
          conditions:
          - condition: property
            property: host.osVersion
            equals_value: MacOS_15
          - condition: property
            property: host.arch
            equals_value: ARM64

    - type: ExecuteCommand
      command: "sudo subscription-manager refresh"
      ignoreExitCode: true
      maxTimeInSeconds: 6000
      maxTimeBetweenOutput: 1200
      enable_if:
          condition: property
          property: host.osVersion
          in_values: [RHEL_9_4, RHEL_9_6]
      userMessageOnFailure: >
        Failed to refresh subscription.

    - type: ExecuteCommand
      command: "sudo yum -y install python3.11-devel python3.11-pip"
      maxTimeInSeconds: 14400
      maxTimeBetweenOutput: 1200
      enable_if:
          condition: property
          property: host.osVersion
          in_values: [RHEL_9_4, RHEL_9_6]
      userMessageOnFailure: >
          Failed to install python 3.11

    - type: EnvironmentVariable
      variableName: interpreter
      variableValue: "python3.11"
      enable_if:
          condition: property
          property: host.osVersion
          in_values: [RHEL_9_4, RHEL_9_6]

    # Use pyenv to install Python 3.11 on macOS+Android
    - type: ExecuteCommand
      command: "pyenv install 3.11.9"
      maxTimeInSeconds: 14400
      maxTimeBetweenOutput: 1200
      ignoreExitCode: true
      enable_if:
          condition: and
          conditions:
          - condition: property
            property: host.os
            equals_value: MacOS
          - condition: property
            property: target.os
            equals_value: Android
      userMessageOnFailure: >
          Failed to install python 3.11 with pyenv
    - type: PrependToEnvironmentVariable
      variableName: PATH
      variableValue: "/Users/qt/.pyenv/versions/3.11.9/bin:"
      enable_if:
          condition: and
          conditions:
          - condition: property
            property: host.os
            equals_value: MacOS
          - condition: property
            property: target.os
            equals_value: Android
    - type: ExecuteCommand
      command: "virtualenv -p {{.Env.interpreter}} {{.AgentWorkingDir}}/env"
      maxTimeInSeconds: 14400
      maxTimeBetweenOutput: 1200
      enable_if:
          condition: or
          conditions:
          - condition: property
            property: host.os
            equals_value: Linux
          - condition: property
            property: host.os
            equals_value: MacOS
      userMessageOnFailure: >
          Failed to create env
    - type: EnvironmentVariable
      variableName: ENV_PYTHON
      variableValue: "{{.AgentWorkingDir}}/env/bin/python"
    - type: AppendToEnvironmentVariable
      variableName: PATH
      variableValue: ":{{.AgentWorkingDir}}/env/bin/"
      enable_if: # Enable for others than rhl 8.*
        condition: property
        property: target.os
        equals_value: Android


