Skip to content

Commit

Permalink
Test CI
Browse files Browse the repository at this point in the history
  • Loading branch information
niheaven committed Mar 19, 2019
1 parent 079c4a5 commit df1d165
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ image:
- Visual Studio 2017

environment:
SCOOP: C:\projects\scoop
matrix:
- PowerShell: 5
- PowerShell: 6
Expand Down
19 changes: 17 additions & 2 deletions test/Scoop-Decompress.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
. "$psscriptroot\Scoop-TestLib.ps1"
. "$psscriptroot\..\lib\core.ps1"
. "$psscriptroot\..\lib\decompress.ps1"
. "$psscriptroot\..\lib\unix.ps1"
. "$psscriptroot\..\lib\install.ps1"
. "$psscriptroot\..\lib\manifest.ps1"
. "$psscriptroot\..\lib\config.ps1"

$isUnix = is_unix

describe "extract_zip" -Tag 'Scoop' {
function install_app_ci($app, $architecture) {
$manifest = manifest $app
$version = $manifest.version
$dir = ensure (versiondir $app $version)
$fname = dl_urls $app $version $manifest $null $architecture $dir
$dir = link_current $dir
success "'$app' ($version) was installed successfully!"
}

install_app_ci 7zip 64bit
install_app_ci lessmsi
install_app_ci innounp

describe "extract_zip" -Tag 'Scoop', 'Decompress' {
beforeall {
$working_dir = setup_working "decompress"
}
Expand Down
28 changes: 17 additions & 11 deletions test/bin/test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,46 @@ $resultsXml = "$PSScriptRoot/TestResults.xml"
$excludes = @()

$splat = @{
Path = $TestPath
OutputFile = $resultsXml
Path = $TestPath
OutputFile = $resultsXml
OutputFormat = 'NUnitXML'
PassThru = $true
PassThru = $true
}

if($env:CI -eq $true) {
$commit = if($env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT) { $env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT } else { $env:APPVEYOR_REPO_COMMIT }
if ($env:CI -eq $true) {
$commit = if ($env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT) { $env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT } else { $env:APPVEYOR_REPO_COMMIT }
$commitMessage = "$env:APPVEYOR_REPO_COMMIT_MESSAGE $env:APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED".TrimEnd()

if($commitMessage -match '!linter') {
if ($commitMessage -match '!linter') {
Write-Warning "Skipping code linting per commit flag '!linter'"
$excludes += 'Linter'
}

$changed_scripts = (Get-GitChangedFile -Include '*.ps1' -Commit $commit)
if(!$changed_scripts) {
if (!$changed_scripts) {
Write-Warning "Skipping tests and code linting for *.ps1 files because they didn't change"
$excludes += 'Linter'
$excludes += 'Scoop'
}

if($commitMessage -match '!manifests') {
$changed_scripts = (Get-GitChangedFile -Include 'decompress.ps1' -Commit $commit)
if (!$changed_scripts) {
Write-Warning "Skipping tests and code linting for decompress.ps1 files because it didn't change"
$excludes += 'Decompress'
}

if ($commitMessage -match '!manifests') {
Write-Warning "Skipping manifest validation per commit flag '!manifests'"
$excludes += 'Manifests'
}

$changed_manifests = (Get-GitChangedFile -Include '*.json' -Commit $commit)
if(!$changed_manifests) {
if (!$changed_manifests) {
Write-Warning "Skipping tests and validation for manifest files because they didn't change"
$excludes += 'Manifests'
}

if($excludes.Length -gt 0) {
if ($excludes.Length -gt 0) {
$splat.ExcludeTag = $excludes
}
}
Expand All @@ -53,6 +59,6 @@ $result = Invoke-Pester @splat

(New-Object Net.WebClient).UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", $resultsXml)

if($result.FailedCount -gt 0) {
if ($result.FailedCount -gt 0) {
exit $result.FailedCount
}

0 comments on commit df1d165

Please sign in to comment.