Create sanity matrix.

This commit is contained in:
Felix Fontein 2025-12-17 21:49:46 +01:00
parent 7eaad3b866
commit f648318088
5 changed files with 130 additions and 76 deletions

View File

@ -38,6 +38,11 @@ variables:
value: .azure-pipelines/scripts/run-nox.sh
- name: fetchDepth
value: 0
- name: minAnsibleCore
value: "2.17"
- name: noxSource
# value: https://github.com/ansible-community/antsibull-nox/archive/main.tar.gz
value: https://github.com/felixfontein/antsibull-nox/archive/azp.tar.gz
resources:
containers:
@ -50,33 +55,65 @@ stages:
- stage: nox
displayName: Run extra sanity tests
dependsOn: []
jobs:
- template: templates/run-nox.yml
parameters:
jobs:
- job: extra_sanity
name: Extra sanity tests
- job: extra_sanity
displayName: Extra sanity tests
container: default
workspace:
clean: all
steps:
- template: templates/run-nox.yml
parameters:
sessions: ""
# - stage: create-matrixes
# displayName: Create matrixes
# jobs:
# - job: A
# steps:
# - task: Bash@3
# inputs:
# filePath: 'script-a.sh'
# name: setvar
# - bash: |
# echo "##vso[task.setVariable variable=legs;isOutput=true]{'a':{'myvar':'A'}, 'b':{'myvar':'B'}}"
# name: mtrx
- stage: create_matrixes
displayName: Create matrixes
dependsOn: []
jobs:
- template: templates/create-nox-matrix.yml
# - stage: sanity
# displayName: Sanity tests
# dependsOn: create-matrixes
# - job: runner
# dependsOn: generator
# strategy:
# matrix: $[ stageDependencies.create-matrixes.A.outputs['mtrx.legs'] ]
# steps:
# - script: echo $(myvar) # echos A or B depending on which leg is running
- stage: sanity
displayName: Sanity tests
dependsOn: create_matrixes
jobs:
- job: sanity
strategy:
matrix: >-
$[ coalesce(stageDependencies.create_matrixes.create_matrixes.outputs['matrix.sanity'], '{"none": {"display_name": "(none)", "skip": true}}') ]
displayName: "$[ variables.display_name ]"
container: default
workspace:
clean: all
steps:
- template: templates/run-nox.yml
parameters:
sessions: $(name)
- stage: foo
displayName: Foo tests
dependsOn: create_matrixes
jobs:
- job: foo
strategy:
matrix: >-
$[ coalesce(stageDependencies.create_matrixes.create_matrixes.outputs['matrix.foo'], '{"none": {"display_name": "(none)", "skip": true}}') ]
displayName: "$[ variables.display_name ]"
container: default
workspace:
clean: all
steps:
- template: templates/run-nox.yml
parameters:
sessions: $(name)
- stage: Summary
condition: succeededOrFailed()
dependsOn:
- nox
- sanity
# - units
# - integration
- foo
jobs:
- template: templates/coverage.yml

View File

@ -5,9 +5,10 @@
set -o pipefail -e
SESSIONS=""
declare -a SESSIONS
if [ "$1" != "" ]; then
SESSIONS="--sessions $1"
IFS=' ' read -ra SESSIONS <<< "$1"
SESSIONS=('--sessions' "${SESSIONS[@]}")
fi
export FORCE_COLOR=1
@ -15,4 +16,4 @@ export ANTSIBULL_NOX_IGNORE_INSTALLED_COLLECTIONS=true
# ANTSIBULL_CHANGE_DETECTION: "${{ inputs.change-detection }}"
# ANTSIBULL_BASE_BRANCH: "${{ inputs.change-detection-base-branch }}"
nox --verbose --reuse-existing-virtualenvs --no-install ${SESSIONS} 2>&1 | "$(dirname "$0")/time-command.py"
nox --verbose --reuse-existing-virtualenvs --no-install "${SESSIONS[@]}" 2>&1 | "$(dirname "$0")/time-command.py"

View File

@ -5,13 +5,14 @@
set -o pipefail -e
SESSIONS=""
declare -a SESSIONS
if [ "$1" != "" ]; then
SESSIONS="--sessions $1"
IFS=' ' read -ra SESSIONS <<< "$1"
SESSIONS=('--sessions' "${SESSIONS[@]}")
fi
export FORCE_COLOR=1
export ANTSIBULL_NOX_IGNORE_INSTALLED_COLLECTIONS=true
echo "Set up nox environments"
nox --verbose --install-only ${SESSIONS} 2>&1 | "$(dirname "$0")/time-command.py"
nox --verbose --install-only "${SESSIONS[@]}" 2>&1 | "$(dirname "$0")/time-command.py"

