Use Azure Pipelines itself to generate and run test matrix from Python script

Instead of having to run a script on the developer's system and then committing the result, Azure Pipelines itself can run a modification of that script and reuse the variable it sets in later steps to determine the test matrices.

Reference: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/phases?view=azure-devops&tabs=yaml#multi-configuration

With this, `/azure-pipelines.yml` no longer needs to be treated like a committed generated artifact!

Closes #30.
This commit is contained in:
Nelson Chen
2019-06-01 16:42:26 -07:00
parent b360851600
commit ba5849026d
3 changed files with 55 additions and 215 deletions

View File

@@ -1,156 +1,46 @@
# Generated by `generate_azure_pipelines_yml.py`
# Please edit template in `ci/`
jobs: jobs:
- job: Mac - job: MatricesGenerator
displayName: Matrices Generator
pool: pool:
vmImage: macOS-10.14 vmImage: 'ubuntu-16.04'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
addToPath: true
- bash: python generate_azure_pipelines_matrices.py
name: mtrx
displayName: Generate test matrices and set variables in Azure Pipelines
- job: Mac
dependsOn: MatricesGenerator
pool:
vmImage: 'macOS-10.14'
strategy:
matrix: $[ dependencies.MatricesGenerator.outputs['mtrx.mac'] ]
steps: steps:
- script: brew install p7zip - script: brew install p7zip
displayName: Install 7zip displayName: Install 7zip
- template: ci/steps.yml - template: ci/steps.yml
strategy:
matrix:
QT 5.11.3 mac desktop clang_64:
PYTHON_VERSION: '3.7'
QT_VERSION: 5.11.3
HOST: mac
TARGET: desktop
ARCH: clang_64
ARCHDIR: clang_64
QT 5.12.3 mac desktop clang_64:
PYTHON_VERSION: '3.7'
QT_VERSION: 5.12.3
HOST: mac
TARGET: desktop
ARCH: clang_64
ARCHDIR: clang_64
QT 5.13.0 mac desktop clang_64:
PYTHON_VERSION: '3.7'
QT_VERSION: 5.13.0
HOST: mac
TARGET: desktop
ARCH: clang_64
ARCHDIR: clang_64
QT 5.13.0 mac ios ios:
PYTHON_VERSION: '3.7'
QT_VERSION: 5.13.0
HOST: mac
TARGET: ios
ARCH: ios
ARCHDIR: ios
- job: Windows - job: Windows
dependsOn: MatricesGenerator
pool: pool:
vmImage: vs2017-win2016 vmImage: 'vs2017-win2016'
strategy:
matrix: $[ dependencies.MatricesGenerator.outputs['mtrx.windows'] ]
steps: steps:
- template: ci/steps.yml - template: ci/steps.yml
strategy:
matrix:
QT 5.11.3 windows desktop win64_msvc2017_64:
PYTHON_VERSION: '3.7'
QT_VERSION: 5.11.3
HOST: windows
TARGET: desktop
ARCH: win64_msvc2017_64
ARCHDIR: msvc2017_64
QT 5.11.3 windows desktop win32_msvc2015:
PYTHON_VERSION: '3.7'
QT_VERSION: 5.11.3
HOST: windows
TARGET: desktop
ARCH: win32_msvc2015
ARCHDIR: msvc2015
QT 5.12.3 windows desktop win64_msvc2017_64:
PYTHON_VERSION: '3.7'
QT_VERSION: 5.12.3
HOST: windows
TARGET: desktop
ARCH: win64_msvc2017_64
ARCHDIR: msvc2017_64
QT 5.12.3 windows desktop win32_msvc2017:
PYTHON_VERSION: '3.7'
QT_VERSION: 5.12.3
HOST: windows
TARGET: desktop
ARCH: win32_msvc2017
ARCHDIR: msvc2017
QT 5.13.0 windows desktop win64_msvc2017_64:
PYTHON_VERSION: '3.7'
QT_VERSION: 5.13.0
HOST: windows
TARGET: desktop
ARCH: win64_msvc2017_64
ARCHDIR: msvc2017_64
QT 5.13.0 windows desktop win64_msvc2015_64:
PYTHON_VERSION: '3.7'
QT_VERSION: 5.13.0
HOST: windows
TARGET: desktop
ARCH: win64_msvc2015_64
ARCHDIR: msvc2015_64
QT 5.13.0 windows desktop win64_mingw73:
PYTHON_VERSION: '3.7'
QT_VERSION: 5.13.0
HOST: windows
TARGET: desktop
ARCH: win64_mingw73
ARCHDIR: mingw73_64
QT 5.13.0 windows desktop win32_msvc2017:
PYTHON_VERSION: '3.7'
QT_VERSION: 5.13.0
HOST: windows
TARGET: desktop
ARCH: win32_msvc2017
ARCHDIR: msvc2017
QT 5.13.0 windows desktop win32_mingw73:
PYTHON_VERSION: '3.7'
QT_VERSION: 5.13.0
HOST: windows
TARGET: desktop
ARCH: win32_mingw73
ARCHDIR: mingw73_32
- job: Linux - job: Linux
dependsOn: MatricesGenerator
pool: pool:
vmImage: ubuntu-16.04 vmImage: 'ubuntu-16.04'
strategy:
matrix: $[ dependencies.MatricesGenerator.outputs['mtrx.linux'] ]
steps: steps:
- template: ci/steps.yml - template: ci/steps.yml
strategy:
matrix:
QT 5.11.3 linux desktop gcc_64:
PYTHON_VERSION: '3.7'
QT_VERSION: 5.11.3
HOST: linux
TARGET: desktop
ARCH: gcc_64
ARCHDIR: gcc_64
QT 5.12.3 linux desktop gcc_64:
PYTHON_VERSION: '3.7'
QT_VERSION: 5.12.3
HOST: linux
TARGET: desktop
ARCH: gcc_64
ARCHDIR: gcc_64
QT 5.13.0 linux desktop gcc_64:
PYTHON_VERSION: '3.7'
QT_VERSION: 5.13.0
HOST: linux
TARGET: desktop
ARCH: gcc_64
ARCHDIR: gcc_64
QT 5.13.0 linux android android_x86:
PYTHON_VERSION: '3.7'
QT_VERSION: 5.13.0
HOST: linux
TARGET: android
ARCH: android_x86
ARCHDIR: android_x86
QT 5.13.0 linux android android_armv7:
PYTHON_VERSION: '3.7'
QT_VERSION: 5.13.0
HOST: linux
TARGET: android
ARCH: android_armv7
ARCHDIR: android_armv7
- job: LinuxSpecificMirror - job: LinuxSpecificMirror
displayName: Linux (Specific Mirror) displayName: Linux (Specific Mirror)
variables: variables:
@@ -162,6 +52,6 @@ jobs:
ARCHDIR: android_armv7 ARCHDIR: android_armv7
QT_BASE_MIRROR: http://mirrors.ocf.berkeley.edu/qt/ QT_BASE_MIRROR: http://mirrors.ocf.berkeley.edu/qt/
pool: pool:
vmImage: ubuntu-16.04 vmImage: 'ubuntu-16.04'
steps: steps:
- template: ci/steps.yml - template: ci/steps.yml

