Skip to content

Commit

Permalink
Add Support for Azure Pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
GuruCharan94 authored and NickCraver committed Jan 11, 2019
1 parent 0f5b4c5 commit 081f36c
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 1 deletion.
67 changes: 67 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
resources:
- repo: self
clean: true
queue:
name: Hosted VS2017

# Build Variables
variables:
MySQLConnectionString: server=localhost;uid=root;pwd='';database=test;Allow User Variables=true
PGPASSWORD: Password12! #Needed for PostgreSQL Installation
PGUSER: postgres #Needed for PostgreSQL Installation
PostgreSqlConnectionString: Server=localhost;Port=5432;Database=test;User Id=postgres;Password=Password12!;
SQLServerConnectionString: Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=tempdb;Trusted_Connection=True;
system.debug: true

# CI Trigger on master branch
trigger:
batch: false
branches:
include:
- master
paths:
exclude:
- docs/*
- '**/*.md'

# Trigger builds for PR's targeting master
pr:
branches:
include:
- master
paths:
exclude:
- docs/*
- '**/*.md'

steps:
- task: DotNetCoreInstaller@0
displayName: 'Install DotNet Core 2.1.3'
inputs:
version: 2.1.300

- task: NuGetToolInstaller@0
displayName: 'Install NuGet CLI 4.4.1'
inputs:
versionSpec: 4.4.1

- task: PowerShell@2
displayName: 'Build / Test / Create Packages'
inputs:
targetType: filePath
filePath: build.AzureDevops.ps1

- task: PublishTestResults@2
displayName: 'Publish Test Results **/Test-*.xml'
inputs:
testResultsFormat: XUnit
testResultsFiles: '**/Test-*.xml'
mergeTestResults: true

# PR doesn't create nuget packages. So publish artifact step disabled for PR's
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: packages'
inputs:
PathtoPublish: .nupkgs
ArtifactName: packages
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
26 changes: 26 additions & 0 deletions build.azureDevops.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Setup Redis with Nuget
nuget install redis-64 -excludeversion
redis-64\tools\redis-server.exe --service-install; redis-64\tools\redis-server.exe --service-start

# Setup PostgreSQL, MySQL, MongoDB using Chocolatey
choco feature enable -n=allowGlobalConfirmation
choco install mongodb --version 3.6.0
choco install mysql --version 5.7.18
choco install postgresql --version 9.6.8 --params "/Password:$PGPASSWORD"

# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
refreshenv

mysql -e "create database test;" --user=root
createdb test

mkdir D:\data\db
# Start MongoDB as run as Background Process
Start-Process "C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe" -ArgumentList "--dbpath D:\data\db" -NoNewWindow -RedirectStandardOutput log.txt

# Build Variables at https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=vsts#build-variables
.\build.ps1 -CreatePackages $true -PullRequestNumber $env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if ($RunTests) {
Write-Host "Running tests: $project (all frameworks)" -ForegroundColor "Magenta"
Push-Location ".\tests\$project"

dotnet xunit -configuration Release --no-build
dotnet xunit -configuration Release --no-build -xml "Test-$project.xml"
if ($LastExitCode -ne 0) {
Write-Host "Error with tests, aborting build." -Foreground "Red"
Pop-Location
Expand Down

0 comments on commit 081f36c

Please sign in to comment.