Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Separate CI build and validation scripts for different areas (#410)
Browse files Browse the repository at this point in the history
* 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.
anpaz authored Jul 22, 2020
1 parent 18c1958 commit a93e56d
Showing 7 changed files with 147 additions and 59 deletions.
67 changes: 48 additions & 19 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -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


14 changes: 4 additions & 10 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
@@ -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:
Build-One '..\utilities\Microsoft.Quantum.Katas\Microsoft.Quantum.Katas.sln'
Write-Host "Building Katas binaries:"

# 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'."
}
Build-One '..\utilities\DumpUnitary\DumpUnitary.sln'
Build-One '..\utilities\Microsoft.Quantum.Katas\Microsoft.Quantum.Katas.sln'

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 changes: 16 additions & 0 deletions scripts/manifest.ps1
Original file line number Diff line number Diff line change
@@ -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;
25 changes: 3 additions & 22 deletions scripts/steps.yml → scripts/steps-binaries.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 23 additions & 0 deletions scripts/steps-init.yml
Original file line number Diff line number Diff line change
@@ -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
34 changes: 26 additions & 8 deletions scripts/test.ps1
Original file line number Diff line number Diff line change
@@ -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

function Test-One {
Param($project)

& "$PSScriptRoot/validate-unicode.ps1"
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

# 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'."
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."
}
27 changes: 27 additions & 0 deletions scripts/validate-projects.ps1
Original file line number Diff line number Diff line change
@@ -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 }

0 comments on commit a93e56d

Please sign in to comment.