diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 0000000..877eb1c --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,34 @@ +#---------------------------------# +# Build Image # +#---------------------------------# +image: Visual Studio 2019 + +#---------------------------------# +# Build Script # +#---------------------------------# +install: + # Update to latest NuGet version since we require 5.3.0 for embedded icon + - ps: nuget update -self + +build_script: + - ps: .\build.ps1 -Target AppVeyor + +# Tests +test: off + +#---------------------------------# +# Branches to build # +#---------------------------------# +branches: + # Whitelist + only: + - develop + - master + - /release/.*/ + - /hotfix/.*/ + +#---------------------------------# +# Build Cache # +#---------------------------------# +cache: +- tools -> recipe.cake diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..59b22b9 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,3 @@ +# These owners will be the default owners for everything in the repo and +# will be requested for review when someone opens a pull request. +* @pascalberger \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..8e72601 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,58 @@ +name: Build and tests +on: [push, pull_request] +jobs: + # Build + Build: + name: Build + runs-on: windows-latest + steps: + - name: Get the sources + uses: actions/checkout@v2 + - name: Fetch all tags and branches + run: git fetch --prune --unshallow + - name: Build + run: .\build.ps1 + shell: powershell + - name: Publish NuGet package as build artifact + uses: actions/upload-artifact@v2 + with: + name: NuGet Package + path: ./BuildArtifacts/Packages/NuGet/ + # Integration Tests Windows (.NET Framework) + Test_Windows_DotNetFramework: + name: Integration Tests Windows (.NET Framework) + needs: Build + runs-on: windows-latest + steps: + - name: Get the sources + uses: actions/checkout@v2 + - name: Download build artifact + uses: actions/download-artifact@v2 + with: + name: NuGet Package + path: ./BuildArtifacts/Packages/NuGet + - name: Run integration tests + run: ./build.ps1 -verbosity diagnostic + working-directory: ./tests/integration/ + shell: powershell + # Integration Tests Windows (.NET Core tool) + Test_Windows_DotNetCoreTool: + name: Integration Tests Windows (.NET Core tool) + needs: Build + runs-on: windows-latest + steps: + - name: Get the sources + uses: actions/checkout@v2 + - name: Download build artifact + uses: actions/download-artifact@v2 + with: + name: NuGet Package + path: ./BuildArtifacts/Packages/NuGet + - name: Restore .NET Core tool + run: dotnet tool restore + working-directory: ./tests/integration/ + shell: powershell + - name: Run integration tests + run: dotnet cake + working-directory: ./tests/integration/ + shell: powershell diff --git a/.gitignore b/.gitignore index 3e759b7..a9e78cf 100644 --- a/.gitignore +++ b/.gitignore @@ -24,14 +24,11 @@ bld/ [Oo]bj/ [Ll]og/ -# Visual Studio 2015/2017 cache/options directory +# Visual Studio 2015 cache/options directory .vs/ # Uncomment if you have tasks that create the project's static files in wwwroot #wwwroot/ -# Visual Studio 2017 auto generated files -Generated\ Files/ - # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* @@ -45,29 +42,20 @@ TestResult.xml [Rr]eleasePS/ dlldata.c -# Benchmark Results -BenchmarkDotNet.Artifacts/ - # .NET Core project.lock.json project.fragment.lock.json artifacts/ **/Properties/launchSettings.json -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio *_i.c *_p.c *_i.h *.ilk *.meta *.obj -*.iobj *.pch *.pdb -*.ipdb *.pgc *.pgd *.rsp @@ -105,9 +93,6 @@ ipch/ *.vspx *.sap -# Visual Studio Trace Files -*.e2e - # TFS 2012 Local Workspace $tf/ @@ -128,10 +113,6 @@ _TeamCity* # DotCover is a Code Coverage Tool *.dotCover -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - # Visual Studio code coverage results *.coverage *.coveragexml @@ -167,7 +148,7 @@ publish/ # Publish Web Output *.[Pp]ublish.xml *.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, +# TODO: Comment the next line if you want to checkin your web deploy settings # but database connection strings (with potential passwords) will be unencrypted *.pubxml *.publishproj @@ -180,12 +161,12 @@ PublishScripts/ # NuGet Packages *.nupkg # The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* +**/packages/* # except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ +!**/packages/build/ # Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files *.nuget.props *.nuget.targets @@ -202,7 +183,6 @@ AppPackages/ BundleArtifacts/ Package.StoreAssociation.xml _pkginfo.txt -*.appx # Visual Studio cache files # files ending in .cache can be ignored @@ -221,10 +201,6 @@ ClientBin/ *.publishsettings orleans.codegen.cs -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - # Since there are multiple workflows, uncomment next line to ignore bower_components # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) #bower_components/ @@ -239,19 +215,15 @@ _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak # SQL Server files *.mdf *.ldf -*.ndf # Business Intelligence projects *.rdl.data *.bim.layout *.bim_*.settings -*.rptproj.rsuser # Microsoft Fakes FakesAssemblies/ @@ -263,6 +235,9 @@ FakesAssemblies/ .ntvs_analysis.dat node_modules/ +# Typescript v1 declaration files +typings/ + # Visual Studio 6 build log *.plg @@ -299,32 +274,6 @@ __pycache__/ *.pyc # Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ +tools/** +!tools/packages.config +BuildArtifacts/ \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..078295e --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,35 @@ +# Contribution Guidelines + +This repository uses [GitFlow] with default configuration. +Development is happening on `develop` branch. + +To contribute: + +* Fork this repository. +* Create a feature branch from `develop`. +* Implement your changes. +* Push your feature branch. +* Create a pull request. + +## Build + +To build this package we are using Cake. + +On Windows PowerShell run: + +```powershell +./build +``` + +On OSX/Linux run: + +```bash +./build.sh +``` + +## Release + +See [Cake.Recipe documentation] how to create a new release of this addin. + +[GitFlow]: (http://nvie.com/posts/a-successful-git-branching-model/) +[Cake.Recipe documentation]: https://cake-contrib.github.io/Cake.Recipe/docs/usage/creating-release \ No newline at end of file diff --git a/GitReleaseManager.yaml b/GitReleaseManager.yaml new file mode 100644 index 0000000..721c1ba --- /dev/null +++ b/GitReleaseManager.yaml @@ -0,0 +1,12 @@ +issue-labels-include: +- Breaking change +- Feature +- Bug +- Improvement +- Documentation +issue-labels-exclude: +- Build +issue-labels-alias: + - name: Documentation + header: Documentation + plural: Documentation \ No newline at end of file diff --git a/LICENSE b/LICENSE index 84f6451..8021318 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 Pascal Berger +Copyright (c) 2018-2020 Pascal Berger Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 1f6d78e..754f05a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,42 @@ -# Cake.Issues.PullRequests.GitHub -Addin for writing issues as comments to GitHub pull requests +# GitHub Actions support for Cake Issues Addin + +This addin for the Cake Build Automation System allows you to write issues found using any code +analyzer or linter to GitHub Actions builds using the [Cake Issues addin](https://github.com/cake-contrib/Cake.Issues). + +For more information about this add-in see the [Cake.Issues website](https://cakeissues.net) +and for general information about the Cake build automation system see the [Cake website](https://cakebuild.net) + +[![License](http://img.shields.io/:license-mit-blue.svg)](https://github.com/cake-contrib/Cake.Issues.PullRequests.GitHubActions/blob/feature/build/LICENSE) + +## Information + +| | Stable | Pre-release | +|:--:|:--:|:--:| +|GitHub Release|-|[![GitHub release](https://img.shields.io/github/release/cake-contrib/Cake.Issues.PullRequests.GitHubActions.svg)](https://github.com/cake-contrib/Cake.Issues.PullRequests.GitHubActions/releases/latest)| +|NuGet|[![NuGet](https://img.shields.io/nuget/v/Cake.Issues.PullRequests.GitHubActions.svg)](https://www.nuget.org/packages/Cake.Issues.PullRequests.GitHubActions)|[![NuGet](https://img.shields.io/nuget/vpre/Cake.Issues.PullRequests.GitHubActions.svg)](https://www.nuget.org/packages/Cake.Issues.PullRequests.GitHubActions)| + +## Build Status + +| | Develop | Master | +|:--:|:--:|:--:| +|AppVeyor Windows|[![Build status](https://ci.appveyor.com/api/projects/status/trj0g753r3hcw22k/branch/develop?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-issues-pullrequests-githubactions/branch/develop)|[![Build status](https://ci.appveyor.com/api/projects/status/trj0g753r3hcw22k/branch/master?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-issues-pullrequests-githubactions/branch/master)| +|Azure DevOps Windows|[![Build Status](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.GitHubActions/_apis/build/status/cake-contrib.Cake.Issues.PullRequests.GitHubActions?branchName=develop&jobName=Windows)](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.GitHubActions/_build/latest?definitionId=17&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.GitHubActions/_apis/build/status/cake-contrib.Cake.Issues.PullRequests.GitHubActions?branchName=master&jobName=Windows)](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.GitHubActions/_build/latest?definitionId=17&branchName=master)| +|GitHub Actions Windows|[![Build Status](https://github.com/cake-contrib/Cake.Issues.PullRequests.GitHubActions/workflows/Build%20and%20tests/badge.svg?branch=develop)](https://github.com/cake-contrib/Cake.Issues.PullRequests.GitHubActions/actions?query=workflow%3A"Build+and+tests"+branch%3Adevelop)|[![Build Status](https://github.com/cake-contrib/Cake.Issues.PullRequests.GitHubActions/workflows/Build%20and%20tests/badge.svg?branch=master)](https://github.com/cake-contrib/Cake.Issues.PullRequests.GitHubActions/actions?query=workflow%3A"Build+and+tests"+branch%3Amaster)| + +## Code Coverage + +[![Coverage Status](https://coveralls.io/repos/github/cake-contrib/Cake.Issues.PullRequests.GitHubActions/badge.svg?branch=develop)](https://coveralls.io/github/cake-contrib/Cake.Issues.PullRequests.GitHubActions?branch=develop) + +## Quick Links + +- [Documentation](https://cakeissues.net) + +## Chat Room + +Come join in the conversation about this addin in our Gitter Chat Room + +[![Join the chat at https://gitter.im/cake-contrib/Lobby](https://badges.gitter.im/cake-contrib/Lobby.svg)](https://gitter.im/cake-contrib/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +## Contributing + +Contributions are welcome. See [Contribution Guidelines](CONTRIBUTING.md). \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..d7198be --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,18 @@ +trigger: +- develop +- master +- release/* +- hotfix/* + +pr: +- develop +- release/* +- hotfix/* + +jobs: +- job: Windows + pool: + vmImage: 'vs2017-win2016' + steps: + - powershell: ./build.ps1 + displayName: 'Cake Build' \ No newline at end of file diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..9a6ade2 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,233 @@ +########################################################################## +# This is the Cake bootstrapper script for PowerShell. +# This file was downloaded from https://github.com/cake-build/resources +# Feel free to change this file to fit your needs. +########################################################################## + +<# + +.SYNOPSIS +This is a Powershell script to bootstrap a Cake build. + +.DESCRIPTION +This Powershell script will download NuGet if missing, restore 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 Experimental +Uses the nightly builds of the Roslyn script engine. +.PARAMETER Mono +Uses the Mono compiler rather than the Roslyn script engine. +.PARAMETER SkipToolPackageRestore +Skips restoring of packages. +.PARAMETER ScriptArgs +Remaining arguments are added here. + +.LINK +https://cakebuild.net + +#> + +[CmdletBinding()] +Param( + [string]$Script = "recipe.cake", + [string]$Target = "Default", + [ValidateSet("Release", "Debug")] + [string]$Configuration = "Release", + [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] + [string]$Verbosity = "Verbose", + [switch]$ShowDescription, + [Alias("WhatIf", "Noop")] + [switch]$DryRun, + [switch]$Experimental, + [switch]$Mono, + [switch]$SkipToolPackageRestore, + [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] + [string[]]$ScriptArgs +) + +[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null +function MD5HashFile([string] $filePath) +{ + if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf)) + { + return $null + } + + [System.IO.Stream] $file = $null; + [System.Security.Cryptography.MD5] $md5 = $null; + try + { + $md5 = [System.Security.Cryptography.MD5]::Create() + $file = [System.IO.File]::OpenRead($filePath) + return [System.BitConverter]::ToString($md5.ComputeHash($file)) + } + finally + { + if ($file -ne $null) + { + $file.Dispose() + } + } +} + +function GetProxyEnabledWebClient +{ + $wc = New-Object System.Net.WebClient + $proxy = [System.Net.WebRequest]::GetSystemWebProxy() + $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials + $wc.Proxy = $proxy + return $wc +} + +Write-Host "Preparing to run build script..." + +if(!$PSScriptRoot){ + $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent +} + +$TOOLS_DIR = Join-Path $PSScriptRoot "tools" +$ADDINS_DIR = Join-Path $TOOLS_DIR "Addins" +$MODULES_DIR = Join-Path $TOOLS_DIR "Modules" +$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe" +$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe" +$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" +$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config" +$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum" +$ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR "packages.config" +$MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config" + +# Make sure tools folder exists +if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) { + Write-Verbose -Message "Creating tools directory..." + New-Item -Path $TOOLS_DIR -Type directory | out-null +} + +# Make sure that packages.config exist. +if (!(Test-Path $PACKAGES_CONFIG)) { + Write-Verbose -Message "Downloading packages.config..." + try { + $wc = GetProxyEnabledWebClient + $wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch { + Throw "Could not download packages.config." + } +} + +# Try find NuGet.exe in path if not exists +if (!(Test-Path $NUGET_EXE)) { + Write-Verbose -Message "Trying to find nuget.exe in PATH..." + $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) } + $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1 + if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) { + Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)." + $NUGET_EXE = $NUGET_EXE_IN_PATH.FullName + } +} + +# Try download NuGet.exe if not exists +if (!(Test-Path $NUGET_EXE)) { + Write-Verbose -Message "Downloading NuGet.exe..." + try { + $wc = GetProxyEnabledWebClient + $wc.DownloadFile($NUGET_URL, $NUGET_EXE) + } catch { + Throw "Could not download NuGet.exe." + } +} + +# Save nuget.exe path to environment to be available to child processed +$ENV:NUGET_EXE = $NUGET_EXE + +# Restore tools from NuGet? +if(-Not $SkipToolPackageRestore.IsPresent) { + Push-Location + Set-Location $TOOLS_DIR + + # Check for changes in packages.config and remove installed tools if true. + [string] $md5Hash = MD5HashFile($PACKAGES_CONFIG) + if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or + ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { + Write-Verbose -Message "Missing or changed package.config hash..." + Remove-Item * -Recurse -Exclude packages.config,nuget.exe + } + + Write-Verbose -Message "Restoring tools from NuGet..." + $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`"" + + if ($LASTEXITCODE -ne 0) { + Throw "An error occurred while restoring NuGet tools." + } + else + { + $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII" + } + Write-Verbose -Message ($NuGetOutput | out-string) + + Pop-Location +} + +# Restore addins from NuGet +if (Test-Path $ADDINS_PACKAGES_CONFIG) { + Push-Location + Set-Location $ADDINS_DIR + + Write-Verbose -Message "Restoring addins from NuGet..." + $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`"" + + if ($LASTEXITCODE -ne 0) { + Throw "An error occurred while restoring NuGet addins." + } + + Write-Verbose -Message ($NuGetOutput | out-string) + + Pop-Location +} + +# Restore modules from NuGet +if (Test-Path $MODULES_PACKAGES_CONFIG) { + Push-Location + Set-Location $MODULES_DIR + + Write-Verbose -Message "Restoring modules from NuGet..." + $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`"" + + if ($LASTEXITCODE -ne 0) { + Throw "An error occurred while restoring NuGet modules." + } + + Write-Verbose -Message ($NuGetOutput | out-string) + + Pop-Location +} + +# Make sure that Cake has been installed. +if (!(Test-Path $CAKE_EXE)) { + Throw "Could not find Cake.exe at $CAKE_EXE" +} + +# 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" } +if ($Mono) { $cakeArguments += "-mono" } +$cakeArguments += $ScriptArgs + +# Start Cake +Write-Host "Running build script..." +&$CAKE_EXE $cakeArguments +exit $LASTEXITCODE \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..4b690aa --- /dev/null +++ b/build.sh @@ -0,0 +1,103 @@ +#!/usr/bin/env bash +########################################################################## +# This is the Cake bootstrapper script for Linux and OS X. +# This file was downloaded from https://github.com/cake-build/resources +# Feel free to change this file to fit your needs. +########################################################################## + +# Define directories. +SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +TOOLS_DIR=$SCRIPT_DIR/tools +NUGET_EXE=$TOOLS_DIR/nuget.exe +NUGET_URL=https://dist.nuget.org/win-x86-commandline/latest/nuget.exe +CAKE_VERSION=0.32.1 +CAKE_EXE=$TOOLS_DIR/Cake.$CAKE_VERSION/Cake.exe + +# Temporarily skip verification of addins. +export CAKE_SETTINGS_SKIPVERIFICATION='true' + +# Define default arguments. +SCRIPT="recipe.cake" +TARGET="Default" +CONFIGURATION="Release" +VERBOSITY="verbose" +DRYRUN= +SCRIPT_ARGUMENTS=() + +# Parse arguments. +for i in "$@"; do + case $1 in + -t|--target) TARGET="$2"; shift ;; + -c|--configuration) CONFIGURATION="$2"; shift ;; + -v|--verbosity) VERBOSITY="$2"; shift ;; + -d|--dryrun) DRYRUN="-dryrun" ;; + --) shift; SCRIPT_ARGUMENTS+=("$@"); break ;; + *) SCRIPT_ARGUMENTS+=("$1") ;; + esac + shift +done + +# Make sure the tools folder exist. +if [ ! -d "$TOOLS_DIR" ]; then + mkdir "$TOOLS_DIR" +fi + +# Print Mono version. +echo "Mono version:" +mono --version +echo "" + +########################################################################### +# INSTALL .NET CORE CLI +########################################################################### + +echo "Installing .NET CLI..." +if [ ! -d "$SCRIPT_DIR/.dotnet" ]; then + mkdir "$SCRIPT_DIR/.dotnet" +fi +curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" https://dot.net/v1/dotnet-install.sh +sudo bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version 2.1.400 --install-dir .dotnet --no-path +export PATH="$SCRIPT_DIR/.dotnet":$PATH +export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +export DOTNET_CLI_TELEMETRY_OPTOUT=1 +export DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0 +"$SCRIPT_DIR/.dotnet/dotnet" --info + +########################################################################### +# INSTALL NUGET +########################################################################### + +# Download NuGet if it does not exist. +if [ ! -f "$NUGET_EXE" ]; then + echo "Downloading NuGet..." + curl -Lsfo "$NUGET_EXE" $NUGET_URL + if [ $? -ne 0 ]; then + echo "An error occurred while downloading nuget.exe." + exit 1 + fi +fi + +########################################################################### +# INSTALL CAKE +########################################################################### + +if [ ! -f "$CAKE_EXE" ]; then + mono "$NUGET_EXE" install Cake -Version $CAKE_VERSION -OutputDirectory "$TOOLS_DIR" + if [ $? -ne 0 ]; then + echo "An error occurred while installing Cake." + exit 1 + fi +fi + +# Make sure that Cake has been installed. +if [ ! -f "$CAKE_EXE" ]; then + echo "Could not find Cake.exe at '$CAKE_EXE'." + exit 1 +fi + +########################################################################### +# RUN BUILD SCRIPT +########################################################################### + +# Start Cake +exec mono "$CAKE_EXE" $SCRIPT --verbosity=$VERBOSITY --configuration=$CONFIGURATION --target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}" diff --git a/cake.config b/cake.config new file mode 100644 index 0000000..652d5e8 --- /dev/null +++ b/cake.config @@ -0,0 +1,3 @@ +[Nuget] +; Use the new InProcess client, because some packages have long file paths. +UseInProcessClient=true \ No newline at end of file diff --git a/docs/examples/index.cshtml b/docs/examples/index.cshtml new file mode 100644 index 0000000..f6edfee --- /dev/null +++ b/docs/examples/index.cshtml @@ -0,0 +1,7 @@ +--- +Title: Examples +Description: Examples for using the Cake.Issues.PullRequests.GitHubActions addin. +--- +

