Separate CI build and validation scripts for different areas (#410)

* Separate building projects versions of the katas, Jupyter Notebooks validation and building projects that create, validate and pack binaries into separate CI jobs.
* Include DumpMachine unit tests to the CI.
This commit is contained in:
Andres Paz 2020-07-22 13:21:54 -07:00 коммит произвёл GitHub
Родитель 18c1958e3c
Коммит a93e56de11
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 147 добавлений и 59 удалений

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

@ -1,7 +1,3 @@
# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net
name: $(Build.Major).$(Build.Minor).$(BuildId)
trigger:
- master
@ -15,19 +11,52 @@ variables:
IQSharp.Hosting.Env: 'build-agent-katas'
jobs:
- job: Windows
pool:
vmImage: 'windows-2019'
steps:
- template: scripts/steps.yml
- job: macOS
pool:
vmImage: 'macOS-latest'
steps:
- template: scripts/steps.yml
- job: Linux
pool:
vmImage: 'ubuntu-latest'
steps:
- template: scripts/steps.yml
- job: binaries
displayName: 'Build Binary Packages'
steps:
- template: scripts/steps-init.yml
- template: scripts/steps-binaries.yml
- job: validate_projects
displayName: 'Validate C# Projects'
strategy:
matrix:
linux:
imageName: 'ubuntu-latest'
mac:
imageName: 'macOS-latest'
windows:
imageName: 'windows-latest'
pool:
vmImage: $(imageName)
steps:
- template: scripts/steps-init.yml
- powershell: ./validate-unicode.ps1
displayName: "Validating unicode characters"
workingDirectory: $(System.DefaultWorkingDirectory)/scripts
- powershell: ./validate-projects.ps1
displayName: "Validating C# projects"
workingDirectory: $(System.DefaultWorkingDirectory)/scripts
- job: validate_notebooks
displayName: 'Validate Notebooks'
strategy:
matrix:
linux:
imageName: 'ubuntu-latest'
mac:
imageName: 'macOS-latest'
windows:
imageName: 'windows-latest'
pool:
vmImage: $(imageName)
steps:
- template: scripts/steps-init.yml
- powershell: ./validate-notebooks.ps1
displayName: "Validating notebooks"
workingDirectory: $(System.DefaultWorkingDirectory)/scripts

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

@ -22,17 +22,11 @@ function Build-One {
$script:all_ok = ($LastExitCode -eq 0) -and $script:all_ok
}
# Microsoft.Quantum.Katas.sln should always be built:
Write-Host "Building Katas binaries:"
Build-One '..\utilities\DumpUnitary\DumpUnitary.sln'
Build-One '..\utilities\Microsoft.Quantum.Katas\Microsoft.Quantum.Katas.sln'
# Building all katas projects can be disabled with the ENABLE_KATAS
if ($Env:ENABLE_KATAS -ne "false") {
Get-ChildItem (Join-Path $PSScriptRoot '..') -Recurse -Include '*.sln' -Exclude 'Microsoft.Quantum.Katas.sln' `
| ForEach-Object { Build-One $_.FullName }
} else {
Write-Host "##vso[task.logissue type=warning;]Skipping building Katas solutions. Env:ENABLE_KATAS is '$Env:ENABLE_KATAS'."
}
if (-not $all_ok) {
throw "At least one test failed execution. Check the logs."
throw "At least one project failed building. Check the logs."
}

16
scripts/manifest.ps1 Normal file
Просмотреть файл

@ -0,0 +1,16 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
#!/usr/bin/env pwsh
& "$PSScriptRoot/set-env.ps1"
@{
Packages = @(
"Microsoft.Quantum.Katas"
);
Assemblies = @(
"..\utilities\Common\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Katas.Common.dll",
"..\utilities\Microsoft.Quantum.Katas\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Katas.dll"
) | ForEach-Object { Get-Item (Join-Path $PSScriptRoot $_) };
} | Write-Output;

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

@ -1,27 +1,5 @@
steps:
##
# Pre-reqs
##
- task: UseDotNet@2
displayName: 'Use .NET Core SDK 3.1.201'
inputs:
packageType: sdk
version: '3.1.201'
- task: UsePythonVersion@0
inputs:
versionSpec: '3.6'
architecture: 'x64'
displayName: 'Use Python 3.6'
- script: pip install setuptools wheel pytest jupyter
displayName: 'Install Python tools'
- powershell: ./install-iqsharp.ps1
displayName: "Installing IQ#"
workingDirectory: $(System.DefaultWorkingDirectory)/scripts
##
# Build, test & pack
##
@ -38,3 +16,6 @@ steps:
displayName: "Packing"
workingDirectory: $(System.DefaultWorkingDirectory)/scripts
- powershell: ./manifest.ps1
displayName: "List built assemblies"
workingDirectory: $(System.DefaultWorkingDirectory)/scripts

23
scripts/steps-init.yml Normal file
Просмотреть файл

@ -0,0 +1,23 @@
steps:
##
# Pre-reqs
##
- task: UseDotNet@2
displayName: 'Use .NET Core SDK 3.1.201'
inputs:
packageType: sdk
version: '3.1.201'
- task: UsePythonVersion@0
inputs:
versionSpec: '3.6'
architecture: 'x64'
displayName: 'Use Python 3.6'
- script: pip install setuptools wheel pytest jupyter
displayName: 'Install Python tools'
- powershell: ./install-iqsharp.ps1
displayName: "Installing IQ#"
workingDirectory: $(System.DefaultWorkingDirectory)/scripts

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

@ -1,15 +1,33 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
$ErrorActionPreference = 'Stop'
& "$PSScriptRoot/set-env.ps1"
$all_ok = $True
& "$PSScriptRoot/validate-unicode.ps1"
function Test-One {
Param($project)
# Validating all katas projects can be disables with the ENABLE_KATAS
if ($Env:ENABLE_KATAS -ne "false") {
& "$PSScriptRoot/validate-notebooks.ps1"
} else {
Write-Host "##vso[task.logissue type=warning;]Skipping testing Katas notebooks. Env:ENABLE_KATAS is '$Env:ENABLE_KATAS'."
Write-Host "##[info]Testing $project"
dotnet test $project `
-c $Env:BUILD_CONFIGURATION `
-v $Env:BUILD_VERBOSITY `
--no-build `
--logger trx `
/property:DefineConstants=$Env:ASSEMBLY_CONSTANTS `
/property:InformationalVersion=$Env:SEMVER_VERSION `
/property:Version=$Env:ASSEMBLY_VERSION
if ($LastExitCode -ne 0) {
Write-Host "##vso[task.logissue type=error;]Failed to test $project"
$script:all_ok = $False
}
}
Write-Host "Testing Katas binaries:"
Test-One '..\utilities\DumpUnitary\DumpUnitary.sln'
Test-One '..\utilities\Microsoft.Quantum.Katas\Microsoft.Quantum.Katas.sln'
if (-not $all_ok) {
throw "At least one test failed execution. Check the logs."
}

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

@ -0,0 +1,27 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
$ErrorActionPreference = 'Stop'
& "$PSScriptRoot/set-env.ps1"
function Build-One {
param(
$project
);
Write-Host "##[info]Building $project..."
dotnet build $project `
-c $Env:BUILD_CONFIGURATION `
-v $Env:BUILD_VERBOSITY `
/property:DefineConstants=$Env:ASSEMBLY_CONSTANTS `
/property:Version=$Env:ASSEMBLY_VERSION `
/property:QsharpDocsOutDir=$Env:DOCS_OUTDIR
$script:all_ok = ($LastExitCode -eq 0) -and $script:all_ok
}
# Build all Katas solutions:
Get-ChildItem (Join-Path $PSScriptRoot '..') -Recurse -Include '*.sln' -Exclude 'Microsoft.Quantum.Katas.sln' `
| ForEach-Object { Build-One $_.FullName }