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:
- job: MatricesGenerator
displayName: Matrices Generator
pool:
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
steps:
- script: brew install p7zip
displayName: Install 7zip
- template: ci/steps.yml
vmImage: 'macOS-10.14'
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
matrix: $[ dependencies.MatricesGenerator.outputs['mtrx.mac'] ]
steps:
- script: brew install p7zip
displayName: Install 7zip
- template: ci/steps.yml
- job: Windows
dependsOn: MatricesGenerator
pool:
vmImage: vs2017-win2016
steps:
- template: ci/steps.yml
vmImage: 'vs2017-win2016'
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
matrix: $[ dependencies.MatricesGenerator.outputs['mtrx.windows'] ]
steps:
- template: ci/steps.yml
- job: Linux
dependsOn: MatricesGenerator
pool:
vmImage: ubuntu-16.04
steps:
- template: ci/steps.yml
vmImage: 'ubuntu-16.04'
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
matrix: $[ dependencies.MatricesGenerator.outputs['mtrx.linux'] ]
steps:
- template: ci/steps.yml
- job: LinuxSpecificMirror
displayName: Linux (Specific Mirror)
variables:
@@ -162,6 +52,6 @@ jobs:
ARCHDIR: android_armv7
QT_BASE_MIRROR: http://mirrors.ocf.berkeley.edu/qt/
pool:
vmImage: ubuntu-16.04
vmImage: 'ubuntu-16.04'
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 os
import json
from itertools import product
from ruamel.yaml import YAML
from ruamel.yaml.comments import CommentedMap
class BuildJob:
def __init__(self, qt_version, host, target, arch, archdir):
@@ -101,37 +98,25 @@ for android_arch in ['android_x86', 'android_armv7']:
matrices = {}
for platform_build_job in all_platform_build_jobs:
yaml_dictionary = collections.OrderedDict({
'matrix': CommentedMap()
})
matrix_dictionary = collections.OrderedDict()
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,
build_job.arch)
yaml_dictionary['matrix'][key] = \
{
'PYTHON_VERSION': python_version,
'QT_VERSION': build_job.qt_version,
'HOST': build_job.host,
'TARGET': build_job.target,
'ARCH': build_job.arch,
'ARCHDIR': build_job.archdir,
}
build_job.arch)
matrix_dictionary[key] = collections.OrderedDict(
[
('PYTHON_VERSION', python_version),
('QT_VERSION', build_job.qt_version),
('HOST', build_job.host),
('TARGET', build_job.target),
('ARCH', build_job.arch),
('ARCHDIR', build_job.archdir),
]
)
# CommentedMap wraps yaml_dictionary to suppress the !!omap annotation
matrices[platform_build_job.platform.capitalize()] = CommentedMap(yaml_dictionary)
matrices[platform_build_job.platform] = matrix_dictionary
root_dir = os.path.abspath(os.path.dirname(__file__))
# Load azure-pipelines.tmpl.yml
with open(os.path.join(root_dir, 'ci', 'azure-pipelines.tmpl.yml'), 'r') as f:
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
print("Setting Variables below")
print(f"##vso[task.setVariable variable=linux;isOutput=true]{json.dumps(matrices['linux'])}")
print(f"##vso[task.setVariable variable=windows;isOutput=true]{json.dumps(matrices['windows'])}")
print(f"##vso[task.setVariable variable=mac;isOutput=true]{json.dumps(matrices['mac'])}")