@Html.Raw(Model.String(DocsKeys.Description))

+ +@Html.Partial("_ChildPages") \ No newline at end of file diff --git a/docs/examples/write-annotations.md b/docs/examples/write-annotations.md new file mode 100644 index 0000000..719a519 --- /dev/null +++ b/docs/examples/write-annotations.md @@ -0,0 +1,54 @@ +--- +Order: 10 +Title: Create annotations in GitHub Actions +Description: Example how to write issues as annotations to a GitHub Actions build. +--- +This example shows how to report issues as annotations to a GitHub Actions build. + +To report issues as annotations to a GitHub Actions build you need to import the core addin, +the core pull request addin, the GitHub Actions support and one or more issue providers, +in this example for JetBrains InspectCode: + +```csharp +#addin "Cake.Issues" +#addin "Cake.Issues.InspectCode" +#addin "Cake.Issues.PullRequests" +#addin "Cake.Issues.PullRequests.GitHubActions" +``` + +:::{.alert .alert-warning} +Please note that you always should pin addins to a specific version to make sure your builds are deterministic and +won't break due to updates to one of the addins. + +See [pinning addin versions](https://cakebuild.net/docs/tutorials/pinning-cake-version#pinning-addin-version) for details. +::: + +In the following task we'll first determine the remote repository URL and +source branch of the pull request and with this information call the [GitHubActionsBuilds] alias: + +```csharp +Task("ReportIssuesToGitHubActions").Does(() => +{ + var repoRootFolder = MakeAbsolute(Directory("./")); + + ReportIssuesToPullRequest( + InspectCodeIssuesFromFilePath( + @"C:\build\inspectcode.log"), + GitHubActionsBuilds(), + repoRootFolder); +}); +``` + +The output will show up in the build log grouped by issue provider / run: + +![Log output](../githubactions-log-output.png "Log output") + +Additionally the issues show up as annotations: + +![Annotations](../githubactions-annotations.png "Annotations") + +Having issues available as annotations also means that they will be shown in pull requests on the related file / position: + +![Pull request integration](../githubactions-pullrequest-integration.png "Pull request integration") + +[GitHubActionsBuilds]: ../../../../api/Cake.Issues.PullRequests.GitHubActions/GitHubActionsBuildsAliases/ diff --git a/docs/features.md b/docs/features.md new file mode 100644 index 0000000..91dea5e --- /dev/null +++ b/docs/features.md @@ -0,0 +1,25 @@ +--- +Order: 20 +Title: Features +Description: Features of the Cake.Issues.PullRequests.GitHubActions addin. +--- +The [Cake.Issues.PullRequests.GitHubActions addin] creates annotations from issues when running on GitHub actions. + +![Pull request integration](githubactions-pullrequest-integration.png "Pull request integration") + +# Basic features + +* Reports issues as annotations to GitHub Actions builds. +* Group issues in log output by provider and run information. + +# Supported capabilities + +The [Cake.Issues.PullRequests.GitHubActions addin] doesn't support any additional capabilities. + +| | Capability | Remarks | +|--------------------------------------------------------------------|--------------------------------|--------------------------------| +| | Checking commit ID | | +| | Discussion threads | | +| | Filtering by modified files | | + +[Cake.Issues.PullRequests.GitHubActions addin]: https://www.nuget.org/packages/Cake.Issues.PullRequests.GitHubActions diff --git a/docs/githubactions-annotations.png b/docs/githubactions-annotations.png new file mode 100644 index 0000000..d9c8bb6 Binary files /dev/null and b/docs/githubactions-annotations.png differ diff --git a/docs/githubactions-log-output.png b/docs/githubactions-log-output.png new file mode 100644 index 0000000..779bc0b Binary files /dev/null and b/docs/githubactions-log-output.png differ diff --git a/docs/githubactions-pullrequest-integration.png b/docs/githubactions-pullrequest-integration.png new file mode 100644 index 0000000..def6f8c Binary files /dev/null and b/docs/githubactions-pullrequest-integration.png differ diff --git a/docs/index.cshtml b/docs/index.cshtml new file mode 100644 index 0000000..aba3619 --- /dev/null +++ b/docs/index.cshtml @@ -0,0 +1,10 @@ +--- +Title: GitHub Actions +Description: Support for GitHub Actions. +--- +