View File

@ -0,0 +1,24 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# This template runs antsibull-nox' matrix generator
jobs:
- job: create_matrixes
displayName: Create matrixes
container: default
workspace:
clean: all
steps:
- checkout: self
fetchDepth: $(fetchDepth)
- bash: pip install $(noxSource)
displayName: Install nox and antsibull-nox
- bash: |
export FORCE_COLOR=1
export AZP_STDOUT=true
nox --session matrix-generator -- --min-ansible-core $(minAnsibleCore) 2>&1
displayName: Run nox
name: matrix

View File

@ -3,50 +3,41 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# This template uses the provided list of jobs to create test one or more nox jobs.
# This template creates steps for job that runs a nox session
parameters:
# A required list of dictionaries, one per nox job.
# Each item in the list must contain a "job", "name", and "sessions" key.
- name: jobs
type: object
- name: sessions
type: string
jobs:
- ${{ each job in parameters.jobs }}:
- job: ${{ job.job }}
displayName: ${{ job.name }}
container: default
workspace:
clean: all
steps:
- checkout: self
fetchDepth: $(fetchDepth)
- bash: pip install https://github.com/ansible-community/antsibull-nox/archive/main.tar.gz
displayName: Install nox and antsibull-nox
- bash: .azure-pipelines/scripts/setup-nox.sh "${{ job.sessions }}"
displayName: Setup nox environments
- bash: .azure-pipelines/scripts/run-nox.sh "${{ job.sessions }}"
displayName: Run nox
- bash: .azure-pipelines/scripts/process-results.sh
condition: succeededOrFailed()
displayName: Process Results
# - bash: .azure-pipelines/scripts/aggregate-coverage.sh "$(Agent.TempDirectory)"
# condition: eq(variables.haveCoverageData, 'true')
# displayName: Aggregate Coverage Data
# - task: PublishTestResults@2
# condition: eq(variables.haveTestResults, 'true')
# inputs:
# testResultsFiles: "$(outputPath)/junit/*.xml"
# displayName: Publish Test Results
# - task: PublishPipelineArtifact@1
# condition: eq(variables.haveBotResults, 'true')
# displayName: Publish Bot Results
# inputs:
# targetPath: "$(outputPath)/bot/"
# artifactName: "Bot $(System.JobAttempt) $(System.StageDisplayName) $(System.JobDisplayName)"
# - task: PublishPipelineArtifact@1
# condition: eq(variables.haveCoverageData, 'true')
# displayName: Publish Coverage Data
# inputs:
# targetPath: "$(Agent.TempDirectory)/coverage/"
# artifactName: "Coverage $(System.JobAttempt) $(System.StageDisplayName) $(System.JobDisplayName)"
steps:
- checkout: self
fetchDepth: $(fetchDepth)
- bash: pip install $(noxSource)
displayName: Install nox and antsibull-nox
- bash: .azure-pipelines/scripts/setup-nox.sh "${{ parameters.sessions }}"
displayName: Setup nox environments
- bash: .azure-pipelines/scripts/run-nox.sh "${{ parameters.sessions }}"
displayName: Run nox
- bash: .azure-pipelines/scripts/process-results.sh
condition: succeededOrFailed()
displayName: Process Results
- bash: .azure-pipelines/scripts/aggregate-coverage.sh "$(Agent.TempDirectory)"
condition: eq(variables.haveCoverageData, 'true')
displayName: Aggregate Coverage Data
- task: PublishTestResults@2
condition: eq(variables.haveTestResults, 'true')
inputs:
testResultsFiles: "$(outputPath)/junit/*.xml"
displayName: Publish Test Results
- task: PublishPipelineArtifact@1
condition: eq(variables.haveBotResults, 'true')
displayName: Publish Bot Results
inputs:
targetPath: "$(outputPath)/bot/"
artifactName: "Bot $(System.JobAttempt) $(System.StageDisplayName) $(System.JobDisplayName)"
- task: PublishPipelineArtifact@1
condition: eq(variables.haveCoverageData, 'true')
displayName: Publish Coverage Data
inputs:
targetPath: "$(Agent.TempDirectory)/coverage/"
artifactName: "Coverage $(System.JobAttempt) $(System.StageDisplayName) $(System.JobDisplayName)"