parameters:
    job_name: ''
    image_name: 'ubuntu-16.04'
    container: ''
    python_path: ''
    python_version: ''
    package_manager: yum
    install_python: ''
    install_packages: |
        set -e -x
        sudo yum groupinstall -y "Development Tools"
        sudo yum install -y \
            openssl openssl-devel \
            sqlite-devel zlib-devel xz-devel bzip2-devel \
            bzip2 tar unzip zip \
            libxml2-devel libxslt-devel
    test_suite: ''
    test_suite_label: ''


jobs:
    - job: ${{ parameters.job_name }}

      pool:
          vmImage: ${{ parameters.image_name }}

      container:
          image: ${{ parameters.container }}
          options: '--name ${{ parameters.job_name }} -e LANG=C.UTF-8 -e LC_ALL=C.UTF-8 -v /usr/bin/docker:/tmp/docker:ro'

      steps:
          - checkout: self
            fetchDepth: 10

          - script: /tmp/docker exec -t -e LANG=C.UTF-8 -e LC_ALL=C.UTF-8 -u 0 ${{ parameters.job_name }} $(Build.SourcesDirectory)/etc/ci/install_sudo.sh ${{ parameters.package_manager }}
            displayName: Install sudo

          - script: ${{ parameters.install_packages }}
            displayName: Install required packages

          - script: ${{ parameters.install_python }}
            displayName: 'Install Python ${{ parameters.python_version }}'

          - script: ${{ parameters.python_path }} --version
            displayName: 'Show Python version'

          - script: PYTHON_EXE=${{ parameters.python_path }} ./configure --dev
            displayName: 'Run Configure'

          - script: ${{ parameters.test_suite }}
            displayName: 'Run ${{ parameters.test_suite_label }} tests with py${{ parameters.python_version }} on ${{ parameters.job_name }}'
