From c1582794689ab84d2fe3e1e42e71a4a98d0386a3 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Sat, 7 Mar 2020 00:09:03 +0900 Subject: [PATCH] Update tooling --- .config/dotnet-tools.json | 12 ++++ InspectCode.ps1 | 27 +++++++++ appveyor.yml | 18 ++++-- build.ps1 | 82 -------------------------- build.sh | 38 ------------ build/{build.cake => InspectCode.cake} | 23 ++++---- build/cakebuild.csproj | 11 ---- 7 files changed, 63 insertions(+), 148 deletions(-) create mode 100644 .config/dotnet-tools.json create mode 100644 InspectCode.ps1 delete mode 100644 build.ps1 delete mode 100755 build.sh rename build/{build.cake => InspectCode.cake} (75%) delete mode 100644 build/cakebuild.csproj diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 0000000..a2ba9ce --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "cake.tool": { + "version": "0.35.0", + "commands": [ + "dotnet-cake" + ] + } + } +} diff --git a/InspectCode.ps1 b/InspectCode.ps1 new file mode 100644 index 0000000..c6f018f --- /dev/null +++ b/InspectCode.ps1 @@ -0,0 +1,27 @@ +[CmdletBinding()] +Param( + [string]$Target, + [string]$Configuration, + [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] + [string]$Verbosity, + [switch]$ShowDescription, + [Alias("WhatIf", "Noop")] + [switch]$DryRun, + [Parameter(Position = 0, Mandatory = $false, ValueFromRemainingArguments = $true)] + [string[]]$ScriptArgs +) + +# Build Cake arguments +$cakeArguments = ""; +if ($Target) { $cakeArguments += "-target=$Target" } +if ($Configuration) { $cakeArguments += "-configuration=$Configuration" } +if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" } +if ($ShowDescription) { $cakeArguments += "-showdescription" } +if ($DryRun) { $cakeArguments += "-dryrun" } +if ($Experimental) { $cakeArguments += "-experimental" } +$cakeArguments += $ScriptArgs + +dotnet tool restore +dotnet cake ./build/InspectCode.cake --bootstrap +dotnet cake ./build/InspectCode.cake $cakeArguments +exit $LASTEXITCODE diff --git a/appveyor.yml b/appveyor.yml index 97d014d..9aa0b17 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,8 +1,18 @@ clone_depth: 1 version: '{branch}-{build}' image: Visual Studio 2019 -test: off +cache: + - '%LOCALAPPDATA%\NuGet\v3-cache -> appveyor.yml' install: - - cmd: git submodule update --init --recursive -build_script: - - cmd: PowerShell -Version 2.0 .\build.ps1 + - cmd: git submodule update --init --recursive # Required for submodules +before_build: + - ps: dotnet --info # Useful when version mismatch between CI and local +build: + project: osu-tools.sln + parallel: true + verbosity: minimal + publish_nuget: false +after_build: + - ps: dotnet tool restore + - ps: .\InspectCode.ps1 +test: off diff --git a/build.ps1 b/build.ps1 deleted file mode 100644 index c6a0bf6..0000000 --- a/build.ps1 +++ /dev/null @@ -1,82 +0,0 @@ -########################################################################## -# This is a customized Cake bootstrapper script for PowerShell. -########################################################################## - -<# - -.SYNOPSIS -This is a Powershell script to bootstrap a Cake build. - -.DESCRIPTION -This Powershell script restores NuGet tools (including Cake) -and execute your Cake build script with the parameters you provide. - -.PARAMETER Script -The build script to execute. -.PARAMETER Target -The build script target to run. -.PARAMETER Configuration -The build configuration to use. -.PARAMETER Verbosity -Specifies the amount of information to be displayed. -.PARAMETER ShowDescription -Shows description about tasks. -.PARAMETER DryRun -Performs a dry run. -.PARAMETER ScriptArgs -Remaining arguments are added here. - -.LINK -https://cakebuild.net - -#> - -[CmdletBinding()] -Param( - [string]$Script = "build.cake", - [string]$Target, - [string]$Configuration, - [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] - [string]$Verbosity, - [switch]$ShowDescription, - [Alias("WhatIf", "Noop")] - [switch]$DryRun, - [Parameter(Position = 0, Mandatory = $false, ValueFromRemainingArguments = $true)] - [string[]]$ScriptArgs -) - -Write-Host "Preparing to run build script..." - -# Determine the script root for resolving other paths. -if(!$PSScriptRoot) { - $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent -} - -# Resolve the paths for resources used for debugging. -$BUILD_DIR = Join-Path $PSScriptRoot "build" -$TOOLS_DIR = Join-Path $BUILD_DIR "tools" -$CAKE_CSPROJ = Join-Path $BUILD_DIR "cakebuild.csproj" - -# Install the required tools locally. -Write-Host "Restoring cake tools..." -Invoke-Expression "dotnet restore `"$CAKE_CSPROJ`" --packages `"$TOOLS_DIR`"" | Out-Null - -# Find the Cake executable -$CAKE_EXECUTABLE = (Get-ChildItem -Path "$TOOLS_DIR/cake.coreclr/" -Filter Cake.dll -Recurse).FullName - -# Build Cake arguments -$cakeArguments = @("$Script"); -if ($Target) { $cakeArguments += "-target=$Target" } -if ($Configuration) { $cakeArguments += "-configuration=$Configuration" } -if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" } -if ($ShowDescription) { $cakeArguments += "-showdescription" } -if ($DryRun) { $cakeArguments += "-dryrun" } -if ($Experimental) { $cakeArguments += "-experimental" } -$cakeArguments += $ScriptArgs - -# Start Cake -Write-Host "Running build script..." -Push-Location -Path $BUILD_DIR -Invoke-Expression "dotnet `"$CAKE_EXECUTABLE`" $cakeArguments" -Pop-Location -exit $LASTEXITCODE diff --git a/build.sh b/build.sh deleted file mode 100755 index 8f1ef5b..0000000 --- a/build.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash - -########################################################################## -# This is a customized Cake bootstrapper script for Shell. -########################################################################## - -echo "Preparing to run build script..." - -cd build -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -TOOLS_DIR=$SCRIPT_DIR/tools -CAKE_BINARY_PATH=$TOOLS_DIR/"cake.coreclr" - -SCRIPT="build.cake" -CAKE_CSPROJ=$SCRIPT_DIR/"cakebuild.csproj" - -# Parse arguments. -CAKE_ARGUMENTS=() -for i in "$@"; do - case $1 in - -s|--script) SCRIPT="$2"; shift ;; - --) shift; CAKE_ARGUMENTS+=("$@"); break ;; - *) CAKE_ARGUMENTS+=("$1") ;; - esac - shift -done - -# Install the required tools locally. -echo "Restoring cake tools..." -dotnet restore $CAKE_CSPROJ --packages $TOOLS_DIR > /dev/null 2>&1 - -# Search for the CakeBuild binary. -CAKE_BINARY=$(find $CAKE_BINARY_PATH -name "Cake.dll") - -# Start Cake -echo "Running build script..." - -dotnet "$CAKE_BINARY" $SCRIPT "${CAKE_ARGUMENTS[@]}" diff --git a/build/build.cake b/build/InspectCode.cake similarity index 75% rename from build/build.cake rename to build/InspectCode.cake index 1e6f31f..c8b47db 100644 --- a/build/build.cake +++ b/build/InspectCode.cake @@ -7,31 +7,28 @@ var nVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First(); // ARGUMENTS /////////////////////////////////////////////////////////////////////////////// -var target = Argument("target", "Build"); +var target = Argument("target", "CodeAnalysis"); var configuration = Argument("configuration", "Release"); var rootDirectory = new DirectoryPath(".."); -var solution = rootDirectory.CombineWithFilePath("osu.Tools.sln"); +var sln = rootDirectory.CombineWithFilePath("osu.Tools.sln"); /////////////////////////////////////////////////////////////////////////////// // TASKS /////////////////////////////////////////////////////////////////////////////// -Task("Compile") - .Does(() => { - DotNetCoreBuild(solution.FullPath, new DotNetCoreBuildSettings { - Configuration = configuration, - }); - }); - -// windows only because both inspectcore and nvika depend on net45 +// windows only because both inspectcode and nvika depend on net45 Task("InspectCode") .WithCriteria(IsRunningOnWindows()) - .IsDependentOn("Compile") .Does(() => { - InspectCode(solution, new InspectCodeSettings { + InspectCode(sln, new InspectCodeSettings { CachesHome = "inspectcode", OutputFile = "inspectcodereport.xml", + ArgumentCustomization = arg => { + if (AppVeyor.IsRunningOnAppVeyor) // Don't flood CI output + arg.Append("--verbosity:WARN"); + return arg; + }, }); int returnCode = StartProcess(nVikaToolPath, $@"parsereport ""inspectcodereport.xml"" --treatwarningsaserrors"); @@ -47,7 +44,7 @@ Task("CodeFileSanity") }); }); -Task("Build") +Task("CodeAnalysis") .IsDependentOn("CodeFileSanity") .IsDependentOn("InspectCode"); diff --git a/build/cakebuild.csproj b/build/cakebuild.csproj deleted file mode 100644 index 04980be..0000000 --- a/build/cakebuild.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - Exe - true - netcoreapp2.0 - - - - - -