Skip to content

Commit 1dad47a

Browse files
[AUTO-CHERRYPICK] Separated toolchain tests from non-toolchain package builds. - branch main (#10448)
Co-authored-by: Pawel Winogrodzki <pawelwi@microsoft.com>
1 parent 1b5b551 commit 1dad47a

4 files changed

Lines changed: 129 additions & 35 deletions

File tree

.pipelines/prchecks/PackageBuildPRCheck.yml

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ variables:
3939
value: RPMs
4040
- name: toolchainArtifactNameBase
4141
value: Toolchain
42+
- name: toolchainTestsArtifactNameBase
43+
value: Toolchain_tests
4244
- name: system.debug
43-
value: '${{ parameters.debug }}'
45+
value: "${{ parameters.debug }}"
4446

4547
extends:
4648
template: v2/OneBranch.NonOfficial.CrossPlat.yml@templates
@@ -74,6 +76,9 @@ extends:
7476
# Toolchain package tests should be run through the full package build, calculate the list of packages that should be re-tested
7577
# and make it available to the next stage via an output variable: 'CalculateToolchainPackageRetestList.toolchainPackageRetestList'
7678
- template: .pipelines/templates/ToolchainCalculatePackageRetests.yml@self
79+
parameters:
80+
# GCC fails to build as a regular package.
81+
ignoredSpecs: ["gcc"]
7782

7883
- script: echo "##vso[task.setvariable variable=toolchainArtifactName;isOutput=true]$(ob_artifactBaseName)"
7984
name: "ToolchainArtifactName"
@@ -99,9 +104,8 @@ extends:
99104
isCustom: true
100105
name: ${{ configuration.agentPool }}
101106
variables:
102-
ob_artifactBaseName: ${{ variables.rpmsArtifactNameBase }}_${{ configuration.name }}_$(System.JobAttempt)
107+
ob_artifactBaseName: $(rpmsArtifactNameBase)_${{ configuration.name }}_$(System.JobAttempt)
103108
ob_outputDirectory: $(Build.ArtifactStagingDirectory)
104-
testListFromToolchain: $[ stageDependencies.Toolchain_${{ configuration.name }}.Build.outputs['CalculateToolchainPackageRetestList.toolchainPackageRetestList'] ]
105109
toolchainArtifactName: $[ stageDependencies.Toolchain_${{ configuration.name }}.Build.outputs['ToolchainArtifactName.toolchainArtifactName'] ]
106110
steps:
107111
- template: .pipelines/templates/PackageBuild.yml@self
@@ -111,25 +115,62 @@ extends:
111115
isCheckBuild: true
112116
isQuickRebuildPackages: true
113117
isUseCCache: true
114-
outputArtifactsFolder: $(ob_outputDirectory)
115118
maxCPU: "${{ configuration.maxCPUs }}"
119+
outputArtifactsFolder: $(ob_outputDirectory)
116120
pipArtifactFeeds: "mariner/Mariner-Pypi-Feed"
117121
selfRepoName: self
118122
testSuiteName: "[${{ configuration.name }}] Package test"
119-
testRerunList: "$(testListFromToolchain)"
120123

121124
- script: echo "##vso[task.setvariable variable=rpmsArtifactName;isOutput=true]$(ob_artifactBaseName)"
122125
name: "RPMsArtifactName"
123126
displayName: "Set variable for published artifact name"
124127

125128
- task: PublishPipelineArtifact@1
126129
inputs:
127-
artifact: ${{ variables.rpmsArtifactNameBase }}_${{ configuration.name }}_$(System.JobAttempt)
130+
artifact: $(rpmsArtifactNameBase)_${{ configuration.name }}_$(System.JobAttempt)
128131
targetPath: $(ob_outputDirectory)
129132
condition: always()
130133
displayName: "Publish packages build artifacts"
131134

132-
- stage: sodiff_${{ configuration.name }}
135+
- stage: Toolchain_tests_${{ configuration.name }}
136+
dependsOn: Toolchain_${{ configuration.name }}
137+
jobs:
138+
- job: TestToolchainPackages
139+
condition: stageDependencies.Toolchain_${{ configuration.name }}.Build.outputs['CalculateToolchainPackageRetestList.toolchainPackageRetestList']
140+
pool:
141+
type: linux
142+
isCustom: true
143+
name: ${{ configuration.agentPool }}
144+
variables:
145+
ob_artifactBaseName: $(toolchainTestsArtifactNameBase)_${{ configuration.name }}_$(System.JobAttempt)
146+
ob_outputDirectory: $(Build.ArtifactStagingDirectory)
147+
testListFromToolchain: $[ stageDependencies.Toolchain_${{ configuration.name }}.Build.outputs['CalculateToolchainPackageRetestList.toolchainPackageRetestList'] ]
148+
toolchainArtifactName: $[ stageDependencies.Toolchain_${{ configuration.name }}.Build.outputs['ToolchainArtifactName.toolchainArtifactName'] ]
149+
steps:
150+
- template: .pipelines/templates/PackageBuild.yml@self
151+
parameters:
152+
checkBuildRetries: "1"
153+
customToolchainArtifactName: $(toolchainArtifactName)
154+
isAllowToolchainRebuilds: true
155+
isCheckBuild: true
156+
isQuickRebuildPackages: true
157+
isUseCCache: true
158+
maxCPU: "${{ configuration.maxCPUs }}"
159+
outputArtifactsFolder: $(ob_outputDirectory)
160+
pipArtifactFeeds: "mariner/Mariner-Pypi-Feed"
161+
selfRepoName: self
162+
srpmPackList: "$(testListFromToolchain)"
163+
testRerunList: "$(testListFromToolchain)"
164+
testSuiteName: "[${{ configuration.name }}] Toolchain test"
165+
166+
- task: PublishPipelineArtifact@1
167+
inputs:
168+
artifact: $(toolchainTestsArtifactNameBase)_${{ configuration.name }}_$(System.JobAttempt)
169+
targetPath: $(ob_outputDirectory)
170+
condition: always()
171+
displayName: "Publish toolchain build artifacts"
172+
173+
- stage: Sodiff_${{ configuration.name }}
133174
dependsOn: RPMs_${{ configuration.name }}
134175
jobs:
135176
- job: Sodiff_Check

.pipelines/templates/PackageBuild.yml

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ parameters:
3737
# - name: build-artifacts
3838
# rpmsTarball: cache.tar.gz
3939

40+
- name: isAllowToolchainRebuilds
41+
type: string
42+
default: "default"
43+
values:
44+
- "default"
45+
- "false"
46+
- "true"
47+
4048
- name: isCheckBuild
4149
type: string
4250
default: "default"
@@ -105,6 +113,14 @@ parameters:
105113
type: string
106114
default: "srpms.tar.gz"
107115

116+
- name: packageBuildList
117+
type: string
118+
default: ""
119+
120+
- name: packageRebuildList
121+
type: string
122+
default: ""
123+
108124
- name: pipArtifactFeeds
109125
type: string
110126
default: ""
@@ -184,20 +200,14 @@ steps:
184200
check_build_retries_arg="CHECK_BUILD_RETRIES=${{ parameters.checkBuildRetries }}"
185201
fi
186202
187-
if [[ ${{ parameters.isDeltaBuild }} == "true" ]]; then
188-
delta_fetch_arg="DELTA_FETCH=y"
189-
elif [[ ${{ parameters.isDeltaBuild }} == "false" ]]; then
190-
delta_fetch_arg="DELTA_FETCH=n"
191-
fi
192-
193-
if [[ -n "${{ parameters.maxCascadingRebuilds }}" ]]; then
194-
max_cascading_rebuilds_arg="MAX_CASCADING_REBUILDS=${{ parameters.maxCascadingRebuilds }}"
203+
if [[ -n "${{ parameters.customToolchainArtifactName }}" ]]; then
204+
toolchain_archive_arg="TOOLCHAIN_ARCHIVE=$(toolchainArchive)"
195205
fi
196206
197-
if [[ ${{ parameters.isQuickRebuildPackages }} == "true" ]]; then
198-
quick_rebuild_packages_arg="QUICK_REBUILD_PACKAGES=y"
199-
elif [[ ${{ parameters.isQuickRebuildPackages }} == "false" ]]; then
200-
quick_rebuild_packages_arg="QUICK_REBUILD_PACKAGES=n"
207+
if [[ ${{ parameters.isAllowToolchainRebuilds }} == "true" ]]; then
208+
allow_toolchain_rebuilds_arg="ALLOW_TOOLCHAIN_REBUILDS=y"
209+
elif [[ ${{ parameters.isAllowToolchainRebuilds }} == "false" ]]; then
210+
allow_toolchain_rebuilds_arg="ALLOW_TOOLCHAIN_REBUILDS=n"
201211
fi
202212
203213
if [[ ${{ parameters.isCheckBuild }} == "true" ]]; then
@@ -206,8 +216,16 @@ steps:
206216
run_check_arg="RUN_CHECK=n"
207217
fi
208218
209-
if [[ -n "${{ parameters.customToolchainArtifactName }}" ]]; then
210-
toolchain_archive_arg="TOOLCHAIN_ARCHIVE=$(toolchainArchive)"
219+
if [[ ${{ parameters.isDeltaBuild }} == "true" ]]; then
220+
delta_fetch_arg="DELTA_FETCH=y"
221+
elif [[ ${{ parameters.isDeltaBuild }} == "false" ]]; then
222+
delta_fetch_arg="DELTA_FETCH=n"
223+
fi
224+
225+
if [[ ${{ parameters.isQuickRebuildPackages }} == "true" ]]; then
226+
quick_rebuild_packages_arg="QUICK_REBUILD_PACKAGES=y"
227+
elif [[ ${{ parameters.isQuickRebuildPackages }} == "false" ]]; then
228+
quick_rebuild_packages_arg="QUICK_REBUILD_PACKAGES=n"
211229
fi
212230
213231
if [[ ${{ parameters.isUseCCache }} == "true" ]]; then
@@ -216,15 +234,22 @@ steps:
216234
use_ccache_arg="USE_CCACHE=n"
217235
fi
218236
237+
if [[ -n "${{ parameters.maxCascadingRebuilds }}" ]]; then
238+
max_cascading_rebuilds_arg="MAX_CASCADING_REBUILDS=${{ parameters.maxCascadingRebuilds }}"
239+
fi
240+
219241
sudo make -C "${{ parameters.buildRepoRoot }}/toolkit" build-packages -j$(nproc) \
220242
CONCURRENT_PACKAGE_BUILDS=${{ parameters.concurrentPackageBuilds }} \
221243
CONFIG_FILE="" \
222244
MAX_CPU="${{ parameters.maxCPU }}" \
245+
PACKAGE_BUILD_LIST="${{ parameters.packageBuildList }}" \
246+
PACKAGE_REBUILD_LIST="${{ parameters.packageRebuildList }}" \
223247
REBUILD_TOOLS=y \
224248
REPO_LIST="${{ parameters.extraPackageRepos }}" \
225249
SPECS_DIR="${{ parameters.buildRepoRoot }}/${{ parameters.specsFolderPath }}" \
226250
SRPM_PACK_LIST="${{ parameters.srpmPackList }}" \
227251
TEST_RERUN_LIST="${{ parameters.testRerunList }}" \
252+
$allow_toolchain_rebuilds_arg \
228253
$check_build_retries_arg \
229254
$delta_fetch_arg \
230255
$max_cascading_rebuilds_arg \

.pipelines/templates/PackageTestResultsAnalysis.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -281,14 +281,16 @@ steps:
281281
282282
- ${{ if parameters.failOnTestFailures }}:
283283
- bash: |
284-
report_path="${{ parameters.testsWorkspace }}/${{ parameters.reportFileName }}"
285-
if [[ ! -f "$report_path" ]]; then
286-
echo "##[error]Test report not found at '$report_path'."
287-
exit 1
288-
fi
289-
290-
if ! grep -q '^<testsuites.*failures="0"' "$report_path"; then
291-
echo "##[error]Test report has failing tests. See the 'Tests' tab for details."
292-
exit 1
293-
fi
284+
report_path="${{ parameters.testsWorkspace }}/${{ parameters.reportFileName }}"
285+
if [[ ! -f "$report_path" ]]; then
286+
echo "##[error]Test report not found at '$report_path'."
287+
exit 1
288+
fi
289+
290+
# The "failures" attribute indicates completed tests where at least one of the test cases failed.
291+
# The "errors" attribute indicates tests, which failed to complete for whatever reason.
292+
if grep -qP '^<testsuites.*(errors|failures)="(?!0)' "$report_path"; then
293+
echo "##[error]Test report has failing tests. See the 'Tests' tab for details."
294+
exit 1
295+
fi
294296
displayName: "Verify all tests passed"

.pipelines/templates/ToolchainCalculatePackageRetests.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,38 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT License.
33

4+
# This template will calculate a list of toolchain packages that might need to be re-tested at a later stage.
5+
# It assumes a toolchain build has already been performed in the same job.
6+
7+
# Output pipeline variables set by this template:
8+
# - CalculateToolchainPackageRetestList.toolchainPackageRetestList
9+
410
parameters:
511
- name: buildRepoRoot
612
type: string
713
default: "$(Build.SourcesDirectory)"
814

15+
- name: ignoredSpecs
16+
type: object
17+
default: []
18+
919
steps:
10-
# This template will calculate a list of toolchain packages that might need to be re-tested at a later stage.
11-
# It assumes a toolchain build has already been performed in the same job. The value will be made available as
12-
# the variable 'CalculateToolchainPackageRetestList.toolchainPackageRetestList'.
1320
- bash: |
21+
array_contains() {
22+
local -n __array=$1
23+
local value=$2
24+
25+
for item in "${__array[@]}"; do
26+
if [[ "$item" == "$value" ]]; then
27+
return 0
28+
fi
29+
done
30+
31+
return 1
32+
}
33+
34+
ignored_specs=(${{ join(parameters.ignoredSpecs, ' ') }})
35+
1436
# Calculate the list of packages that should be re-tested during full package build.
1537
# This list will be the contents of 'built_specs_list.txt' in the toolchain build logs directory, but only for
1638
# packages that have a '%check' section in their spec file. The assumption is that all packages will have a
@@ -24,14 +46,18 @@ steps:
2446
echo "##[error]ERROR: '${specs_dir}/${spec}/${spec}.spec' does not exist"
2547
exit 1
2648
fi
49+
2750
if grep -q '^%check' "${specs_dir}/${spec}/${spec}.spec"; then
28-
retest_list+=("${spec}")
51+
if ! array_contains ignored_specs "${spec}"; then
52+
retest_list+=("${spec}")
53+
fi
2954
fi
3055
done < "$built_list"
3156
else
3257
echo "No file '$built_list' found, so no packages to re-test"
3358
fi
3459
# Default will be "", which is fine.
60+
3561
echo "Setting 'CalculateToolchainPackageRetestList.toolchainPackageRetestList' to '${retest_list[*]}'"
3662
echo "##vso[task.setvariable variable=toolchainPackageRetestList;isOutput=true]${retest_list[*]}"
3763
name: "CalculateToolchainPackageRetestList"

0 commit comments

Comments
 (0)