Merge pull request #27 from aaronparker/dependabot/github_actions/ste… #168
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Validate project" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'src/**' | |
- 'tests/*.ps1' | |
- '!src/VERSION.txt' | |
- '.github/workflows/validate-scripts.yml' | |
workflow_dispatch: | |
jobs: | |
validate: | |
name: "Validate project code" | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: Run PSScriptAnalyzer | |
uses: microsoft/psscriptanalyzer-action@6b2948b1944407914a58661c49941824d149734f | |
with: | |
path: ./src | |
recurse: true | |
output: results.sarif | |
# Upload the SARIF file generated in the previous step | |
- name: Upload SARIF results file | |
uses: github/codeql-action/upload-sarif@v2 | |
with: | |
sarif_file: results.sarif | |
- name: Install Pester | |
shell: powershell | |
working-directory: "${{ github.workspace }}" | |
run: | | |
Install-Module -Name "Pester" -SkipPublisherCheck -Force | |
# Run Pester tests | |
- name: Test with Pester | |
shell: powershell | |
working-directory: "${{ github.workspace }}" | |
run: | | |
Import-Module -Name "Pester" -Force -ErrorAction "Stop" | |
$Config = New-PesterConfiguration | |
$Config.Run.Path = "$env:GITHUB_WORKSPACE\tests" | |
$Config.Run.PassThru = $true | |
$Config.CodeCoverage.Enabled = $true | |
$Config.CodeCoverage.CoveragePercentTarget = 50 | |
$Config.CodeCoverage.Path = "$env:GITHUB_WORKSPACE\src" | |
$Config.CodeCoverage.OutputFormat = "JaCoCo" | |
$Config.CodeCoverage.OutputPath = "$env:GITHUB_WORKSPACE\CodeCoverage.xml" | |
$Config.TestResult.Enabled = $true | |
$Config.Output.Verbosity = "Detailed" | |
$Config.TestResult.OutputFormat = "NUnitXml" | |
$Config.TestResult.OutputPath = "$env:GITHUB_WORKSPACE\tests\TestResults.xml" | |
Invoke-Pester -Configuration $Config | |
# Upload test results | |
- name: Upload test results | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: test-results | |
path: "${{ github.workspace }}\\tests\\TestResults.xml" | |
# Publish test results | |
- name: Publish test results | |
uses: EnricoMi/publish-unit-test-result-action/composite@v2 | |
if: always() | |
with: | |
nunit_files: "${{ github.workspace }}\\tests\\TestResults.xml" | |
- name: Upload to Codecov | |
id: codecov | |
if: always() | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: ./CodeCoverage.xml | |
verbose: true | |
- name: Get version | |
id: get-version | |
shell: powershell | |
working-directory: "${{ github.workspace }}" | |
run: | | |
echo "version=$(Get-Date -Format "yyMM.dd.$($env:GITHUB_RUN_NUMBER)")" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append | |
# Update version number in VERSION.txt | |
- name: Update version number | |
shell: powershell | |
working-directory: "${{ github.workspace }}" | |
run: | | |
"${{ steps.get-version.outputs.version }}" | ` | |
Out-File -FilePath "${{ github.workspace }}\src\VERSION.txt" -Encoding "ascii" -Force -NoNewline | |
# Import GPG key | |
- name: Import GPG key | |
id: import_gpg | |
uses: crazy-max/ghaction-import-gpg@v6 | |
with: | |
gpg_private_key: ${{ secrets.GPGKEY }} | |
passphrase: ${{ secrets.GPGPASSPHRASE }} | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
git_config_global: true | |
git_tag_gpgsign: true | |
git_push_gpgsign: false | |
git_committer_name: ${{ secrets.COMMIT_NAME }} | |
git_committer_email: ${{ secrets.COMMIT_EMAIL }} | |
- name: Commit changes | |
id: commit | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: "${{ steps.get-version.outputs.version }}" | |
commit_user_name: ${{ secrets.COMMIT_NAME }} | |
commit_user_email: ${{ secrets.COMMIT_EMAIL }} |