diff --git a/.github/workflows/code-analysis-built-module.yml b/.github/workflows/code-analysis-built-module.yml index 47c377c..8399e3f 100644 --- a/.github/workflows/code-analysis-built-module.yml +++ b/.github/workflows/code-analysis-built-module.yml @@ -1,64 +1,64 @@ -name: Code analysis (built module) - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - workflow_dispatch: - -# cSpell: ignore codeql SARIF -jobs: - pssa: - name: PSScriptAnalyzer - runs-on: windows-latest - permissions: - contents: read # for actions/checkout to fetch code - security-events: write # for github/codeql-action/upload-sarif to upload SARIF results - #actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Install GitVersion - shell: powershell - run: | - dotnet tool install --global GitVersion.Tool --version 5.* - - name: Run GitVersion - shell: powershell - run: | - dotnet-gitversion | ConvertFrom-Json - - name: Build Module - shell: powershell - run: | - Write-Information -MessageData 'Module is being built.' -InformationAction 'Continue' - .\build.ps1 -ResolveDependency -Tasks 'build' - - name: Run PSScriptAnalyzer - shell: powershell - run: | - Write-Information -MessageData 'Prepare the test pipeline.' -InformationAction 'Continue' - .\build.ps1 -Tasks 'noop' - - Write-Information -MessageData 'Import module ConvertToSARIF into the session.' -InformationAction 'Continue' - Import-Module -Name 'ConvertToSARIF' -Force - - Write-Information -MessageData 'Import module PSScriptAnalyzer into the session.' -InformationAction 'Continue' - Import-Module -Name 'PSScriptAnalyzer' -Force - - $filesToScan = Get-ChildItem -Path './output/builtModule/PSResourceGet.Bootstrap/**/PSResourceGet.Bootstrap.psm1' -File - Write-Information -MessageData ("Will scan the file:`t{0}." -f $filesToScan.FullName) -InformationAction 'Continue' - - Write-Information -MessageData 'Running PSScriptAnalyzer on built module.' -InformationAction 'Continue' - $pssaError = $filesToScan | - Invoke-ScriptAnalyzer -Settings './.vscode/analyzersettings.psd1' - - Write-Information -MessageData 'Converting PSScriptAnalyzer result to SARIF.' -InformationAction 'Continue' - $pssaError | - ConvertTo-SARIF -FilePath 'results.sarif' - - Write-Information -MessageData 'Analyzing done.' -InformationAction 'Continue' - - name: Upload SARIF results - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: results.sarif +name: Code analysis (built module) + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +# cSpell: ignore codeql SARIF +jobs: + pssa: + name: PSScriptAnalyzer + runs-on: windows-latest + permissions: + contents: read # for actions/checkout to fetch code + security-events: write # for github/codeql-action/upload-sarif to upload SARIF results + #actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status + steps: + - name: Checkout code + uses: actions/checkout@v5 + with: + fetch-depth: 0 + - name: Install GitVersion + shell: powershell + run: | + dotnet tool install --global GitVersion.Tool --version 5.* + - name: Run GitVersion + shell: powershell + run: | + dotnet-gitversion | ConvertFrom-Json + - name: Build Module + shell: powershell + run: | + Write-Information -MessageData 'Module is being built.' -InformationAction 'Continue' + .\build.ps1 -ResolveDependency -Tasks 'build' + - name: Run PSScriptAnalyzer + shell: powershell + run: | + Write-Information -MessageData 'Prepare the test pipeline.' -InformationAction 'Continue' + .\build.ps1 -Tasks 'noop' + + Write-Information -MessageData 'Import module ConvertToSARIF into the session.' -InformationAction 'Continue' + Import-Module -Name 'ConvertToSARIF' -Force + + Write-Information -MessageData 'Import module PSScriptAnalyzer into the session.' -InformationAction 'Continue' + Import-Module -Name 'PSScriptAnalyzer' -Force + + $filesToScan = Get-ChildItem -Path './output/builtModule/PSResourceGet.Bootstrap/**/PSResourceGet.Bootstrap.psm1' -File + Write-Information -MessageData ("Will scan the file:`t{0}." -f $filesToScan.FullName) -InformationAction 'Continue' + + Write-Information -MessageData 'Running PSScriptAnalyzer on built module.' -InformationAction 'Continue' + $pssaError = $filesToScan | + Invoke-ScriptAnalyzer -Settings './.vscode/analyzersettings.psd1' + + Write-Information -MessageData 'Converting PSScriptAnalyzer result to SARIF.' -InformationAction 'Continue' + $pssaError | + ConvertTo-SARIF -FilePath 'results.sarif' + + Write-Information -MessageData 'Analyzing done.' -InformationAction 'Continue' + - name: Upload SARIF results + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: results.sarif diff --git a/.github/workflows/code-analysis.yml b/.github/workflows/code-analysis.yml index 7af1464..ac93252 100644 --- a/.github/workflows/code-analysis.yml +++ b/.github/workflows/code-analysis.yml @@ -1,74 +1,74 @@ -name: Code analysis (source) - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - workflow_dispatch: - -# cSpell: ignore codeql SARIF -jobs: - pssa: - name: PSScriptAnalyzer - runs-on: windows-latest - permissions: - contents: read # for actions/checkout to fetch code - security-events: write # for github/codeql-action/upload-sarif to upload SARIF results - #actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Install GitVersion - shell: powershell - run: | - dotnet tool install --global GitVersion.Tool --version 5.* - - name: Run GitVersion - shell: powershell - run: | - dotnet-gitversion | ConvertFrom-Json - - name: Build Module - shell: powershell - run: | - Write-Information -MessageData 'Module is being built so that examples can be scanned.' -InformationAction 'Continue' - .\build.ps1 -ResolveDependency -Tasks 'build' - - name: Run PSScriptAnalyzer - shell: powershell - run: | - Write-Information -MessageData 'Prepare the test pipeline.' -InformationAction 'Continue' - .\build.ps1 -Tasks 'noop' - - Write-Information -MessageData 'Import module ConvertToSARIF into the session.' -InformationAction 'Continue' - Import-Module -Name 'ConvertToSARIF' -Force - - Write-Information -MessageData 'Import module PSScriptAnalyzer into the session.' -InformationAction 'Continue' - Import-Module -Name 'PSScriptAnalyzer' -Force - - $filesToScan = Get-ChildItem -Path './source/' -Recurse -Include @('*.psm1', '*.ps1') -File - Write-Information -MessageData ("Will scan the files:`n`r`t{0}." -f ($filesToScan.FullName -join "`n`r`t")) -InformationAction 'Continue' - - Write-Information -MessageData 'Running PSScriptAnalyzer.' -InformationAction 'Continue' - $pssaError = $filesToScan | - Invoke-ScriptAnalyzer -Settings './.vscode/analyzersettings.psd1' - - $parseErrorTypes = @( - 'TypeNotFound' - 'RequiresModuleInvalid' - ) - Write-Information -MessageData ('Filter out reported parse errors that is unable to be resolved in source files: {0}' -f ($parseErrorTypes -join ', ')) -InformationAction 'Continue' - $pssaError = $pssaError | - Where-Object -FilterScript { - $_.RuleName -notin $parseErrorTypes - } - - Write-Information -MessageData 'Converting PSScriptAnalyzer result to SARIF.' -InformationAction 'Continue' - $pssaError | - ConvertTo-SARIF -FilePath 'results.sarif' - - Write-Information -MessageData 'Analyzing done.' -InformationAction 'Continue' - - name: Upload SARIF results - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: results.sarif +name: Code analysis (source) + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +# cSpell: ignore codeql SARIF +jobs: + pssa: + name: PSScriptAnalyzer + runs-on: windows-latest + permissions: + contents: read # for actions/checkout to fetch code + security-events: write # for github/codeql-action/upload-sarif to upload SARIF results + #actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status + steps: + - name: Checkout code + uses: actions/checkout@v5 + with: + fetch-depth: 0 + - name: Install GitVersion + shell: powershell + run: | + dotnet tool install --global GitVersion.Tool --version 5.* + - name: Run GitVersion + shell: powershell + run: | + dotnet-gitversion | ConvertFrom-Json + - name: Build Module + shell: powershell + run: | + Write-Information -MessageData 'Module is being built so that examples can be scanned.' -InformationAction 'Continue' + .\build.ps1 -ResolveDependency -Tasks 'build' + - name: Run PSScriptAnalyzer + shell: powershell + run: | + Write-Information -MessageData 'Prepare the test pipeline.' -InformationAction 'Continue' + .\build.ps1 -Tasks 'noop' + + Write-Information -MessageData 'Import module ConvertToSARIF into the session.' -InformationAction 'Continue' + Import-Module -Name 'ConvertToSARIF' -Force + + Write-Information -MessageData 'Import module PSScriptAnalyzer into the session.' -InformationAction 'Continue' + Import-Module -Name 'PSScriptAnalyzer' -Force + + $filesToScan = Get-ChildItem -Path './source/' -Recurse -Include @('*.psm1', '*.ps1') -File + Write-Information -MessageData ("Will scan the files:`n`r`t{0}." -f ($filesToScan.FullName -join "`n`r`t")) -InformationAction 'Continue' + + Write-Information -MessageData 'Running PSScriptAnalyzer.' -InformationAction 'Continue' + $pssaError = $filesToScan | + Invoke-ScriptAnalyzer -Settings './.vscode/analyzersettings.psd1' + + $parseErrorTypes = @( + 'TypeNotFound' + 'RequiresModuleInvalid' + ) + Write-Information -MessageData ('Filter out reported parse errors that is unable to be resolved in source files: {0}' -f ($parseErrorTypes -join ', ')) -InformationAction 'Continue' + $pssaError = $pssaError | + Where-Object -FilterScript { + $_.RuleName -notin $parseErrorTypes + } + + Write-Information -MessageData 'Converting PSScriptAnalyzer result to SARIF.' -InformationAction 'Continue' + $pssaError | + ConvertTo-SARIF -FilePath 'results.sarif' + + Write-Information -MessageData 'Analyzing done.' -InformationAction 'Continue' + - name: Upload SARIF results + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: results.sarif diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ca2db2..d6e5ab2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Bump Stale action to v10. +- Bump Checkout action to v5. ## [0.2.0] - 2024-02-18