View File

@@ -1,35 +0,0 @@
# Generated by `generate_azure_pipelines_yml.py`
# Please edit template in `ci/`
jobs:
- job: Mac
pool:
vmImage: 'macOS-10.14'
steps:
- script: brew install p7zip
displayName: Install 7zip
- template: ci/steps.yml
- job: Windows
pool:
vmImage: 'vs2017-win2016'
steps:
- template: ci/steps.yml
- job: Linux
pool:
vmImage: 'ubuntu-16.04'
steps:
- template: ci/steps.yml
- job: LinuxSpecificMirror
displayName: Linux (Specific Mirror)
variables:
PYTHON_VERSION: '3.7'
QT_VERSION: 5.13.0
HOST: linux
TARGET: android
ARCH: android_armv7
ARCHDIR: android_armv7
QT_BASE_MIRROR: http://mirrors.ocf.berkeley.edu/qt/
pool:
vmImage: 'ubuntu-16.04'
steps:
- template: ci/steps.yml

View File

@@ -1,13 +1,10 @@
""" """
This generates a matrix of QT versions to test downloading against This sets variables for a matrix of QT versions to test downloading against with Azure Pipelines
""" """
import collections import collections
import os import json
from itertools import product from itertools import product
from ruamel.yaml import YAML
from ruamel.yaml.comments import CommentedMap
class BuildJob: class BuildJob:
def __init__(self, qt_version, host, target, arch, archdir): def __init__(self, qt_version, host, target, arch, archdir):
@@ -101,37 +98,25 @@ for android_arch in ['android_x86', 'android_armv7']:
matrices = {} matrices = {}
for platform_build_job in all_platform_build_jobs: for platform_build_job in all_platform_build_jobs:
yaml_dictionary = collections.OrderedDict({ matrix_dictionary = collections.OrderedDict()
'matrix': CommentedMap()
})
for build_job, python_version in product(platform_build_job.build_jobs, python_versions): for build_job, python_version in product(platform_build_job.build_jobs, python_versions):
key = 'QT {} {} {} {}'.format(build_job.qt_version, build_job.host, build_job.target, key = 'QT {} {} {} {}'.format(build_job.qt_version, build_job.host, build_job.target,
build_job.arch) build_job.arch)
yaml_dictionary['matrix'][key] = \ matrix_dictionary[key] = collections.OrderedDict(
{ [
'PYTHON_VERSION': python_version, ('PYTHON_VERSION', python_version),
'QT_VERSION': build_job.qt_version, ('QT_VERSION', build_job.qt_version),
'HOST': build_job.host, ('HOST', build_job.host),
'TARGET': build_job.target, ('TARGET', build_job.target),
'ARCH': build_job.arch, ('ARCH', build_job.arch),
'ARCHDIR': build_job.archdir, ('ARCHDIR', build_job.archdir),
} ]
)
# CommentedMap wraps yaml_dictionary to suppress the !!omap annotation matrices[platform_build_job.platform] = matrix_dictionary
matrices[platform_build_job.platform.capitalize()] = CommentedMap(yaml_dictionary)
root_dir = os.path.abspath(os.path.dirname(__file__)) print("Setting Variables below")
print(f"##vso[task.setVariable variable=linux;isOutput=true]{json.dumps(matrices['linux'])}")
# Load azure-pipelines.tmpl.yml print(f"##vso[task.setVariable variable=windows;isOutput=true]{json.dumps(matrices['windows'])}")
with open(os.path.join(root_dir, 'ci', 'azure-pipelines.tmpl.yml'), 'r') as f: print(f"##vso[task.setVariable variable=mac;isOutput=true]{json.dumps(matrices['mac'])}")
azure_pipelines_yaml = YAML().load(f.read())
# Attach strategies to their respective jobs
for job_yaml in azure_pipelines_yaml['jobs']:
if job_yaml['job'] in matrices:
job_yaml['strategy'] = matrices[job_yaml['job']]
with open(os.path.join(root_dir, 'azure-pipelines.yml'), 'w') as f:
YAML().dump(azure_pipelines_yaml, f)
pass