Skip to content

Commit

Permalink
(#159 #160) Initial Pass at running inspection tools
Browse files Browse the repository at this point in the history
- Updated appveyor to include new artifacts
- Added config files for dupfinder and inspectcode to BuildScripts folder
- Added Tasks for:
  - Installing Chocolatey if required
  - Installing resharper clt if required
  - Running dupfinder, using config file
  - Running inspectcode, using config file
  • Loading branch information
Gary Ewan Park committed Sep 25, 2014
1 parent c11900c commit 4487ec6
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 5 deletions.
92 changes: 90 additions & 2 deletions BuildScripts/default.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ function get-buildArtifactsDirectory {
return "." | Resolve-Path | Join-Path -ChildPath "../BuildArtifacts";
}

function get-buildScriptsDirectory {
return "." | Resolve-Path;
}

function get-sourceDirectory {
return "." | Resolve-Path | Join-Path -ChildPath "../Source";
}
Expand Down Expand Up @@ -49,6 +53,19 @@ function isAppVeyor() {
Test-Path -Path env:\APPVEYOR
}

function isChocolateyInstalled() {
$script:chocolateyDir = $null
if ($env:ChocolateyInstall -ne $null) {
$script:chocolateyDir = $env:ChocolateyInstall;
} elseif (Test-Path (Join-Path $env:SYSTEMDRIVE Chocolatey)) {
$script:chocolateyDir = Join-Path $env:SYSTEMDRIVE Chocolatey;
} elseif (Test-Path (Join-Path ([Environment]::GetFolderPath("CommonApplicationData")) Chocolatey)) {
$script:chocolateyDir = Join-Path ([Environment]::GetFolderPath("CommonApplicationData")) Chocolatey;
}

Test-Path -Path $script:chocolateyDir;
}

Task -Name Default -Depends BuildSolution

# private tasks
Expand All @@ -65,18 +82,63 @@ Task -Name __RemoveBuildArtifactsDirectory -Description $private -Action {
get-buildArtifactsDirectory | remove-packageDirectory;
}

Task -Name __InstallChocolatey -Description $private -Action {
if(isChocolateyInstalled) {
Write-Host "Chocolatey already installed";
}
else {
Write-Host "Chocolatey is not installed, installing Chocolatey...";
Invoke-Expression ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'));

$script:chocolateyDir = Join-Path ([Environment]::GetFolderPath("CommonApplicationData")) Chocolatey
if (-not (Test-Path $script:chocolateyDir)) {
throw "Error installing Chocolatey"
}
}
}

Task -Name __InstallReSharperCommandLineTools -Depends __InstallChocolatey -Description $private -Action {
$chocolateyBinDir = Join-Path $script:chocolateyDir -ChildPath "bin";
$inspectCodeExe = Join-Path $chocolateyBinDir -ChildPath "inspectcode.exe";

$choco = Join-Path (Join-Path $script:chocolateyDir "chocolateyInstall") -ChildPath "chocolatey.cmd";
Write-Output "Where is Choco: $choco";

if (-not (Test-Path $inspectCodeExe)) {
Invoke-Expression "$choco install resharper-clt";
if ($LASTEXITCODE -ne 0) {
throw "Error installing resharper-clt";
}
} else {
Write-Host "resharper-clt already installed";
}
}

Task -Name __InstallPSBuild -Description $private -Action {
# Need a test here to see if this is actually required
(new-object Net.WebClient).DownloadString("https://raw.github.com/ligershark/psbuild/master/src/GetPSBuild.ps1") | Invoke-Expression;
}

Task -Name __UpdateReSharperCommandLineTools -Description $private -Action {
$choco = Join-Path (Join-Path $script:chocolateyDir "chocolateyInstall") -ChildPath "chocolatey.cmd";

Invoke-Expression "$choco update resharper-clt";

if ($LASTEXITCODE -ne 0) {
throw "Error updating resharper-clt";
}
}

# primary targets

Task -Name PackageSolution -Depends RebuildSolution, PackageChocolatey -Description "Complete build, including creation of Chocolatey Package."

Task -Name DeploySolutionToMyGet -Depends PackageSolution, DeployPacakgeToMyGet -Description "Complete build, including creation of Chocolatey Package and Deployment to MyGet.org"

Task -Name DeploySolutionToChocolatey -Depends PackageSolution, DeployPackageToChocolatey -Description "Complete build, including creation of Chocolatey Package and Deployment to Chocolatey.org."
Task -Name InspectCodeForProblems -Depends RunDupFinder, RunInspectCode -Description "Complete build, including running dupfinder, and inspectcode."

Task -Name DeploySolutionToMyGet -Depends InspectCodeForProblems, DeployPacakgeToMyGet -Description "Complete build, including creation of Chocolatey Package and Deployment to MyGet.org"

Task -Name DeploySolutionToChocolatey -Depends InspectCodeForProblems, DeployPackageToChocolatey -Description "Complete build, including creation of Chocolatey Package and Deployment to Chocolatey.org."

# build tasks

Expand Down Expand Up @@ -108,6 +170,32 @@ Task -Name RunGitVersion -Description "Execute the GitVersion Command Line Tool,
}
}

