From f648318088388b1e159cb62489f0439f741b5c18 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 17 Dec 2025 21:49:46 +0100 Subject: [PATCH] Create sanity matrix. --- .azure-pipelines/azure-pipelines.yml | 89 +++++++++++++------ .azure-pipelines/scripts/run-nox.sh | 7 +- .azure-pipelines/scripts/setup-nox.sh | 7 +- .../templates/create-nox-matrix.yml | 24 +++++ .azure-pipelines/templates/run-nox.yml | 79 ++++++++-------- 5 files changed, 130 insertions(+), 76 deletions(-) create mode 100644 .azure-pipelines/templates/create-nox-matrix.yml diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index a783f243..d2dc56f4 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -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 diff --git a/.azure-pipelines/scripts/run-nox.sh b/.azure-pipelines/scripts/run-nox.sh index 9d16b67b..03a0e86b 100755 --- a/.azure-pipelines/scripts/run-nox.sh +++ b/.azure-pipelines/scripts/run-nox.sh @@ -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" diff --git a/.azure-pipelines/scripts/setup-nox.sh b/.azure-pipelines/scripts/setup-nox.sh index 03fe2f75..95f3a7d7 100755 --- a/.azure-pipelines/scripts/setup-nox.sh +++ b/.azure-pipelines/scripts/setup-nox.sh @@ -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" diff --git a/.azure-pipelines/templates/create-nox-matrix.yml b/.azure-pipelines/templates/create-nox-matrix.yml new file mode 100644 index 00000000..d3e86eba --- /dev/null +++ b/.azure-pipelines/templates/create-nox-matrix.yml @@ -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 diff --git a/.azure-pipelines/templates/run-nox.yml b/.azure-pipelines/templates/run-nox.yml index 02072dd8..a9075635 100644 --- a/.azure-pipelines/templates/run-nox.yml +++ b/.azure-pipelines/templates/run-nox.yml @@ -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)"