diff --git a/tools/devops/automation/run-post-pr-build-tests.yml b/tools/devops/automation/run-post-pr-build-tests.yml index 16bdd59d45bd..b83f2d8e95c3 100644 --- a/tools/devops/automation/run-post-pr-build-tests.yml +++ b/tools/devops/automation/run-post-pr-build-tests.yml @@ -1,19 +1,29 @@ -# YAML pipeline for post build operations. -# This pipeline will execute the tests for the CI on PR as soon as the workloads have been complited. +# YAML pipeline for post build operations. +# This pipeline will build the workloads and then execute the tests for the CI on a PR. trigger: none -pr: none -# we cannot use a template in a pipeline context -resources: - pipelines: - - pipeline: macios - source: \Xamarin\Mac-iOS\pr pipelines\xamarin-macios-pr - trigger: - stages: - - build_packages +pr: + autoCancel: true + branches: + include: + - '*' # yes, you do need the quote, * has meaning in yamls + paths: + exclude: + - .github + - docs + - CODEOWNERS + - ISSUE_TEMPLATE.md + - LICENSE + - NOTICE.txt + - SECURITY.MD + - README.md + - src/README.md + - tools/mtouch/README.md + - msbuild/Xamarin.Localization.MSBuild/README.md extends: template: templates/pipelines/run-tests-pipeline.yml parameters: isPR: true + buildPackages: true diff --git a/tools/devops/automation/templates/common/configure.yml b/tools/devops/automation/templates/common/configure.yml index 4eef3b811f88..c4587316eefe 100644 --- a/tools/devops/automation/templates/common/configure.yml +++ b/tools/devops/automation/templates/common/configure.yml @@ -232,7 +232,19 @@ steps: $testMatrix = $testMatrix | ConvertFrom-Json | ConvertTo-Json -Compress # update the config file so that we do not recalculate the matrix in other pipelines Edit-BuildConfiguration -ConfigKey TEST_MATRIX -ConfigValue $testMatrix -ConfigFile $Env:CONFIG_PATH - #CONFIG_PATH + Write-Host "##vso[task.setvariable variable=TEST_MATRIX;isOutput=true]$testMatrix" + + # also compute the simulator test matrix and set it as output variable so that + # dependent stages in post-build test pipelines can consume it + $simulatorTestMatrix = Get-TestConfiguration ` + -TestConfigurations "$Env:TEST_CONFIGURATIONS" ` + -SupportedPlatforms "$Env:SUPPORTED_PLATFORMS" ` + -EnabledPlatforms "$Env:CONFIGURE_PLATFORMS_DOTNET_PLATFORMS" ` + -TestsLabels "${{ parameters.testsLabels }}" ` + -StatusContext "${{ parameters.statusContext }}" ` + -StageFilter "simulator_tests" + $simulatorTestMatrix = $simulatorTestMatrix | ConvertFrom-Json | ConvertTo-Json -Compress + Write-Host "##vso[task.setvariable variable=SIMULATOR_TEST_MATRIX;isOutput=true]$simulatorTestMatrix" name: test_matrix displayName: 'Create tests strategy matrix' env: diff --git a/tools/devops/automation/templates/pipelines/run-tests-pipeline.yml b/tools/devops/automation/templates/pipelines/run-tests-pipeline.yml index 2213a4425696..a3ef20748f63 100644 --- a/tools/devops/automation/templates/pipelines/run-tests-pipeline.yml +++ b/tools/devops/automation/templates/pipelines/run-tests-pipeline.yml @@ -31,6 +31,11 @@ parameters: type: boolean default: true + - name: buildPackages + displayName: Build packages as part of this pipeline (instead of downloading from a pipeline resource) + type: boolean + default: false + resources: repositories: - repository: self @@ -56,3 +61,4 @@ stages: provisionatorChannel: ${{ parameters.provisionatorChannel }} runTests: ${{ parameters.runTests }} runWindowsIntegration: ${{ parameters.runWindowsIntegration }} + buildPackages: ${{ parameters.buildPackages }} diff --git a/tools/devops/automation/templates/tests-stage.yml b/tools/devops/automation/templates/tests-stage.yml index fb3c7746d609..41f6fec21ddd 100644 --- a/tools/devops/automation/templates/tests-stage.yml +++ b/tools/devops/automation/templates/tests-stage.yml @@ -121,6 +121,10 @@ parameters: type: string default: '' +- name: buildPackages + type: boolean + default: false + stages: - template: ./build/linux-build-verification.yml @@ -148,13 +152,69 @@ stages: BRANCH_NAME: $[ replace(variables['Build.SourceBranch'], 'refs/heads/', '') ] steps: - - template: common/load_configuration.yml - parameters: - repositoryAlias: ${{ parameters.repositoryAlias }} - commit: ${{ parameters.commit }} - statusContext: 'VSTS: simulator tests' - uploadArtifacts: true - use1ES: false + - ${{ if eq(parameters.buildPackages, true) }}: + # When building packages in this pipeline, generate configuration from scratch + - template: common/configure.yml + parameters: + repositoryAlias: ${{ parameters.repositoryAlias }} + commit: ${{ parameters.commit }} + statusContext: 'VSTS: simulator tests' + uploadArtifacts: true + use1ES: false + isPR: ${{ parameters.isPR }} + - ${{ else }}: + # When using pre-built packages from a pipeline resource, load existing configuration + - template: common/load_configuration.yml + parameters: + repositoryAlias: ${{ parameters.repositoryAlias }} + commit: ${{ parameters.commit }} + statusContext: 'VSTS: simulator tests' + uploadArtifacts: true + use1ES: false + +# When buildPackages is true, build packages as part of this pipeline +- ${{ if eq(parameters.buildPackages, true) }}: + - stage: build_packages + displayName: '${{ parameters.stageDisplayNamePrefix }}Build' + dependsOn: [configure_build] + jobs: + - job: build + displayName: 'Build packages' + timeoutInMinutes: 1000 + variables: + DOTNET_PLATFORMS: $[ stageDependencies.configure_build.configure.outputs['configure_platforms.DOTNET_PLATFORMS'] ] + INCLUDE_DOTNET_IOS: $[ stageDependencies.configure_build.configure.outputs['configure_platforms.INCLUDE_DOTNET_IOS'] ] + INCLUDE_DOTNET_MACCATALYST: $[ stageDependencies.configure_build.configure.outputs['configure_platforms.INCLUDE_DOTNET_MACCATALYST'] ] + INCLUDE_DOTNET_MACOS: $[ stageDependencies.configure_build.configure.outputs['configure_platforms.INCLUDE_DOTNET_MACOS'] ] + INCLUDE_DOTNET_TVOS: $[ stageDependencies.configure_build.configure.outputs['configure_platforms.INCLUDE_DOTNET_TVOS'] ] + BuildPackage: $[ stageDependencies.configure_build.configure.outputs['labels.build_package'] ] + SkipPackages: $[ stageDependencies.configure_build.configure.outputs['labels.skip_packages'] ] + SkipNugets: $[ stageDependencies.configure_build.configure.outputs['labels.skip_nugets'] ] + SkipSigning: $[ stageDependencies.configure_build.configure.outputs['labels.skip_signing'] ] + SkipApiComparison: $[ stageDependencies.configure_build.configure.outputs['labels.skip_api_comparison'] ] + PR_ID: $[ stageDependencies.configure_build.configure.outputs['labels.pr_number'] ] + BRANCH_NAME: $[ replace(variables['Build.SourceBranch'], 'refs/heads/', '') ] + XHARNESS_LABELS: $[ stageDependencies.configure_build.configure.outputs['labels.xharness_labels'] ] + RUN_MAC_TESTS: $[ stageDependencies.configure_build.configure.outputs['decisions.RUN_MAC_TESTS'] ] + pool: + name: $(PRBuildPool) + demands: + - Agent.OS -equals Darwin + - Agent.OSVersion -gtVersion $(minimumMacOSVersion) + - macOS.Name -equals ${{ parameters.macOSName }} + - XcodeChannel -equals ${{ parameters.xcodeChannel }} + steps: + - template: build/build-pkgs.yml + parameters: + isPR: ${{ parameters.isPR }} + repositoryAlias: ${{ parameters.repositoryAlias }} + commit: ${{ parameters.commit }} + vsdropsPrefix: ${{ variables.vsdropsPrefix }} + keyringPass: $(pass--lab--mac--builder--keychain) + gitHubToken: $(Github.Token) + xqaCertPass: $(xqa--certificates--password) + use1ES: false + xcodeChannel: ${{ parameters.xcodeChannel }} # always run simulator tests - template: ./tests/stage.yml @@ -173,7 +233,7 @@ stages: gitHubToken: $(Github.Token) xqaCertPass: $(xqa--certificates--password) condition: ${{ parameters.runTests }} - postPipeline: true + postPipeline: ${{ not(parameters.buildPackages) }} - template: ./tests/publish-results.yml parameters: @@ -185,7 +245,7 @@ stages: isPR: ${{ parameters.isPR }} repositoryAlias: ${{ parameters.repositoryAlias }} commit: ${{ parameters.commit }} - postPipeline: true + postPipeline: ${{ not(parameters.buildPackages) }} macTestsConfigurations: ${{ parameters.macTestsConfigurations }} - ${{ if eq(parameters.runWindowsIntegration, true) }}: @@ -200,11 +260,14 @@ stages: statusContext: 'Windows Integration Tests' gitHubToken: $(Github.Token) xqaCertPass: $(xqa--certificates--password) - postPipeline: true + postPipeline: ${{ not(parameters.buildPackages) }} - stage: build_macos_tests displayName: '${{ parameters.stageDisplayNamePrefix }}Build macOS tests' - dependsOn: [configure_build] + dependsOn: + - configure_build + - ${{ if eq(parameters.buildPackages, true) }}: + - build_packages condition: and(succeeded(), ne(dependencies.configure_build.outputs['configure.configure_platforms.DOTNET_PLATFORMS'], '')) jobs: - template: ./build/build-mac-tests-stage.yml @@ -234,5 +297,5 @@ stages: keyringPass: $(pass--lab--mac--builder--keychain) demands: ${{ config.demands }} xqaCertPass: $(xqa--certificates--password) - postPipeline: true + postPipeline: ${{ not(parameters.buildPackages) }} label: ${{ config.label }} diff --git a/tools/devops/automation/templates/windows/stage.yml b/tools/devops/automation/templates/windows/stage.yml index bad97571f29a..7f287284164c 100644 --- a/tools/devops/automation/templates/windows/stage.yml +++ b/tools/devops/automation/templates/windows/stage.yml @@ -47,6 +47,8 @@ stages: displayName: ${{ parameters.displayName }} dependsOn: - configure_build + - ${{ if not(parameters.postPipeline) }}: + - build_packages condition: and(succeeded(), eq(dependencies.configure_build.outputs['configure.decisions.RUN_WINDOWS_TESTS'], 'true')) jobs: