From 1dad47a2e43f76b3708557508b090aa1173ef341 Mon Sep 17 00:00:00 2001 From: CBL-Mariner-Bot <75509084+CBL-Mariner-Bot@users.noreply.github.com> Date: Fri, 13 Sep 2024 14:46:20 -0700 Subject: [PATCH] [AUTO-CHERRYPICK] Separated toolchain tests from non-toolchain package builds. - branch main (#10448) Co-authored-by: Pawel Winogrodzki --- .pipelines/prchecks/PackageBuildPRCheck.yml | 55 ++++++++++++++++--- .pipelines/templates/PackageBuild.yml | 53 +++++++++++++----- .../templates/PackageTestResultsAnalysis.yml | 20 ++++--- .../ToolchainCalculatePackageRetests.yml | 34 ++++++++++-- 4 files changed, 128 insertions(+), 34 deletions(-) diff --git a/.pipelines/prchecks/PackageBuildPRCheck.yml b/.pipelines/prchecks/PackageBuildPRCheck.yml index d0fef572b1..ea1426f5c3 100644 --- a/.pipelines/prchecks/PackageBuildPRCheck.yml +++ b/.pipelines/prchecks/PackageBuildPRCheck.yml @@ -39,8 +39,10 @@ variables: value: RPMs - name: toolchainArtifactNameBase value: Toolchain + - name: toolchainTestsArtifactNameBase + value: Toolchain_tests - name: system.debug - value: '${{ parameters.debug }}' + value: "${{ parameters.debug }}" extends: template: v2/OneBranch.NonOfficial.CrossPlat.yml@templates @@ -74,6 +76,9 @@ extends: # Toolchain package tests should be run through the full package build, calculate the list of packages that should be re-tested # and make it available to the next stage via an output variable: 'CalculateToolchainPackageRetestList.toolchainPackageRetestList' - template: .pipelines/templates/ToolchainCalculatePackageRetests.yml@self + parameters: + # GCC fails to build as a regular package. + ignoredSpecs: ["gcc"] - script: echo "##vso[task.setvariable variable=toolchainArtifactName;isOutput=true]$(ob_artifactBaseName)" name: "ToolchainArtifactName" @@ -99,9 +104,8 @@ extends: isCustom: true name: ${{ configuration.agentPool }} variables: - ob_artifactBaseName: ${{ variables.rpmsArtifactNameBase }}_${{ configuration.name }}_$(System.JobAttempt) + ob_artifactBaseName: $(rpmsArtifactNameBase)_${{ configuration.name }}_$(System.JobAttempt) ob_outputDirectory: $(Build.ArtifactStagingDirectory) - testListFromToolchain: $[ stageDependencies.Toolchain_${{ configuration.name }}.Build.outputs['CalculateToolchainPackageRetestList.toolchainPackageRetestList'] ] toolchainArtifactName: $[ stageDependencies.Toolchain_${{ configuration.name }}.Build.outputs['ToolchainArtifactName.toolchainArtifactName'] ] steps: - template: .pipelines/templates/PackageBuild.yml@self @@ -111,12 +115,11 @@ extends: isCheckBuild: true isQuickRebuildPackages: true isUseCCache: true - outputArtifactsFolder: $(ob_outputDirectory) maxCPU: "${{ configuration.maxCPUs }}" + outputArtifactsFolder: $(ob_outputDirectory) pipArtifactFeeds: "mariner/Mariner-Pypi-Feed" selfRepoName: self testSuiteName: "[${{ configuration.name }}] Package test" - testRerunList: "$(testListFromToolchain)" - script: echo "##vso[task.setvariable variable=rpmsArtifactName;isOutput=true]$(ob_artifactBaseName)" name: "RPMsArtifactName" @@ -124,12 +127,50 @@ extends: - task: PublishPipelineArtifact@1 inputs: - artifact: ${{ variables.rpmsArtifactNameBase }}_${{ configuration.name }}_$(System.JobAttempt) + artifact: $(rpmsArtifactNameBase)_${{ configuration.name }}_$(System.JobAttempt) targetPath: $(ob_outputDirectory) condition: always() displayName: "Publish packages build artifacts" - - stage: sodiff_${{ configuration.name }} + - stage: Toolchain_tests_${{ configuration.name }} + dependsOn: Toolchain_${{ configuration.name }} + jobs: + - job: TestToolchainPackages + condition: stageDependencies.Toolchain_${{ configuration.name }}.Build.outputs['CalculateToolchainPackageRetestList.toolchainPackageRetestList'] + pool: + type: linux + isCustom: true + name: ${{ configuration.agentPool }} + variables: + ob_artifactBaseName: $(toolchainTestsArtifactNameBase)_${{ configuration.name }}_$(System.JobAttempt) + ob_outputDirectory: $(Build.ArtifactStagingDirectory) + testListFromToolchain: $[ stageDependencies.Toolchain_${{ configuration.name }}.Build.outputs['CalculateToolchainPackageRetestList.toolchainPackageRetestList'] ] + toolchainArtifactName: $[ stageDependencies.Toolchain_${{ configuration.name }}.Build.outputs['ToolchainArtifactName.toolchainArtifactName'] ] + steps: + - template: .pipelines/templates/PackageBuild.yml@self + parameters: + checkBuildRetries: "1" + customToolchainArtifactName: $(toolchainArtifactName) + isAllowToolchainRebuilds: true + isCheckBuild: true + isQuickRebuildPackages: true + isUseCCache: true + maxCPU: "${{ configuration.maxCPUs }}" + outputArtifactsFolder: $(ob_outputDirectory) + pipArtifactFeeds: "mariner/Mariner-Pypi-Feed" + selfRepoName: self + srpmPackList: "$(testListFromToolchain)" + testRerunList: "$(testListFromToolchain)" + testSuiteName: "[${{ configuration.name }}] Toolchain test" + + - task: PublishPipelineArtifact@1 + inputs: + artifact: $(toolchainTestsArtifactNameBase)_${{ configuration.name }}_$(System.JobAttempt) + targetPath: $(ob_outputDirectory) + condition: always() + displayName: "Publish toolchain build artifacts" + + - stage: Sodiff_${{ configuration.name }} dependsOn: RPMs_${{ configuration.name }} jobs: - job: Sodiff_Check diff --git a/.pipelines/templates/PackageBuild.yml b/.pipelines/templates/PackageBuild.yml index ca3038450a..4ab4ec2904 100644 --- a/.pipelines/templates/PackageBuild.yml +++ b/.pipelines/templates/PackageBuild.yml @@ -37,6 +37,14 @@ parameters: # - name: build-artifacts # rpmsTarball: cache.tar.gz + - name: isAllowToolchainRebuilds + type: string + default: "default" + values: + - "default" + - "false" + - "true" + - name: isCheckBuild type: string default: "default" @@ -105,6 +113,14 @@ parameters: type: string default: "srpms.tar.gz" + - name: packageBuildList + type: string + default: "" + + - name: packageRebuildList + type: string + default: "" + - name: pipArtifactFeeds type: string default: "" @@ -184,20 +200,14 @@ steps: check_build_retries_arg="CHECK_BUILD_RETRIES=${{ parameters.checkBuildRetries }}" fi - if [[ ${{ parameters.isDeltaBuild }} == "true" ]]; then - delta_fetch_arg="DELTA_FETCH=y" - elif [[ ${{ parameters.isDeltaBuild }} == "false" ]]; then - delta_fetch_arg="DELTA_FETCH=n" + if [[ -n "${{ parameters.customToolchainArtifactName }}" ]]; then + toolchain_archive_arg="TOOLCHAIN_ARCHIVE=$(toolchainArchive)" fi - if [[ -n "${{ parameters.maxCascadingRebuilds }}" ]]; then - max_cascading_rebuilds_arg="MAX_CASCADING_REBUILDS=${{ parameters.maxCascadingRebuilds }}" - fi - - if [[ ${{ parameters.isQuickRebuildPackages }} == "true" ]]; then - quick_rebuild_packages_arg="QUICK_REBUILD_PACKAGES=y" - elif [[ ${{ parameters.isQuickRebuildPackages }} == "false" ]]; then - quick_rebuild_packages_arg="QUICK_REBUILD_PACKAGES=n" + if [[ ${{ parameters.isAllowToolchainRebuilds }} == "true" ]]; then + allow_toolchain_rebuilds_arg="ALLOW_TOOLCHAIN_REBUILDS=y" + elif [[ ${{ parameters.isAllowToolchainRebuilds }} == "false" ]]; then + allow_toolchain_rebuilds_arg="ALLOW_TOOLCHAIN_REBUILDS=n" fi if [[ ${{ parameters.isCheckBuild }} == "true" ]]; then @@ -206,8 +216,16 @@ steps: run_check_arg="RUN_CHECK=n" fi - if [[ -n "${{ parameters.customToolchainArtifactName }}" ]]; then - toolchain_archive_arg="TOOLCHAIN_ARCHIVE=$(toolchainArchive)" + if [[ ${{ parameters.isDeltaBuild }} == "true" ]]; then + delta_fetch_arg="DELTA_FETCH=y" + elif [[ ${{ parameters.isDeltaBuild }} == "false" ]]; then + delta_fetch_arg="DELTA_FETCH=n" + fi + + if [[ ${{ parameters.isQuickRebuildPackages }} == "true" ]]; then + quick_rebuild_packages_arg="QUICK_REBUILD_PACKAGES=y" + elif [[ ${{ parameters.isQuickRebuildPackages }} == "false" ]]; then + quick_rebuild_packages_arg="QUICK_REBUILD_PACKAGES=n" fi if [[ ${{ parameters.isUseCCache }} == "true" ]]; then @@ -216,15 +234,22 @@ steps: use_ccache_arg="USE_CCACHE=n" fi + if [[ -n "${{ parameters.maxCascadingRebuilds }}" ]]; then + max_cascading_rebuilds_arg="MAX_CASCADING_REBUILDS=${{ parameters.maxCascadingRebuilds }}" + fi + sudo make -C "${{ parameters.buildRepoRoot }}/toolkit" build-packages -j$(nproc) \ CONCURRENT_PACKAGE_BUILDS=${{ parameters.concurrentPackageBuilds }} \ CONFIG_FILE="" \ MAX_CPU="${{ parameters.maxCPU }}" \ + PACKAGE_BUILD_LIST="${{ parameters.packageBuildList }}" \ + PACKAGE_REBUILD_LIST="${{ parameters.packageRebuildList }}" \ REBUILD_TOOLS=y \ REPO_LIST="${{ parameters.extraPackageRepos }}" \ SPECS_DIR="${{ parameters.buildRepoRoot }}/${{ parameters.specsFolderPath }}" \ SRPM_PACK_LIST="${{ parameters.srpmPackList }}" \ TEST_RERUN_LIST="${{ parameters.testRerunList }}" \ + $allow_toolchain_rebuilds_arg \ $check_build_retries_arg \ $delta_fetch_arg \ $max_cascading_rebuilds_arg \ diff --git a/.pipelines/templates/PackageTestResultsAnalysis.yml b/.pipelines/templates/PackageTestResultsAnalysis.yml index f89d632284..f015abcb0f 100644 --- a/.pipelines/templates/PackageTestResultsAnalysis.yml +++ b/.pipelines/templates/PackageTestResultsAnalysis.yml @@ -281,14 +281,16 @@ steps: - ${{ if parameters.failOnTestFailures }}: - bash: | - report_path="${{ parameters.testsWorkspace }}/${{ parameters.reportFileName }}" - if [[ ! -f "$report_path" ]]; then - echo "##[error]Test report not found at '$report_path'." - exit 1 - fi + report_path="${{ parameters.testsWorkspace }}/${{ parameters.reportFileName }}" + if [[ ! -f "$report_path" ]]; then + echo "##[error]Test report not found at '$report_path'." + exit 1 + fi - if ! grep -q '^