+ Support for GitHub Actions is implemented in the + Cake.Issues.PullRequests.GitHubActions addin. +

+ +@Html.Partial("_ChildPages") \ No newline at end of file diff --git a/docs/requirements.md b/docs/requirements.md new file mode 100644 index 0000000..e1e6694 --- /dev/null +++ b/docs/requirements.md @@ -0,0 +1,9 @@ +--- +Order: 10 +Title: Requirements +Description: Requirements for the Cake.Issues.PullRequests.GitHubActions addin. +--- +The requirements for using the [Cake.Issues.PullRequests.GitHubActions addin] are listed in the [release notes] for any specific version. + +[Cake.Issues.PullRequests.GitHubActions addin]: https://www.nuget.org/packages/Cake.Issues.PullRequests.GitHubActions +[release notes]: release-notes diff --git a/nuspec/nuget/Cake.Issues.PullRequests.GitHubActions.nuspec b/nuspec/nuget/Cake.Issues.PullRequests.GitHubActions.nuspec new file mode 100644 index 0000000..b507209 --- /dev/null +++ b/nuspec/nuget/Cake.Issues.PullRequests.GitHubActions.nuspec @@ -0,0 +1,33 @@ + + + + Cake.Issues.PullRequests.GitHubActions + Cake.Issues.PullRequests.GitHubActions + 0.0.0 + Pascal Berger + pascalberger, cake-contrib + GitHub Actions support for the Cake.Issues addin for Cake Build Automation System + +GitHub Actions support for the Cake.Issues addin for Cake allows you to report to GitHub Actions builds. + +This addin provides the aliases for writing to GitHub Actions builds. +It also requires the core Cake.Issues and Cake.Issues.PullRequests addins and one or more issue providers. + +See the Project Site for an overview of the whole ecosystem of addins for working with issues in Cake scripts. + + MIT + https://cakeissues.net + icon.png + false + + Copyright © Pascal Berger + Cake Script Cake-Issues Cake-PullRequestSystem Issues PullRequest GitHub GitHub-Actions + https://github.com/cake-contrib/Cake.Issues.PullRequests.GitHubActions/releases/tag/0.9.0 + + + + + + + + \ No newline at end of file diff --git a/nuspec/nuget/icon.png b/nuspec/nuget/icon.png new file mode 100644 index 0000000..9881edc Binary files /dev/null and b/nuspec/nuget/icon.png differ diff --git a/recipe.cake b/recipe.cake new file mode 100644 index 0000000..d6d97fa --- /dev/null +++ b/recipe.cake @@ -0,0 +1,29 @@ +#load nuget:?package=Cake.Recipe&version=1.1.2 + +Environment.SetVariableNames(); + +BuildParameters.SetParameters( + context: Context, + buildSystem: BuildSystem, + sourceDirectoryPath: "./src", + title: "Cake.Issues.PullRequests.GitHubActions", + repositoryOwner: "cake-contrib", + repositoryName: "Cake.Issues.PullRequests.GitHubActions", + appVeyorAccountName: "cakecontrib", + shouldPublishMyGet: false, + shouldGenerateDocumentation: false, + shouldRunCodecov: true, + shouldRunDupFinder: false, + shouldRunInspectCode: false, + shouldRunGitVersion: true); + +BuildParameters.PrintParameters(Context); + +ToolSettings.SetToolSettings( + context: Context, + dupFinderExcludePattern: new string[] { BuildParameters.RootDirectoryPath + "/src/Cake.Issues.PullRequests.GitHubActions.Tests/*.cs" }, + testCoverageFilter: "+[*]* -[xunit.*]* -[Cake.Core]* -[Cake.Testing]* -[*.Tests]* -[Shouldly]* -[Cake.Issues]* -[Cake.Issues.Testing]* -[Cake.Issues.PullRequests]*", + testCoverageExcludeByAttribute: "*.ExcludeFromCodeCoverage*", + testCoverageExcludeByFile: "*/*Designer.cs;*/*.g.cs;*/*.g.i.cs"); + +Build.RunDotNetCore(); diff --git a/src/Cake.Issues.PullRequests.GitHubActions.Tests.ruleset b/src/Cake.Issues.PullRequests.GitHubActions.Tests.ruleset new file mode 100644 index 0000000..70ad3ab --- /dev/null +++ b/src/Cake.Issues.PullRequests.GitHubActions.Tests.ruleset @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/Cake.Issues.PullRequests.GitHubActions.Tests/Cake.Issues.PullRequests.GitHubActions.Tests.csproj b/src/Cake.Issues.PullRequests.GitHubActions.Tests/Cake.Issues.PullRequests.GitHubActions.Tests.csproj new file mode 100644 index 0000000..68fd0d0 --- /dev/null +++ b/src/Cake.Issues.PullRequests.GitHubActions.Tests/Cake.Issues.PullRequests.GitHubActions.Tests.csproj @@ -0,0 +1,31 @@ + + + + netcoreapp2.1 + false + Cake.Issues + Copyright © Pascal Berger and contributors + Tests for the Cake.Issues.PullRequests.GitHubActions addin + Pascal Berger + + + + ..\Cake.Issues.PullRequests.GitHubActions.Tests.ruleset + + + + + + + + + + + + + + + + + + diff --git a/src/Cake.Issues.PullRequests.GitHubActions.Tests/GitHubActionsBuildSettingsTests.cs b/src/Cake.Issues.PullRequests.GitHubActions.Tests/GitHubActionsBuildSettingsTests.cs new file mode 100644 index 0000000..1d5d4ac --- /dev/null +++ b/src/Cake.Issues.PullRequests.GitHubActions.Tests/GitHubActionsBuildSettingsTests.cs @@ -0,0 +1,15 @@ +namespace Cake.Issues.PullRequests.GitHubActions.Tests +{ + using System; + using Cake.Issues.Testing; + using Cake.Testing; + using Shouldly; + using Xunit; + + public sealed class GitHubActionsBuildSettingsTests + { + public sealed class TheCtor + { + } + } +} \ No newline at end of file diff --git a/src/Cake.Issues.PullRequests.GitHubActions.ruleset b/src/Cake.Issues.PullRequests.GitHubActions.ruleset new file mode 100644 index 0000000..ea23c99 --- /dev/null +++ b/src/Cake.Issues.PullRequests.GitHubActions.ruleset @@ -0,0 +1,241 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Cake.Issues.PullRequests.GitHubActions.sln b/src/Cake.Issues.PullRequests.GitHubActions.sln new file mode 100644 index 0000000..2fa0f91 --- /dev/null +++ b/src/Cake.Issues.PullRequests.GitHubActions.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27703.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cake.Issues.PullRequests.GitHubActions", "Cake.Issues.PullRequests.GitHubActions\Cake.Issues.PullRequests.GitHubActions.csproj", "{CC3D0C2D-6AC5-44DC-A0DD-D826D76FC00D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.Issues.PullRequests.GitHubActions.Tests", "Cake.Issues.PullRequests.GitHubActions.Tests\Cake.Issues.PullRequests.GitHubActions.Tests.csproj", "{0C70A4C8-732B-4870-B914-C86FF2D2CB2F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CC3D0C2D-6AC5-44DC-A0DD-D826D76FC00D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CC3D0C2D-6AC5-44DC-A0DD-D826D76FC00D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CC3D0C2D-6AC5-44DC-A0DD-D826D76FC00D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CC3D0C2D-6AC5-44DC-A0DD-D826D76FC00D}.Release|Any CPU.Build.0 = Release|Any CPU + {0C70A4C8-732B-4870-B914-C86FF2D2CB2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0C70A4C8-732B-4870-B914-C86FF2D2CB2F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0C70A4C8-732B-4870-B914-C86FF2D2CB2F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0C70A4C8-732B-4870-B914-C86FF2D2CB2F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BBFD0A4B-FB65-4C3A-88BA-35ECDB3BAF2A} + EndGlobalSection +EndGlobal diff --git a/src/Cake.Issues.PullRequests.GitHubActions.sln.DotSettings b/src/Cake.Issues.PullRequests.GitHubActions.sln.DotSettings new file mode 100644 index 0000000..7cc51a4 --- /dev/null +++ b/src/Cake.Issues.PullRequests.GitHubActions.sln.DotSettings @@ -0,0 +1,3 @@ + + DO_NOT_SHOW + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> \ No newline at end of file diff --git a/src/Cake.Issues.PullRequests.GitHubActions/Cake.Issues.PullRequests.GitHubActions.csproj b/src/Cake.Issues.PullRequests.GitHubActions/Cake.Issues.PullRequests.GitHubActions.csproj new file mode 100644 index 0000000..e8a3423 --- /dev/null +++ b/src/Cake.Issues.PullRequests.GitHubActions/Cake.Issues.PullRequests.GitHubActions.csproj @@ -0,0 +1,32 @@ + + + + netstandard2.0 + Addin for writing code analyzer or linter issues to GitHub Actions + Pascal Berger + Copyright © Pascal Berger and contributors + + + + full + true + ..\Cake.Issues.PullRequests.GitHubActions.ruleset + + + + bin\Debug\netstandard2.0\Cake.Issues.PullRequests.GitHubActions.xml + + + + bin\Release\netstandard2.0\Cake.Issues.PullRequests.GitHubActions.xml + + + + + + + + + + + diff --git a/src/Cake.Issues.PullRequests.GitHubActions/GitHubActionsBuildSettings.cs b/src/Cake.Issues.PullRequests.GitHubActions/GitHubActionsBuildSettings.cs new file mode 100644 index 0000000..beb2aed --- /dev/null +++ b/src/Cake.Issues.PullRequests.GitHubActions/GitHubActionsBuildSettings.cs @@ -0,0 +1,14 @@ +namespace Cake.Issues.PullRequests.GitHubActions +{ + /// + /// Settings for . + /// + public class GitHubActionsBuildSettings + { + /// + /// Gets or sets a value indicating whether issues should be grouped by issue provider and run information. + /// Enabled by default. + /// + public bool GroupIssues { get; set; } = true; + } +} \ No newline at end of file diff --git a/src/Cake.Issues.PullRequests.GitHubActions/GitHubActionsBuildsAliases.cs b/src/Cake.Issues.PullRequests.GitHubActions/GitHubActionsBuildsAliases.cs new file mode 100644 index 0000000..811f1fa --- /dev/null +++ b/src/Cake.Issues.PullRequests.GitHubActions/GitHubActionsBuildsAliases.cs @@ -0,0 +1,76 @@ +namespace Cake.Issues.PullRequests.GitHubActions +{ + using Cake.Core; + using Cake.Core.Annotations; + + /// + /// Contains functionality related to writing code analysis issues to GitHub Actions. + /// + [CakeAliasCategory(IssuesAliasConstants.MainCakeAliasCategory)] + public static class GitHubActionsBuildsAliases + { + /// + /// Gets an object for writing issues to GitHub Actions using the default settings. + /// + /// The context. + /// Object for writing issues to GitHub Actions. + /// + /// Report code analysis issues reported as MsBuild warnings to GitHub Actions: + /// + /// + /// + /// + [CakeMethodAlias] + [CakeAliasCategory(PullRequestsAliasConstants.PullRequestSystemCakeAliasCategory)] + public static IPullRequestSystem GitHubActionsBuilds( + this ICakeContext context) + { + context.NotNull(nameof(context)); + + return new GitHubActionsPullRequestSystem(context, new GitHubActionsBuildSettings()); + } + + /// + /// Gets an object for writing issues to GitHub Actions using the specified settings. + /// + /// The context. + /// Settings for writing issues to GitHub Actions. + /// Object for writing issues to GitHub Actions. + /// + /// Report code analysis issues reported as MsBuild warnings to GitHub Actions: + /// + /// + /// + /// + [CakeMethodAlias] + [CakeAliasCategory(PullRequestsAliasConstants.PullRequestSystemCakeAliasCategory)] + public static IPullRequestSystem GitHubActionsBuilds( + this ICakeContext context, + GitHubActionsBuildSettings settings) + { + context.NotNull(nameof(context)); + settings.NotNull(nameof(settings)); + + return new GitHubActionsPullRequestSystem(context, settings); + } + } +} diff --git a/src/Cake.Issues.PullRequests.GitHubActions/GitHubActionsPullRequestSystem.cs b/src/Cake.Issues.PullRequests.GitHubActions/GitHubActionsPullRequestSystem.cs new file mode 100644 index 0000000..dd0cbaf --- /dev/null +++ b/src/Cake.Issues.PullRequests.GitHubActions/GitHubActionsPullRequestSystem.cs @@ -0,0 +1,123 @@ +namespace Cake.Issues.PullRequests.GitHubActions +{ + using System; + using System.Collections.Generic; + using System.Linq; + using Cake.Core; + using Cake.Core.Diagnostics; + using Cake.Core.IO; + + /// + /// Class for posting issues to GitHub Actions. + /// + public class GitHubActionsPullRequestSystem : BasePullRequestSystem + { + private readonly GitHubActionsBuildSettings settings; + + /// + /// Initializes a new instance of the class. + /// + /// The Cake context. + /// Settings for writing the issues to GitHub Actions. + public GitHubActionsPullRequestSystem(ICakeContext context, GitHubActionsBuildSettings settings) + : base(context?.Log) + { + settings.NotNull(nameof(settings)); + + this.settings = settings; + } + + /// + protected override void InternalPostDiscussionThreads(IEnumerable issues, string commentSource) + { + issues.NotNull(nameof(issues)); + + if (this.settings.GroupIssues) + { + this.WriteGroupedIssues(issues); + } + else + { + this.WriteIssues(issues); + } + } + + /// + /// Formats the options for the warning service message. + /// + /// The root path of the file, relative to the repository root. + /// The file path relative to the project root. + /// The line where the issue ocurred. + /// The column where the issue ocurred. + /// Formatted options string for the warning service message. + private static string FormatWarningOptions(DirectoryPath rootDirectoryPath, FilePath filePath, int? line, int? column) + { + var result = new List(); + + if (filePath != null) + { + result.Add($"file={rootDirectoryPath.CombineWithFilePath(filePath)}"); + } + + if (line.HasValue) + { + result.Add($"line={line.Value}"); + } + + if (column.HasValue) + { + result.Add($"col={column}"); + } + + return string.Join(",", result); + } + + /// + /// Writes services messages to report issues to GitHub Actions grouped by provider and run. + /// + /// Issues which should be reported. + private void WriteGroupedIssues(IEnumerable issues) + { + // Group annotations by provider type and run + var groupedIssues = + from issue in issues + group issue by new { issue.ProviderType, issue.Run }; + + foreach (var group in groupedIssues) + { + var groupName = group.First().ProviderName; + + if (!string.IsNullOrWhiteSpace(group.Key.Run)) + { + groupName += " - " + group.Key.Run; + } + + this.Log.Information($"::group::{groupName}"); + + this.WriteIssues(group); + + this.Log.Information($"::endgroup::{groupName}"); + } + } + + /// + /// Writes services message to report issues to GitHub Actions. + /// + /// Issues which should be reported. + private void WriteIssues(IEnumerable issues) + { + foreach (var issue in issues.OrderByDescending(x => x.Priority)) + { + // Commands don't support line breaks, therefore we only use the first line of the message. + var message = + issue.MessageText + .Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries) + .FirstOrDefault() + ?.Trim(); + + this.Log.Information( + $"::warning {FormatWarningOptions(this.Settings.RepositoryRoot, issue.AffectedFileRelativePath, issue.Line, issue.Column)}::{message}"); + } + } + } +} diff --git a/tests/integration/.config/dotnet-tools.json b/tests/integration/.config/dotnet-tools.json new file mode 100644 index 0000000..38bd0ea --- /dev/null +++ b/tests/integration/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "cake.tool": { + "version": "0.38.4", + "commands": [ + "dotnet-cake" + ] + } + } +} \ No newline at end of file diff --git a/tests/integration/.gitignore b/tests/integration/.gitignore new file mode 100644 index 0000000..e7c4962 --- /dev/null +++ b/tests/integration/.gitignore @@ -0,0 +1,379 @@ + +# Created by https://www.gitignore.io/api/cake,windows,visualstudio,visualstudiocode + +### Cake ### +tools/* +!tools/packages.config + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +### VisualStudio ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + + +# End of https://www.gitignore.io/api/cake,windows,visualstudio,visualstudiocode + + +# Project specific folders +BuildArtifacts diff --git a/tests/integration/build.cake b/tests/integration/build.cake new file mode 100644 index 0000000..d4fd926 --- /dev/null +++ b/tests/integration/build.cake @@ -0,0 +1,101 @@ +#load "buildData.cake" + +#addin "Cake.Markdownlint" +#addin "Cake.Issues&prerelease" +#addin "Cake.Issues.MsBuild&prerelease" +#addin "Cake.Issues.PullRequests&prerelease" +#addin "Cake.Issues.PullRequests.GitHubActions&prerelease" + +////////////////////////////////////////////////// +// ARGUMENTS +////////////////////////////////////////////////// + +var target = Argument("target", "Default"); + +////////////////////////////////////////////////// +// SETUP / TEARDOWN +////////////////////////////////////////////////// + +Setup(setupContext => +{ + return new BuildData(); +}); + +var repoRootFolder = MakeAbsolute(Directory("./")); +var logPath = repoRootFolder.Combine("BuildArtifacts").Combine("logs"); + +////////////////////////////////////////////////// +// TARGETS +////////////////////////////////////////////////// + +Task("Build") + .Does((data) => +{ + var msBuildLogPath = logPath.CombineWithFilePath("msbuild.binlog"); + var solutionFile = + repoRootFolder + .Combine("src") + .CombineWithFilePath("ClassLibrary1.sln"); + +#if NETCOREAPP + DotNetCoreRestore(solutionFile.FullPath); + + var settings = + new DotNetCoreMSBuildSettings() + .WithTarget("Rebuild") + .WithLogger( + "BinaryLogger," + Context.Tools.Resolve("Cake.Issues.MsBuild*/**/StructuredLogger.dll"), + "", + msBuildLogPath.FullPath + ); + + DotNetCoreBuild( + solutionFile.FullPath, + new DotNetCoreBuildSettings + { + MSBuildSettings = settings + }); +#else + NuGetRestore(solutionFile); + + var settings = + new MSBuildSettings() + .WithTarget("Rebuild") + .WithLogger( + Context.Tools.Resolve("Cake.Issues.MsBuild*/**/StructuredLogger.dll").FullPath, + "BinaryLogger", + msBuildLogPath.FullPath); + MSBuild(solutionFile, settings); +#endif + + data.AddIssues( + ReadIssues( + MsBuildIssuesFromFilePath( + msBuildLogPath, + MsBuildBinaryLogFileFormat), + repoRootFolder) + ); +}); + +Task("Report-IssuesToBuildServer") + .Does((data) => +{ + ReportIssuesToPullRequest( + data.Issues, + GitHubActionsBuilds(), + repoRootFolder); +}); + +Task("Lint") + .IsDependentOn("Build"); + +// Run issues task by default. +Task("Default") + .IsDependentOn("Lint") + .IsDependentOn("Report-IssuesToBuildServer"); + +////////////////////////////////////////////////// +// EXECUTION +////////////////////////////////////////////////// + +RunTarget(target); \ No newline at end of file diff --git a/tests/integration/build.ps1 b/tests/integration/build.ps1 new file mode 100644 index 0000000..05b31be --- /dev/null +++ b/tests/integration/build.ps1 @@ -0,0 +1,234 @@ +########################################################################## +# This is the Cake bootstrapper script for PowerShell. +# This file was downloaded from https://github.com/cake-build/resources +# Feel free to change this file to fit your needs. +########################################################################## + +<# + +.SYNOPSIS +This is a Powershell script to bootstrap a Cake build. + +.DESCRIPTION +This Powershell script will download NuGet if missing, restore 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 Experimental +Uses the nightly builds of the Roslyn script engine. +.PARAMETER Mono +Uses the Mono Compiler rather than the Roslyn script engine. +.PARAMETER SkipToolPackageRestore +Skips restoring of packages. +.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, + [switch]$Experimental, + [switch]$Mono, + [switch]$SkipToolPackageRestore, + [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] + [string[]]$ScriptArgs +) + +[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null +function MD5HashFile([string] $filePath) +{ + if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf)) + { + return $null + } + + [System.IO.Stream] $file = $null; + [System.Security.Cryptography.MD5] $md5 = $null; + try + { + $md5 = [System.Security.Cryptography.MD5]::Create() + $file = [System.IO.File]::OpenRead($filePath) + return [System.BitConverter]::ToString($md5.ComputeHash($file)) + } + finally + { + if ($file -ne $null) + { + $file.Dispose() + } + } +} + +function GetProxyEnabledWebClient +{ + $wc = New-Object System.Net.WebClient + $proxy = [System.Net.WebRequest]::GetSystemWebProxy() + $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials + $wc.Proxy = $proxy + return $wc +} + +Write-Host "Preparing to run build script..." + +if(!$PSScriptRoot){ + $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent +} + +$TOOLS_DIR = Join-Path $PSScriptRoot "tools" +$ADDINS_DIR = Join-Path $TOOLS_DIR "Addins" +$MODULES_DIR = Join-Path $TOOLS_DIR "Modules" +$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe" +$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe" +$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" +$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config" +$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum" +$ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR "packages.config" +$MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config" + +# Make sure tools folder exists +if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) { + Write-Verbose -Message "Creating tools directory..." + New-Item -Path $TOOLS_DIR -Type directory | out-null +} + +# Make sure that packages.config exist. +if (!(Test-Path $PACKAGES_CONFIG)) { + Write-Verbose -Message "Downloading packages.config..." + try { + $wc = GetProxyEnabledWebClient + $wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch { + Throw "Could not download packages.config." + } +} + +# Try find NuGet.exe in path if not exists +if (!(Test-Path $NUGET_EXE)) { + Write-Verbose -Message "Trying to find nuget.exe in PATH..." + $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) } + $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1 + if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) { + Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)." + $NUGET_EXE = $NUGET_EXE_IN_PATH.FullName + } +} + +# Try download NuGet.exe if not exists +if (!(Test-Path $NUGET_EXE)) { + Write-Verbose -Message "Downloading NuGet.exe..." + try { + $wc = GetProxyEnabledWebClient + $wc.DownloadFile($NUGET_URL, $NUGET_EXE) + } catch { + Throw "Could not download NuGet.exe." + } +} + +# Save nuget.exe path to environment to be available to child processed +$ENV:NUGET_EXE = $NUGET_EXE + +# Restore tools from NuGet? +if(-Not $SkipToolPackageRestore.IsPresent) { + Push-Location + Set-Location $TOOLS_DIR + + # Check for changes in packages.config and remove installed tools if true. + [string] $md5Hash = MD5HashFile($PACKAGES_CONFIG) + if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or + ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { + Write-Verbose -Message "Missing or changed package.config hash..." + Remove-Item * -Recurse -Exclude packages.config,nuget.exe + } + + Write-Verbose -Message "Restoring tools from NuGet..." + $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`"" + + if ($LASTEXITCODE -ne 0) { + Throw "An error occurred while restoring NuGet tools." + } + else + { + $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII" + } + Write-Verbose -Message ($NuGetOutput | out-string) + + Pop-Location +} + +# Restore addins from NuGet +if (Test-Path $ADDINS_PACKAGES_CONFIG) { + Push-Location + Set-Location $ADDINS_DIR + + Write-Verbose -Message "Restoring addins from NuGet..." + $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`"" + + if ($LASTEXITCODE -ne 0) { + Throw "An error occurred while restoring NuGet addins." + } + + Write-Verbose -Message ($NuGetOutput | out-string) + + Pop-Location +} + +# Restore modules from NuGet +if (Test-Path $MODULES_PACKAGES_CONFIG) { + Push-Location + Set-Location $MODULES_DIR + + Write-Verbose -Message "Restoring modules from NuGet..." + $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`"" + + if ($LASTEXITCODE -ne 0) { + Throw "An error occurred while restoring NuGet modules." + } + + Write-Verbose -Message ($NuGetOutput | out-string) + + Pop-Location +} + +# Make sure that Cake has been installed. +if (!(Test-Path $CAKE_EXE)) { + Throw "Could not find Cake.exe at $CAKE_EXE" +} + + + +# 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" } +if ($Mono) { $cakeArguments += "-mono" } +$cakeArguments += $ScriptArgs + +# Start Cake +Write-Host "Running build script..." +&$CAKE_EXE $cakeArguments +exit $LASTEXITCODE diff --git a/tests/integration/build.sh b/tests/integration/build.sh new file mode 100644 index 0000000..51f8617 --- /dev/null +++ b/tests/integration/build.sh @@ -0,0 +1,103 @@ +#!/usr/bin/env bash +########################################################################## +# This is the Cake bootstrapper script for Linux and OS X. +# This file was downloaded from https://github.com/cake-build/resources +# Feel free to change this file to fit your needs. +########################################################################## + +# Define directories. +SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +TOOLS_DIR=$SCRIPT_DIR/tools +NUGET_EXE=$TOOLS_DIR/nuget.exe +NUGET_URL=https://dist.nuget.org/win-x86-commandline/latest/nuget.exe +CAKE_VERSION=0.38.0 +CAKE_EXE=$TOOLS_DIR/Cake.$CAKE_VERSION/Cake.exe + +# Temporarily skip verification of addins. +export CAKE_SETTINGS_SKIPVERIFICATION='true' + +# Define default arguments. +SCRIPT="build.cake" +TARGET="Default" +CONFIGURATION="Release" +VERBOSITY="verbose" +DRYRUN= +SCRIPT_ARGUMENTS=() + +# Parse arguments. +for i in "$@"; do + case $1 in + -t|--target) TARGET="$2"; shift ;; + -c|--configuration) CONFIGURATION="$2"; shift ;; + -v|--verbosity) VERBOSITY="$2"; shift ;; + -d|--dryrun) DRYRUN="-dryrun" ;; + --) shift; SCRIPT_ARGUMENTS+=("$@"); break ;; + *) SCRIPT_ARGUMENTS+=("$1") ;; + esac + shift +done + +# Make sure the tools folder exist. +if [ ! -d "$TOOLS_DIR" ]; then + mkdir "$TOOLS_DIR" +fi + +# Print Mono version. +echo "Mono version:" +mono --version +echo "" + +########################################################################### +# INSTALL .NET CORE CLI +########################################################################### + +echo "Installing .NET CLI..." +if [ ! -d "$SCRIPT_DIR/.dotnet" ]; then + mkdir "$SCRIPT_DIR/.dotnet" +fi +curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" https://dot.net/v1/dotnet-install.sh +sudo bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version 2.1.400 --install-dir .dotnet --no-path +export PATH="$SCRIPT_DIR/.dotnet":$PATH +export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +export DOTNET_CLI_TELEMETRY_OPTOUT=1 +export DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0 +"$SCRIPT_DIR/.dotnet/dotnet" --info + +########################################################################### +# INSTALL NUGET +########################################################################### + +# Download NuGet if it does not exist. +if [ ! -f "$NUGET_EXE" ]; then + echo "Downloading NuGet..." + curl -Lsfo "$NUGET_EXE" $NUGET_URL + if [ $? -ne 0 ]; then + echo "An error occurred while downloading nuget.exe." + exit 1 + fi +fi + +########################################################################### +# INSTALL CAKE +########################################################################### + +if [ ! -f "$CAKE_EXE" ]; then + mono "$NUGET_EXE" install Cake -Version $CAKE_VERSION -OutputDirectory "$TOOLS_DIR" + if [ $? -ne 0 ]; then + echo "An error occurred while installing Cake." + exit 1 + fi +fi + +# Make sure that Cake has been installed. +if [ ! -f "$CAKE_EXE" ]; then + echo "Could not find Cake.exe at '$CAKE_EXE'." + exit 1 +fi + +########################################################################### +# RUN BUILD SCRIPT +########################################################################### + +# Start Cake +exec mono "$CAKE_EXE" $SCRIPT --verbosity=$VERBOSITY --configuration=$CONFIGURATION --target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}" diff --git a/tests/integration/buildData.cake b/tests/integration/buildData.cake new file mode 100644 index 0000000..8a22d41 --- /dev/null +++ b/tests/integration/buildData.cake @@ -0,0 +1,29 @@ +public class BuildData +{ + private readonly List issues = new List(); + + /// + /// Gets issues determined during building. + /// + public IEnumerable Issues + { + get + { + return issues.AsReadOnly(); + } + } + + /// + /// Add issues to . + /// + /// List of issues which should be added. + public void AddIssues(IEnumerable issues) + { + if (issues == null) + { + throw new NullReferenceException(nameof(issues)); + } + + this.issues.AddRange(issues); + } +} \ No newline at end of file diff --git a/tests/integration/nuget.config b/tests/integration/nuget.config new file mode 100644 index 0000000..a202f0a --- /dev/null +++ b/tests/integration/nuget.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/tests/integration/src/ClassLibrary1.sln b/tests/integration/src/ClassLibrary1.sln new file mode 100644 index 0000000..62df92e --- /dev/null +++ b/tests/integration/src/ClassLibrary1.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.csproj", "{9B73BB5B-06A3-46F3-9068-E3607A8217B0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9B73BB5B-06A3-46F3-9068-E3607A8217B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9B73BB5B-06A3-46F3-9068-E3607A8217B0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9B73BB5B-06A3-46F3-9068-E3607A8217B0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9B73BB5B-06A3-46F3-9068-E3607A8217B0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/tests/integration/src/ClassLibrary1/Class1.cs b/tests/integration/src/ClassLibrary1/Class1.cs new file mode 100644 index 0000000..4ea0004 --- /dev/null +++ b/tests/integration/src/ClassLibrary1/Class1.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ClassLibrary1 +{ + public class Class1 + { + public void Foo() + { + var foo = "foo"; + var bar = "bar"; + if (!string.IsNullOrEmpty(foo) && !string.IsNullOrEmpty(bar)) + { + var foobar = foo + bar; + } + } + + public void Bar() + { + var foo = "foo"; + var bar = "bar"; + if (!string.IsNullOrEmpty(foo) && !string.IsNullOrEmpty(bar)) + { + var foobar = foo + bar; + } + } + } +} diff --git a/tests/integration/src/ClassLibrary1/ClassLibrary1.csproj b/tests/integration/src/ClassLibrary1/ClassLibrary1.csproj new file mode 100644 index 0000000..9ec4dd9 --- /dev/null +++ b/tests/integration/src/ClassLibrary1/ClassLibrary1.csproj @@ -0,0 +1,21 @@ + + + + netstandard2.0 + + + + + all + 3.0.0 + + + all + 1.1.118 + + + + + + + \ No newline at end of file diff --git a/tests/integration/tools/packages.config b/tests/integration/tools/packages.config new file mode 100644 index 0000000..a36acb6 --- /dev/null +++ b/tests/integration/tools/packages.config @@ -0,0 +1,4 @@ + + + + diff --git a/tools/packages.config b/tools/packages.config new file mode 100644 index 0000000..e7f7fdd --- /dev/null +++ b/tools/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file