CI: make Python version configurable

Add a new parameter "usePythonVersion" to the CI job templates.
This makes it possible to specify the version of Python to use.
The default value is '', in which case Python will not be downloaded
at runtime and the one provided by the VM/container image will be used.

Additionally, add a template .azurepipelines/templates/defaults.yml,
from which the default Pyhton version string can be obtained.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Chris Fernald <chfernal@microsoft.com>
This commit is contained in:
Oliver Steffen 2023-01-16 18:40:28 +01:00 committed by mergify[bot]
parent 015a001b03
commit 3579551734
6 changed files with 30 additions and 7 deletions

View File

@ -13,13 +13,13 @@ pr:
- master
- stable/*
variables:
- template: templates/defaults.yml
jobs:
- template: templates/pr-gate-build-job.yml
parameters:
tool_chain_tag: 'GCC5'
vm_image: 'ubuntu-latest'
arch_list: "IA32,X64,ARM,AARCH64,RISCV64,LOONGARCH64"
extra_install_step:
- bash: sudo apt-get install -y lcov
displayName: Install Code Coverage Tools
condition: and(gt(variables.pkg_count, 0), succeeded())
usePythonVersion: ${{ variables.default_python_version }}

View File

@ -12,12 +12,16 @@ pr:
- master
- stable/*
variables:
- template: templates/defaults.yml
jobs:
- template: templates/pr-gate-build-job.yml
parameters:
tool_chain_tag: 'VS2019'
vm_image: 'windows-2019'
arch_list: "IA32,X64"
usePythonVersion: ${{ variables.default_python_version }}
extra_install_step:
- powershell: choco install opencppcoverage; Write-Host "##vso[task.prependpath]C:\Program Files\OpenCppCoverage"
displayName: Install Code Coverage Tool

View File

@ -0,0 +1,11 @@
## @file
# File templates/default.yml
#
# template file containing common default values
#
# Copyright (c) Red Hat, Inc.
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
variables:
default_python_version: ">=3.10.6"

View File

@ -34,6 +34,9 @@ parameters:
- name: extra_install_step
type: stepList
default: []
- name: usePythonVersion
type: string
default: ''
steps:
- checkout: self
@ -42,8 +45,9 @@ steps:
- task: UsePythonVersion@0
inputs:
versionSpec: ">=3.10.6"
versionSpec: ${{ parameters.usePythonVersion }}
architecture: "x64"
condition: ne('${{ parameters.usePythonVersion }}', '')
- script: pip install -r pip-requirements.txt --upgrade
displayName: 'Install/Upgrade pip modules'

View File

@ -13,6 +13,7 @@ parameters:
vm_image: ''
arch_list: ''
extra_install_step: []
usePythonVersion: ''
# Build step
jobs:
@ -78,6 +79,7 @@ jobs:
build_pkgs: $(Build.Pkgs)
build_targets: $(Build.Targets)
build_archs: ${{ parameters.arch_list }}
usePythonVersion: ${{ parameters.usePythonVersion }}
extra_install_step: ${{ parameters.extra_install_step }}
- job: Build_${{ parameters.tool_chain_tag }}_TARGET_CODE_COVERAGE

View File

@ -12,6 +12,7 @@ parameters:
build_pkgs: ''
build_targets: ''
build_archs: ''
usePythonVersion: ''
extra_install_step: []
steps:
@ -21,8 +22,9 @@ steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '>=3.10.6'
architecture: 'x64'
versionSpec: ${{ parameters.usePythonVersion }}
architecture: "x64"
condition: ne('${{ parameters.usePythonVersion }}', '')
- script: pip install -r pip-requirements.txt --upgrade
displayName: 'Install/Upgrade pip modules'