Task -Name RunInspectCode -Depends __InstallReSharperCommandLineTools -Description "Execute the InspectCode Command Line Tool" -Action {
$chocolateyBinDir = Join-Path $script:chocolateyDir -ChildPath "bin";
$inspectCodeExe = Join-Path $chocolateyBinDir -ChildPath "inspectcode.exe";
$buildScriptsDirectory = get-buildScriptsDirectory;
$inspectCodeConfigFile = Join-Path $buildScriptsDirectory -ChildPath "inspectcode.config";

Invoke-Expression "$inspectCodeExe /config=$inspectCodeConfigFile";

if ($LASTEXITCODE -ne 0) {
throw "Error running InspectCode";
}
}

Task -Name RunDupFinder -Depends __InstallReSharperCommandLineTools -Description "Execute the DupFinder Command Line Tool" -Action {
$chocolateyBinDir = Join-Path $script:chocolateyDir -ChildPath "bin";
$dupFinderExe = Join-Path $chocolateyBinDir -ChildPath "dupfinder.exe";
$buildScriptsDirectory = get-buildScriptsDirectory;
$dupFinderConfigFile = Join-Path $buildScriptsDirectory -ChildPath "dupfinder.config";

Invoke-Expression "$dupFinderExe /config=$dupFinderConfigFile";

if ($LASTEXITCODE -ne 0) {
throw "Error running DupFinder";
}
}

Task -Name OutputNugetVersion -Description "So that we are clear which version of NuGet is being used, call NuGet" -Action {
try {
Write-Output "Running NuGet..."
Expand Down
8 changes: 8 additions & 0 deletions BuildScripts/dupfinder.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<DupFinderOptions>
<ExcludeFiles></ExcludeFiles>
<InputFiles>
<Pattern>C:\projects\ChocolateyGUI\Source\**\*.cs</Pattern>
</InputFiles>
<OutputFile>C:\projects\ChocolateyGUI\BuildArtifacts\dupfinder.xml</OutputFile>
</DupFinderOptions>
6 changes: 6 additions & 0 deletions BuildScripts/inspectcode.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<InspectCodeOptions>
<SolutionFile>C:\projects\ChocolateyGUI\Source\ChocolateyGui.sln</SolutionFile>
<CustomSettingsProfile></CustomSettingsProfile>
<OutputFile>C:\projects\ChocolateyGUI\BuildArtifacts\inspectcode.xml</OutputFile>
</InspectCodeOptions>
8 changes: 7 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ environment:
#---------------------------------#

build_script:
- cmd: build.bat PackageSolution
- cmd: build.bat

test: off

Expand All @@ -44,6 +44,12 @@ artifacts:
- path: BuildArtifacts\StyleCopReport.xml
name: StyleCop Report

- path: BuildArtifacts\inspectcode.xml
name: Inspect Code Report

- path: BuildArtifacts\dupfinder.xml
name: DupFinder Report

#---------------------------------#
# caching configuration #
#---------------------------------#
Expand Down
4 changes: 2 additions & 2 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ IF "%APPVEYOR%"=="" (

IF "%APPVEYOR_REPO_BRANCH%"=="develop" IF "%APPVEYOR_PULL_REQUEST_NUMBER%" NEQ "" (
ECHO Since we are on develop branch with a pull request number, we are just going to package the solution, with no deployment
powershell -NoProfile -ExecutionPolicy bypass -Command "%~dp0BuildScripts\build.ps1 PackageSolution Release"
powershell -NoProfile -ExecutionPolicy bypass -Command "%~dp0BuildScripts\build.ps1 InspectCodeForProblems Release"
GOTO :eof
)

Expand All @@ -60,7 +60,7 @@ IF "%APPVEYOR%"=="" (

IF "%APPVEYOR_REPO_BRANCH%"=="master" IF "%APPVEYOR_PULL_REQUEST_NUMBER%" NEQ "" (
ECHO Since we are on develop branch with a pull request number, we are just going to package the solution, with no deployment
powershell -NoProfile -ExecutionPolicy bypass -Command "%~dp0BuildScripts\build.ps1 PackageSolution Release"
powershell -NoProfile -ExecutionPolicy bypass -Command "%~dp0BuildScripts\build.ps1 InspectCodeForProblems Release"
GOTO :eof
)
)
Expand Down

0 comments on commit 4487ec6

Please sign in to comment.