diff --git a/.gitignore b/.gitignore index e5cf2d2ec..f5e9ffd76 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ TODO.md launch.json **.DS_Store **insync** -vaporshell-snippets** \ No newline at end of file +vaporshell-snippets** +TestResults**.xml \ No newline at end of file diff --git a/ci/init.ps1 b/ci/init.ps1 index 2cccf5ad9..7fea527dc 100644 --- a/ci/init.ps1 +++ b/ci/init.ps1 @@ -34,13 +34,17 @@ else { # Grab nuget bits, install modules, set build variables, start build. Get-PackageProvider -Name NuGet -ForceBootstrap | Out-Null - Install-Module Psake, PSDeploy, Pester, BuildHelpers, Coveralls -Force -Scope CurrentUser + Install-Module Psake, PSDeploy, Pester, BuildHelpers, Coveralls -Force -Scope CurrentUser -AllowClobber Import-Module Psake, BuildHelpers, Coveralls + Set-Location .. + Set-BuildEnvironment - Set-Location $PSScriptRoot + #Set-Location $PSScriptRoot - Invoke-psake .\psake.ps1 -taskList $Task -nologo + Invoke-psake .\ci\psake.ps1 -taskList $Task -nologo exit ( [int]( -not $psake.build_success ) ) -} \ No newline at end of file +} + +#Get-Item Env:BH* | Remove-Item \ No newline at end of file diff --git a/ci/psake.ps1 b/ci/psake.ps1 index 53cf13f1b..cfd78fe95 100644 --- a/ci/psake.ps1 +++ b/ci/psake.ps1 @@ -39,7 +39,7 @@ Task Test -Depends Init { "`n`tSTATUS: Testing with PowerShell $PSVersion" # Gather test results. Store them in a variable and file - $TestResults = Invoke-Pester -Path $ProjectRoot\Tests -PassThru -OutputFormat NUnitXml -OutputFile "$ProjectRoot\$TestFile" -CodeCoverage "$ProjectRoot\Vaporshell\Public\Condition Functions\*","$ProjectRoot\Vaporshell\Public\Intrinsic Functions\*","$ProjectRoot\Vaporshell\Public\Primary Functions\*","$ProjectRoot\Vaporshell\Public\Transform\*","$ProjectRoot\Vaporshell\Public\*-Vaporshell.ps1","$ProjectRoot\Vaporshell\Vaporshell.psm1" + $TestResults = Invoke-Pester -Path $ProjectRoot\Tests -PassThru -OutputFormat NUnitXml -OutputFile "$ProjectRoot\$TestFile" # -CodeCoverage "$ProjectRoot\Vaporshell\Public\Condition Functions\*","$ProjectRoot\Vaporshell\Public\Intrinsic Functions\*","$ProjectRoot\Vaporshell\Public\Primary Functions\*","$ProjectRoot\Vaporshell\Public\Transform\*","$ProjectRoot\Vaporshell\Public\*-Vaporshell.ps1","$ProjectRoot\Vaporshell\Vaporshell.psm1" # In Appveyor? Upload our tests! #Abstract this into a function? If($ENV:BHBuildSystem -eq 'AppVeyor') @@ -47,7 +47,10 @@ Task Test -Depends Init { (New-Object 'System.Net.WebClient').UploadFile( "https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", "$ProjectRoot\$TestFile" ) - $coverage = Format-Coverage -PesterResults $TestResults -CoverallsApiToken $ENV:Coveralls -BranchName $ENV:APPVEYOR_REPO_BRANCH -RootFolder $ProjectRoot + + $files = Get-ChildItem "$ProjectRoot\Vaporshell" -Include *.ps1,*.psm1 -Recurse | Where-Object {$_.Name -notlike "Add-VS*" -and $_.Name -notlike "New-VS*" -and $_.FullName -notlike "*\Private\*" -and $_.Name -ne "Update-VSResourceFunctions.ps1"} + $coverage = Format-Coverage -Include $files -CoverallsApiToken $ENV:Coveralls -BranchName $ENV:APPVEYOR_REPO_BRANCH -RootFolder ..\ + #$coverage = Format-Coverage -PesterResults $TestResults -CoverallsApiToken $ENV:Coveralls -BranchName $ENV:APPVEYOR_REPO_BRANCH -RootFolder ..\ Publish-Coverage -Coverage $coverage } @@ -65,14 +68,20 @@ Task Test -Depends Init { Task Build -Depends Test { $lines - # Load the module, read the exported functions, update the psd1 FunctionsToExport - Set-ModuleFunctions @Verbose + if ($env:APPVEYOR) { + # Load the module, read the exported functions, update the psd1 FunctionsToExport + Set-ModuleFunctions @Verbose + + # Bump the module version + #S$Version = Get-NextPSGalleryVersion -Name $env:BHProjectName + Update-Metadata -Path $env:BHPSModuleManifest -PropertyName ModuleVersion -Value "1.1.6" #$Version + + #Update-Metadata -Path $env:BHPSModuleManifest -Increment Minor + } + else { + Write-Host -ForegroundColor Magenta "Build system is not AppVeyor -- skipping module update!" + } - # Bump the module version - #S$Version = Get-NextPSGalleryVersion -Name $env:BHProjectName - Update-Metadata -Path $env:BHPSModuleManifest -PropertyName ModuleVersion -Value "1.1.6" #$Version - - #Update-Metadata -Path $env:BHPSModuleManifest -Increment Minor } Task Deploy -Depends Build { diff --git a/deploy.psdeploy.ps1 b/deploy.psdeploy.ps1 index bfef66a74..e5561cc23 100644 --- a/deploy.psdeploy.ps1 +++ b/deploy.psdeploy.ps1 @@ -14,9 +14,18 @@ # Set-BuildEnvironment from BuildHelpers module has populated ENV:BHProjectName # Publish to gallery with a few restrictions +if ($env:TRAVIS) { + $buildSystem = "Travis CI" +} +elseif ($env:APPVEYOR) { + $buildSystem = "AppVeyor" +} +else { + $buildSystem = "Unknown" +} if( $env:BHProjectName -and $env:BHProjectName.Count -eq 1 -and - $env:BHBuildSystem -ne 'Unknown' -and + $buildSystem -eq 'AppVeyor' -and $env:BHBranchName -eq "master" -and $env:BHCommitMessage -match '!deploy' ) @@ -34,7 +43,7 @@ if( else { "Skipping deployment: To deploy, ensure that...`n" + - "`t* You are in a known build system (Current: $ENV:BHBuildSystem)`n" + + "`t* You are building in AppVeyor (Current: $buildSystem)`n" + "`t* You are committing to the master branch (Current: $ENV:BHBranchName) `n" + "`t* Your commit message includes !deploy (Current: $ENV:BHCommitMessage)" | Write-Host