mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
added ImportOnly test and added additional macOS stage on azure-pipelines.yml
This commit is contained in:
25
CI/CI.ps1
25
CI/CI.ps1
@@ -13,7 +13,10 @@ param
|
|||||||
# AppVeyor and Azure - Upload module as AppVeyor Artifact.
|
# AppVeyor and Azure - Upload module as AppVeyor Artifact.
|
||||||
[Switch]$Artifact,
|
[Switch]$Artifact,
|
||||||
# Azure - Runs PsScriptAnalyzer against one or more folders and pivots the results to form a report.
|
# Azure - Runs PsScriptAnalyzer against one or more folders and pivots the results to form a report.
|
||||||
[Switch]$Analyzer
|
[Switch]$Analyzer,
|
||||||
|
# Installs the module and invokes only the ModuleImport test.
|
||||||
|
# Used for validating that the module imports still when external dependencies are missing, e.g. mono-libgdiplus on macOS.
|
||||||
|
[Switch]$TestImportOnly
|
||||||
)
|
)
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
if ($Initialize) {
|
if ($Initialize) {
|
||||||
@@ -21,7 +24,7 @@ if ($Initialize) {
|
|||||||
$ModuleVersion = (. ([Scriptblock]::Create((Get-Content -Path $Psd1 | Out-String)))).ModuleVersion
|
$ModuleVersion = (. ([Scriptblock]::Create((Get-Content -Path $Psd1 | Out-String)))).ModuleVersion
|
||||||
Update-AppveyorBuild -Version "$ModuleVersion ($env:APPVEYOR_BUILD_NUMBER) $env:APPVEYOR_REPO_BRANCH"
|
Update-AppveyorBuild -Version "$ModuleVersion ($env:APPVEYOR_BUILD_NUMBER) $env:APPVEYOR_REPO_BRANCH"
|
||||||
}
|
}
|
||||||
if ($Test) {
|
if ($Test -or $TestImportOnly) {
|
||||||
function Get-EnvironmentInfo {
|
function Get-EnvironmentInfo {
|
||||||
if ([environment]::OSVersion.Platform -like "win*") {
|
if ([environment]::OSVersion.Platform -like "win*") {
|
||||||
# Get Windows Version
|
# Get Windows Version
|
||||||
@@ -97,7 +100,23 @@ if (-not $VersionFilePath) {
|
|||||||
'[Progress] Installing Module.'
|
'[Progress] Installing Module.'
|
||||||
. .\CI\Install.ps1
|
. .\CI\Install.ps1
|
||||||
'[Progress] Invoking Pester.'
|
'[Progress] Invoking Pester.'
|
||||||
Invoke-Pester -OutputFile ('TestResultsPS{0}.xml' -f $PSVersionTable.PSVersion)
|
$pesterParams = @{
|
||||||
|
OutputFile = ('TestResultsPS{0}.xml' -f $PSVersionTable.PSVersion)
|
||||||
|
PassThru = $true
|
||||||
|
}
|
||||||
|
if ($TestImportOnly) {
|
||||||
|
$pesterParams['Tag'] = 'TestImportOnly'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$pesterParams['ExcludeTag'] = 'TestImportOnly'
|
||||||
|
}
|
||||||
|
$testResults = Invoke-Pester @pesterParams
|
||||||
|
'Pester invocation complete!'
|
||||||
|
if ($testResults.FailedCount -gt 0) {
|
||||||
|
"Test failures:"
|
||||||
|
$testResults.TestResult | Where-Object {-not $_.Passed} | Format-List
|
||||||
|
Write-Error "$($testResults.FailedCount) Pester tests failed. Build cannot continue!"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($Finalize) {
|
if ($Finalize) {
|
||||||
'[Progress] Finalizing.'
|
'[Progress] Finalizing.'
|
||||||
|
|||||||
6
__tests__/ImportExcelTests/TestImportOnly.tests.ps1
Normal file
6
__tests__/ImportExcelTests/TestImportOnly.tests.ps1
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
Param()
|
||||||
|
Describe "Module" -Tag "TestImportOnly" {
|
||||||
|
It "Should import without error" {
|
||||||
|
{ Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 -Force -ErrorAction Stop } | Should -Not -Throw
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -93,3 +93,19 @@ jobs:
|
|||||||
testResultsFormat: 'NUnit'
|
testResultsFormat: 'NUnit'
|
||||||
testResultsFiles: '**/TestResults*.xml'
|
testResultsFiles: '**/TestResults*.xml'
|
||||||
failTaskOnFailedTests: true
|
failTaskOnFailedTests: true
|
||||||
|
|
||||||
|
- job: macOSNoDeps
|
||||||
|
pool:
|
||||||
|
vmImage: 'macOS-latest'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- powershell: 'Install-Module -Name Pester -Force -MaximumVersion 4.99.99'
|
||||||
|
displayName: 'Update Pester'
|
||||||
|
- powershell: './CI/CI.ps1 -TestImportOnly'
|
||||||
|
displayName: 'Install and Test Import Only'
|
||||||
|
|
||||||
|
- task: PublishTestResults@2
|
||||||
|
inputs:
|
||||||
|
testResultsFormat: 'NUnit'
|
||||||
|
testResultsFiles: '**/TestResults*.xml'
|
||||||
|
failTaskOnFailedTests: true
|
||||||
|
|||||||
Reference in New Issue
Block a user