Skip to content
This repository has been archived by the owner on Oct 21, 2023. It is now read-only.

Commit

Permalink
updates to code coverage tests
Browse files Browse the repository at this point in the history
  • Loading branch information
scrthq committed Jul 9, 2017
1 parent 8deb27c commit 3bc8f2a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -3,4 +3,5 @@ TODO.md
launch.json
**.DS_Store
**insync**
vaporshell-snippets**
vaporshell-snippets**
TestResults**.xml
12 changes: 8 additions & 4 deletions ci/init.ps1
Expand Up @@ -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 ) )
}
}

#Get-Item Env:BH* | Remove-Item
27 changes: 18 additions & 9 deletions ci/psake.ps1
Expand Up @@ -39,15 +39,18 @@ 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')
{
(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
}

Expand All @@ -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 {
Expand Down
13 changes: 11 additions & 2 deletions deploy.psdeploy.ps1
Expand Up @@ -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'
)
Expand All @@ -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
Expand Down

0 comments on commit 3bc8f2a

Please sign in to comment.