[CI] Allow to enable or disable the dotnet builds. (#11358)

Create a new parameter that can be used to decide if we build or not the
dotnet parts of the project. If we do not, we make sure that we do not
have any errors in all the other steps.
This commit is contained in:
Manuel de la Pena 2021-05-02 20:31:42 -04:00 коммит произвёл GitHub
Родитель 47f273b4f6
Коммит 19482a71ae
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 84 добавлений и 30 удалений

Просмотреть файл

@ -22,6 +22,10 @@ parameters:
type: string
default: 'latest'
- name: enableDotnet
type: boolean
default: true
# We are doing some black magic. We have several templates that
# are executed with different parameters.
#
@ -218,6 +222,7 @@ stages:
keyringPass: $(xma-password)
gitHubToken: ${{ variables['GitHub.Token'] }}
xqaCertPass: $(xqa--certificates--password)
enableDotnet: ${{ parameters.enableDotnet }}
- ${{ if eq(parameters.runDeviceTests, true) }}:
- ${{ if and(ne(variables['Build.Reason'], 'Schedule'), or(eq(variables['Build.Reason'], 'IndividualCI'), eq(variables['Build.Reason'], 'Manual'))) }}:

Просмотреть файл

@ -23,6 +23,10 @@ parameters:
- name: xqaCertPass
type: string
- name: enableDotnet
type: boolean
default: false
steps:
- checkout: self # https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#checkout
clean: true # Executes: git clean -ffdx && git reset --hard HEAD
@ -274,13 +278,21 @@ steps:
CONFIGURE_FLAGS="--enable-xamarin"
fi
CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-dotnet --enable-dotnet-windows --enable-install-source"
if [[ "$EnableDotNet" == "True" ]]; then
echo "Enabling dotnet builds."
CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-dotnet --enable-dotnet-windows"
fi
CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-install-source"
echo "Configuration falgs are '$CONFIGURE_FLAGS'"
cd $(Build.SourcesDirectory)/xamarin-macios/
./configure $CONFIGURE_FLAGS
echo $(cat $(Build.SourcesDirectory)/xamarin-macios/configure.inc)
env:
IsPR: $(configuration.IsPR)
${{ if eq(parameters.enableDotnet, true) }}:
EnableDotNet: 'True'
displayName: "Configure build"
timeoutInMinutes: 5
@ -312,11 +324,14 @@ steps:
timeoutInMinutes: 180
# build nugets
- template: build-nugets.yml
- ${{ if eq(parameters.enableDotnet, true) }}:
- template: build-nugets.yml
# only sign an notarize in no PR executions
- ${{ if ne(parameters.isPR, 'True') }}:
- template: sign-and-notarized.yml
parameters:
enableDotnet: ${{ parameters.enableDotnet }}
- template: generate-workspace-info.yml@templates
parameters:

Просмотреть файл

@ -1,6 +1,12 @@
# This job will parse all the labels present in a PR, will set
# the tags for the build AND will set a number of configuration
# variables to be used by the rest of the projects
parameters:
- name: enableDotnet
type: boolean
default: false
steps:
- checkout: self # https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#checkout
clean: true # Executes: git clean -ffdx && git reset --hard HEAD
@ -24,6 +30,12 @@ steps:
if ($buildReason -eq "Schedule") {
$tags.Add("cronjob")
}
if ($Env:ENABLE_DOTNET -eq "True") {
Write-Host "dotnet will be enabled for the build because ENABLE_DOTNET was '$Env:ENABLE_DOTNET'"
} else {
Write-Host "dotnet will be disabled for the build because ENABLE_DOTNET was '$Env:ENABLE_DOTNET'"
}
if ($buildReason -eq "PullRequest" -or (($buildReason -eq "Manual") -and ($buildSourceBranchName -eq "merge")) ) {
Write-Host "Configuring build from PR."
@ -57,7 +69,8 @@ steps:
# decide if we add the run-dotnet-tests label (if not present) this is done only for main
# we can use $ref for that :)
$xharnessLabels = $tags -join ","
if ($ref -eq "main" -and -not ("run-dotnet-tests" -in $xharnessLabels)) {
if ($Env:ENABLE_DOTNET -eq "True" -and -not ("run-dotnet-tests" -in $xharnessLabels)) {
Write-Host "Adding label run-dotnet-tests to xharness."
$tags.Add("run-dotnet-tests")
if ($xharnessLabels -eq "") {
$xharnessLabels = "run-dotnet-tests"
@ -102,6 +115,8 @@ steps:
BUILD_REVISION: $(Build.SourceVersion)
GITHUB_TOKEN: $(GitHub.Token)
ACCESSTOKEN: $(AzDoBuildAccess.Token)
${{ if eq(parameters.enableDotnet, true) }}:
ENABLE_DOTNET: "True"
name: labels
displayName: 'Configure build'

Просмотреть файл

@ -5,6 +5,10 @@ parameters:
type: string
default: 'Real'
- name: enableDotnet
type: boolean
default: false
steps:
- bash: |
@ -86,36 +90,37 @@ steps:
zipSources: false # we do not use the feature and makes the installation to last 10/12 mins instead of < 1 min
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
- ${{ if eq(parameters.enableDotnet, true) }}:
- pwsh : |
# Get the list of files to sign
$msiFiles = Get-ChildItem -Path $(Build.SourcesDirectory)/package/ -Filter "*.msi"
- pwsh : |
# Get the list of files to sign
$msiFiles = Get-ChildItem -Path $(Build.SourcesDirectory)/package/ -Filter "*.msi"
# Add those files to an array
$SignFiles = @()
foreach($msi in $msiFiles) {
Write-Host "$($msi.FullName)"
$SignFiles += @{ "SrcPath"="$($msi.FullName)"}
}
Write-Host "$msiFiles"
# array of dicts
$SignFileRecord = @(
@{
"Certs" = "400";
"SignFileList" = $SignFiles;
# Add those files to an array
$SignFiles = @()
foreach($msi in $msiFiles) {
Write-Host "$($msi.FullName)"
$SignFiles += @{ "SrcPath"="$($msi.FullName)"}
}
)
$SignFileList = @{
"SignFileRecordList" = $SignFileRecord
}
Write-Host "$msiFiles"
# Write the json to a file
ConvertTo-Json -InputObject $SignFileList -Depth 5 | Out-File -FilePath $(Build.ArtifactStagingDirectory)/MsiFiles2Notarize.json -Force
dotnet $Env:MBSIGN_APPFOLDER/ddsignfiles.dll /filelist:$(Build.ArtifactStagingDirectory)/MsiFiles2Notarize.json
displayName: 'Sign .msi'
# array of dicts
$SignFileRecord = @(
@{
"Certs" = "400";
"SignFileList" = $SignFiles;
}
)
$SignFileList = @{
"SignFileRecordList" = $SignFileRecord
}
# Write the json to a file
ConvertTo-Json -InputObject $SignFileList -Depth 5 | Out-File -FilePath $(Build.ArtifactStagingDirectory)/MsiFiles2Notarize.json -Force
dotnet $Env:MBSIGN_APPFOLDER/ddsignfiles.dll /filelist:$(Build.ArtifactStagingDirectory)/MsiFiles2Notarize.json
displayName: 'Sign .msi'
- bash: |
security unlock-keychain -p $PRODUCTSIGN_KEYCHAIN_PASSWORD builder.keychain

Просмотреть файл

@ -21,6 +21,10 @@ parameters:
- name: xqaCertPass
type: string
- name: enableDotnet
type: boolean
default: false
jobs:
- job: configure
displayName: 'Configure build'
@ -95,6 +99,7 @@ jobs:
keyringPass: ${{ parameters.keyringPass }}
gitHubToken: ${{ parameters.gitHubToken }}
xqaCertPass: ${{ parameters.xqaCertPass }}
enableDotnet: ${{ parameters.enableDotnet }}
- job: upload_azure_blob
displayName: 'Upload packages to Azure'
@ -115,6 +120,8 @@ jobs:
clean: all
steps:
- template: upload-azure.yml
parameters:
enableDotnet: ${{ parameters.enableDotnet }}
- job: upload_vsdrops
displayName: 'Upload test results to VSDrops'

Просмотреть файл

@ -1,3 +1,8 @@
parameters:
- name: enableDotnet
type: boolean
default: false
steps:
- checkout: self
@ -164,7 +169,7 @@ steps:
Set-GitHubStatus -Status "error" -Description "msbuild.zip not found." -Context "msbuild.zip"
}
if ($Env:SkipNugets -ne "True") {
if ($Env:ENABLE_DOTNET -eq "True" -and $Env:SkipNugets -ne "True") {
$nugets = Get-ChildItem -Path $pkgsPath -Filter *.nupkg -File -Name
Write-Host $nugets
Write-Host "nuget count is $($nugets.Count)"
@ -196,4 +201,6 @@ steps:
GITHUB_TOKEN: $(GitHub.Token)
ACCESSTOKEN: $(System.AccessToken)
STORAGE_URI: $(Parameters.outputStorageUri)
${{ if eq(parameters.enableDotnet, true) }}:
ENABLE_DOTNET: "True"
displayName: 'Set GithubStatus'