forked from xunit/xunit.analyzers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c054815
commit 9f40d46
Showing
30 changed files
with
795 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"cSpell.words": [ | ||
"app", | ||
"nuget", | ||
"nupkg", | ||
"parallelization", | ||
"veyor" | ||
], | ||
"files.exclude": { | ||
"**/.git": true, | ||
"**/.DS_Store": true, | ||
"**/bin": true, | ||
"**/obj": true, | ||
"artifacts": true, | ||
"packages": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Build", | ||
"type": "process", | ||
"command": "dotnet", | ||
"args": [ | ||
"run", | ||
"--project", | ||
"tools/builder", | ||
"--no-launch-profile", | ||
"--", | ||
"Build" | ||
], | ||
"options": { | ||
"cwd": "${workspaceRoot}" | ||
}, | ||
"group": "build", | ||
"presentation": { | ||
"focus": true | ||
}, | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"label": "Pre-PR Validation", | ||
"type": "process", | ||
"command": "dotnet", | ||
"args": [ | ||
"run", | ||
"--project", | ||
"tools/builder", | ||
"--no-launch-profile", | ||
"--", | ||
"Packages" | ||
], | ||
"options": { | ||
"cwd": "${workspaceRoot}" | ||
}, | ||
"group": "build", | ||
"presentation": { | ||
"focus": true | ||
}, | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"label": "Unit Tests (.NET Core)", | ||
"type": "process", | ||
"command": "dotnet", | ||
"args": [ | ||
"run", | ||
"--project", | ||
"tools/builder", | ||
"--no-launch-profile", | ||
"--", | ||
"TestCore" | ||
], | ||
"options": { | ||
"cwd": "${workspaceRoot}" | ||
}, | ||
"group": "build", | ||
"presentation": { | ||
"focus": true | ||
}, | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"label": "Unit Tests (.NET Framework)", | ||
"type": "process", | ||
"command": "dotnet", | ||
"args": [ | ||
"run", | ||
"--project", | ||
"tools/builder", | ||
"--no-launch-profile", | ||
"--", | ||
"TestFx" | ||
], | ||
"options": { | ||
"cwd": "${workspaceRoot}" | ||
}, | ||
"group": "build", | ||
"presentation": { | ||
"focus": true | ||
}, | ||
"problemMatcher": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
PUSHED=0 | ||
|
||
cleanup () { | ||
if [[ $PUSHED == 1 ]]; then | ||
popd >/dev/null | ||
PUSHED=0 | ||
fi | ||
} | ||
|
||
trap cleanup EXIT ERR INT TERM | ||
|
||
if which dotnet > /dev/null; then | ||
if which mono > /dev/null; then | ||
pushd $( cd "$(dirname "$0")" ; pwd -P ) >/dev/null | ||
PUSHED=1 | ||
|
||
dotnet run --project tools/builder --no-launch-profile -- "$@" | ||
else | ||
echo "error(1): Could not find 'mono'; please install Mono" 2>&1 | ||
exit 1 | ||
fi | ||
else | ||
echo "error(1): Could not find 'dotnet'; please install the .NET Core SDK" 2>&1 | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,150 +1,18 @@ | ||
param( | ||
[string] $target = "test", | ||
[string] $configuration = "Release", | ||
[string] $buildAssemblyVersion = "", | ||
[string] $buildSemanticVersion = "" | ||
) | ||
#!/usr/bin/env pwsh | ||
#Requires -Version 5.1 | ||
|
||
if ($PSScriptRoot -eq $null) { | ||
fatal "This build script requires PowerShell 3 or later." | ||
} | ||
|
||
$buildModuleFile = join-path $PSScriptRoot "build\tools\xunit-build-module.psm1" | ||
|
||
if ((test-path $buildModuleFile) -eq $false) { | ||
write-host "Could not find build module. Did you forget to 'git submodule update --init'?" -ForegroundColor Red | ||
exit -1 | ||
} | ||
|
||
Set-StrictMode -Version 2 | ||
Import-Module $buildModuleFile -Scope Local -Force -ArgumentList "4.1.0" | ||
Set-Location $PSScriptRoot | ||
|
||
$packageOutputFolder = (join-path (Get-Location) "artifacts\packages") | ||
$parallelFlags = "-parallel all -maxthreads 16" | ||
$testOutputFolder = (join-path (Get-Location) "artifacts\test") | ||
$solutionFolder = Get-Location | ||
|
||
$signClientVersion = "0.9.1" | ||
$signClientFolder = (join-path (Get-Location) "packages\SignClient.$signClientVersion") | ||
$signClientAppSettings = (join-path (Get-Location) "tools\SignClient\appsettings.json") | ||
|
||
# Helper functions | ||
|
||
function _xunit_console([string] $command) { | ||
_exec ('& "' + $PSScriptRoot + '\packages\xunit.runner.console\tools\net472\xunit.console.x86.exe" ' + $command) | ||
} | ||
Set-StrictMode -Version Latest | ||
$ErrorActionPreference = "Stop" | ||
|
||
# Top-level targets | ||
|
||
function __target_appveyor() { | ||
__target_ci | ||
__target__signpackages | ||
__target__pushmyget | ||
} | ||
|
||
function __target_build() { | ||
__target_packagerestore | ||
|
||
_build_step "Compiling binaries" | ||
_msbuild "xunit.analyzers.sln" $configuration | ||
|
||
_dotnet ("tools\DocBuilder\bin\Release\netcoreapp2.1\Xunit.Analyzers.DocBuilder.dll " + (Join-Path $PSScriptRoot "docs")) # "Verifying documentation files" | ||
if ($null -eq (Get-Command "dotnet" -ErrorAction Ignore)) { | ||
throw "Could not find 'dotnet'; please install the .NET Core SDK" | ||
} | ||
|
||
function __target_ci() { | ||
__target__setversion | ||
__target_test | ||
__target__packages | ||
} | ||
|
||
function __target_packagerestore() { | ||
_download_nuget | ||
Push-Location (Split-Path $MyInvocation.MyCommand.Definition) | ||
|
||
_build_step "Restoring NuGet packages" | ||
_mkdir packages | ||
_exec ('& "' + $nugetExe + '" restore xunit.analyzers.sln -NonInteractive') | ||
_exec ('& "' + $nugetExe + '" install xunit.runner.console -OutputDirectory "' + (Join-Path $PSScriptRoot "packages") + '" -NonInteractive -ExcludeVersion') | ||
try { | ||
& dotnet run --project tools/builder --no-launch-profile -- $args | ||
} | ||
|
||
function __target_packages() { | ||
__target_build | ||
__target__packages | ||
} | ||
|
||
function __target_test() { | ||
__target_build | ||
__target__test | ||
finally { | ||
Pop-Location | ||
} | ||
|
||
# Dependent targets | ||
|
||
function __target__packages() { | ||
_download_nuget | ||
|
||
_build_step "Creating NuGet packages" | ||
Get-ChildItem -Recurse -Filter *.nuspec | _nuget_pack -outputFolder $packageOutputFolder -configuration $configuration | ||
} | ||
|
||
function __target__pushmyget() { | ||
_build_step "Pushing packages to MyGet" | ||
if ($env:MyGetApiKey -eq $null) { | ||
Write-Host -ForegroundColor Yellow "Skipping MyGet push because environment variable 'MyGetApiKey' is not set." | ||
Write-Host "" | ||
} else { | ||
Get-ChildItem -Filter *.nupkg $packageOutputFolder | _nuget_push -source https://www.myget.org/F/xunit/api/v2/package -apiKey $env:MyGetApiKey | ||
} | ||
} | ||
|
||
function __target__setversion() { | ||
if ($buildAssemblyVersion -ne "") { | ||
_build_step ("Setting assembly version: '" + $buildAssemblyVersion + "'") | ||
Get-ChildItem -Recurse -Filter AssemblyInfo.cs | _replace -match '\("99\.99\.99\.0"\)' -replacement ('("' + $buildAssemblyVersion + '")') | ||
} | ||
|
||
if ($buildSemanticVersion -ne "") { | ||
_build_step ("Setting semantic version: '" + $buildSemanticVersion + "'") | ||
Get-ChildItem -Recurse -Filter AssemblyInfo.cs | _replace -match '\("99\.99\.99-dev"\)' -replacement ('("' + $buildSemanticVersion + '")') | ||
Get-ChildItem -Recurse -Filter *.nuspec | _replace -match '99\.99\.99-dev' -replacement $buildSemanticVersion | ||
} | ||
} | ||
|
||
function __target__signpackages() { | ||
if ($env:SignClientSecret -ne $null) { | ||
if ((test-path $signClientFolder) -eq $false) { | ||
_build_step ("Downloading SignClient " + $signClientVersion) | ||
_exec ('& "' + $nugetExe + '" install SignClient -version ' + $signClientVersion + ' -SolutionDir "' + $solutionFolder + '" -Verbosity quiet -NonInteractive') | ||
} | ||
|
||
_build_step "Signing NuGet packages" | ||
$appPath = (join-path $signClientFolder "tools\netcoreapp2.0\SignClient.dll") | ||
$nupgks = Get-ChildItem (join-path $packageOutputFolder "*.nupkg") | ForEach-Object { $_.FullName } | ||
foreach ($nupkg in $nupgks) { | ||
$cmd = '& dotnet "' + $appPath + '" sign -c "' + $signClientAppSettings + '" -r "' + $env:SignClientUser + '" -s "' + $env:SignClientSecret + '" -n "xUnit.net" -d "xUnit.net" -u "https://github.com/xunit/xunit.analyzers" -i "' + $nupkg + '"' | ||
$msg = $cmd.Replace($env:SignClientSecret, '[Redacted]') | ||
$msg = $msg.Replace($env:SignClientUser, '[Redacted]') | ||
_exec $cmd $msg | ||
} | ||
} | ||
} | ||
|
||
function __target__test() { | ||
_build_step "Running unit tests" | ||
_xunit_console ("test\xunit.analyzers.tests\bin\" + $configuration + "\net472\xunit.analyzers.tests.dll -xml artifacts\test\TestResults.xml -diagnostics") | ||
} | ||
|
||
# Dispatch | ||
|
||
$targetFunction = (Get-ChildItem ("Function:__target_" + $target.ToLowerInvariant()) -ErrorAction SilentlyContinue) | ||
if ($targetFunction -eq $null) { | ||
_fatal "Unknown target '$target'" | ||
} | ||
|
||
_build_step "Performing pre-build verifications" | ||
_require dotnet "Could not find 'dotnet'. Please ensure .NET CLI Tooling is installed." | ||
_require msbuild "Could not find 'msbuild'. Please ensure MSBUILD.EXE v15 is on the path." | ||
_verify_msbuild15 | ||
|
||
_mkdir $packageOutputFolder | ||
_mkdir $testOutputFolder | ||
& $targetFunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.