mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Module.Template 2.0.4 Update
This commit is contained in:
@@ -11,7 +11,9 @@ param
|
||||
# AppVeyor Only - Upload results to AppVeyor "Tests" tab.
|
||||
[Switch]$Finalize,
|
||||
# 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.
|
||||
[Switch]$Analyzer
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
if ($Initialize) {
|
||||
@@ -139,4 +141,68 @@ if ($Artifact) {
|
||||
#Write-Host "##vso[task.setvariable variable=ModuleName]$ModuleName"
|
||||
Copy-Item -Path $ModulePath -Destination $env:Build_ArtifactStagingDirectory -Recurse
|
||||
}
|
||||
}
|
||||
if ($Analyzer) {
|
||||
if (!(Get-Module -Name PSScriptAnalyzer -ListAvailable)) {
|
||||
'[Progress] Installing PSScriptAnalyzer.'
|
||||
Install-Module -Name PSScriptAnalyzer -Force
|
||||
}
|
||||
|
||||
if ($env:System_PullRequest_TargetBranch) {
|
||||
'[Progress] Get target branch.'
|
||||
$TempGitClone = Join-Path ([IO.Path]::GetTempPath()) (New-Guid)
|
||||
Copy-Item -Path $PWD -Destination $TempGitClone -Recurse
|
||||
(Get-Item (Join-Path $TempGitClone '.git')).Attributes += 'Hidden'
|
||||
"[Progress] git clean."
|
||||
git -C $TempGitClone clean -f
|
||||
"[Progress] git reset."
|
||||
git -C $TempGitClone reset --hard
|
||||
"[Progress] git checkout."
|
||||
git -C $TempGitClone checkout -q $env:System_PullRequest_TargetBranch
|
||||
|
||||
$DirsToProcess = @{ 'Pull Request' = $PWD ; $env:System_PullRequest_TargetBranch = $TempGitClone }
|
||||
}
|
||||
else {
|
||||
$DirsToProcess = @{ 'GitHub' = $PWD }
|
||||
}
|
||||
|
||||
"[Progress] Running Script Analyzer."
|
||||
$AnalyzerResults = $DirsToProcess.GetEnumerator() | ForEach-Object {
|
||||
$DirName = $_.Key
|
||||
Write-Verbose "[Progress] Running Script Analyzer on $DirName."
|
||||
Invoke-ScriptAnalyzer -Path $_.Value -Recurse -ErrorAction SilentlyContinue |
|
||||
Add-Member -MemberType NoteProperty -Name Location -Value $DirName -PassThru
|
||||
}
|
||||
|
||||
if ($AnalyzerResults) {
|
||||
if (!(Get-Module -Name ImportExcel -ListAvailable)) {
|
||||
'[Progress] Installing ImportExcel.'
|
||||
Install-Module -Name ImportExcel -Force
|
||||
}
|
||||
'[Progress] Creating ScriptAnalyzer.xlsx.'
|
||||
$ExcelParams = @{
|
||||
Path = 'ScriptAnalyzer.xlsx'
|
||||
WorksheetName = 'FullResults'
|
||||
Now = $true
|
||||
Activate = $true
|
||||
Show = $false
|
||||
}
|
||||
$PivotParams = @{
|
||||
PivotTableName = 'BreakDown'
|
||||
PivotData = @{RuleName = 'Count' }
|
||||
PivotRows = 'Severity', 'RuleName'
|
||||
PivotColumns = 'Location'
|
||||
PivotTotals = 'Rows'
|
||||
}
|
||||
Remove-Item -Path $ExcelParams['Path'] -ErrorAction SilentlyContinue
|
||||
|
||||
$PivotParams['PivotChartDefinition'] = New-ExcelChartDefinition -ChartType 'BarClustered' -Column (1 + $DirsToProcess.Count) -Title "Script analysis" -LegendBold
|
||||
$ExcelParams['PivotTableDefinition'] = New-PivotTableDefinition @PivotParams
|
||||
|
||||
$AnalyzerResults | Export-Excel @ExcelParams
|
||||
'[Progress] Analyzer finished.'
|
||||
}
|
||||
else {
|
||||
"[Info] Invoke-ScriptAnalyzer didn't return any problems."
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
.SYNOPSIS
|
||||
Deploy module to PowerShellGallery.
|
||||
#>
|
||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "Success")]
|
||||
[CmdletBinding(DefaultParameterSetName = 'ModuleName')]
|
||||
Param
|
||||
(
|
||||
18
appveyor.yml
18
appveyor.yml
@@ -28,20 +28,20 @@ install:
|
||||
- ps: 'Install-Module -Name Pester -Force -SkipPublisherCheck'
|
||||
- ps: 'Install-Module -Name Assert -Force'
|
||||
# PowerShell Core
|
||||
- ps: '& .\__tests__\InstallPowerShell.ps1 -Version "7.0.0-preview.3"' # Install other PowerShell Core version (Optional)
|
||||
- ps: '& .\CI\InstallPowerShell.ps1 -Version "7.0.0-preview.4"' # Install other PowerShell Core version (Optional)
|
||||
- pwsh: 'Install-Module -Name Pester -Force'
|
||||
- pwsh: 'Install-Module -Name Assert -Force'
|
||||
|
||||
# To run your custom scripts instead of automatic tests
|
||||
test_script:
|
||||
- ps: '& .\__tests__\CI.ps1 -Test'
|
||||
- pwsh: '& .\__tests__\CI.ps1 -Test'
|
||||
- ps: '& .\__tests__\CI.ps1 -Finalize' # Collect and upload results
|
||||
- ps: '& .\CI\CI.ps1 -Test'
|
||||
- pwsh: '& .\CI\CI.ps1 -Test'
|
||||
- ps: '& .\CI\CI.ps1 -Finalize' # Collect and upload results
|
||||
|
||||
# Deploy
|
||||
deploy_script:
|
||||
- ps: '& .\__tests__\CI.ps1 -Artifact'
|
||||
#- ps: '$null = Install-PackageProvider -Name NuGet -Force ; & .\__tests__\Publish.ps1'
|
||||
- ps: '& .\CI\CI.ps1 -Artifact'
|
||||
- ps: '$null = Install-PackageProvider -Name NuGet -Force ; & .\CI\Publish.ps1'
|
||||
|
||||
# Linux setup
|
||||
for:
|
||||
@@ -55,13 +55,13 @@ for:
|
||||
- sh: 'export LANG=en_US.UTF-8' # Fix for PowerShell 7.0.0-preview.2, Remove if using other version.
|
||||
# Scripts that run after cloning repository
|
||||
install:
|
||||
- pwsh: '& .\__tests__\CI.ps1 -Initialize' # Set AppVeyor build version
|
||||
- pwsh: '& .\CI\CI.ps1 -Initialize' # Set AppVeyor build version
|
||||
- pwsh: 'Install-Module -Name Pester -Force'
|
||||
- pwsh: 'Install-Module -Name Assert -Force'
|
||||
# To run your custom scripts instead of automatic tests
|
||||
test_script:
|
||||
- pwsh: '& .\__tests__\CI.ps1 -Test'
|
||||
- pwsh: '& .\__tests__\CI.ps1 -Finalize' # Collect and upload results
|
||||
- pwsh: '& .\CI\CI.ps1 -Test'
|
||||
- pwsh: '& .\CI\CI.ps1 -Finalize' # Collect and upload results
|
||||
# Skip Deploy
|
||||
deploy_script:
|
||||
- pwsh: '"Deploy skiped on Linux."'
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
steps:
|
||||
- powershell: 'Install-Module -Name Pester -Force -SkipPublisherCheck'
|
||||
displayName: 'Update Pester'
|
||||
- powershell: './__tests__/CI.ps1 -Test'
|
||||
- powershell: './CI/CI.ps1 -Test'
|
||||
displayName: 'Install and Test'
|
||||
|
||||
- task: PublishTestResults@2
|
||||
@@ -31,12 +31,14 @@ jobs:
|
||||
testResultsFiles: '**/TestResults*.xml'
|
||||
failTaskOnFailedTests: true
|
||||
|
||||
- powershell: './__tests__/CI.ps1 -Artifact'
|
||||
- powershell: './CI/CI.ps1 -Artifact'
|
||||
displayName: 'Prepare Artifact'
|
||||
- task: PublishPipelineArtifact@1
|
||||
inputs:
|
||||
targetPath: '$(Build.ArtifactStagingDirectory)'
|
||||
artifact: 'Modules'
|
||||
- powershell: './CI/CI.ps1 -Analyzer'
|
||||
displayName: 'Invoke ScriptAnalyzer'
|
||||
- task: PublishPipelineArtifact@1
|
||||
inputs:
|
||||
targetPath: '$(Build.SourcesDirectory)'
|
||||
@@ -49,7 +51,7 @@ jobs:
|
||||
steps:
|
||||
- pwsh: 'Install-Module -Name Pester -Force'
|
||||
displayName: 'Update Pester'
|
||||
- pwsh: './__tests__/CI.ps1 -Test'
|
||||
- pwsh: './CI/CI.ps1 -Test'
|
||||
displayName: 'Install and Test'
|
||||
|
||||
- task: PublishTestResults@2
|
||||
@@ -65,7 +67,7 @@ jobs:
|
||||
steps:
|
||||
- powershell: 'Install-Module -Name Pester -Force'
|
||||
displayName: 'Update Pester'
|
||||
- powershell: './__tests__/CI.ps1 -Test'
|
||||
- powershell: './CI/CI.ps1 -Test'
|
||||
displayName: 'Install and Test'
|
||||
|
||||
- task: PublishTestResults@2
|
||||
@@ -83,7 +85,7 @@ jobs:
|
||||
displayName: 'Install mono-libgdiplus'
|
||||
- powershell: 'Install-Module -Name Pester -Force'
|
||||
displayName: 'Update Pester'
|
||||
- powershell: './__tests__/CI.ps1 -Test'
|
||||
- powershell: './CI/CI.ps1 -Test'
|
||||
displayName: 'Install and Test'
|
||||
|
||||
- task: PublishTestResults@2
|
||||
|
||||
Reference in New Issue
Block a user