-
-
Notifications
You must be signed in to change notification settings - Fork 18
144 lines (129 loc) · 4.6 KB
/
validate-module.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Validate module
on:
push:
branches:
- '*'
- '!main'
paths:
- 'VcRedist/**'
- 'tests/**'
- '.github/workflows/validate-module.yml'
tags-ignore:
- '*'
pull_request:
branches:
- 'main'
paths:
- 'VcRedist/**'
- '!VcRedist/VcRedist.psd1'
- 'tests/**'
workflow_dispatch:
jobs:
psscriptanalyzer:
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
name: Run PSScriptAnalyzer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run PSScriptAnalyzer (development push)
uses: microsoft/psscriptanalyzer-action@6b2948b1944407914a58661c49941824d149734f
with:
path: "./VcRedist"
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@v3
with:
sarif_file: results.sarif
run-pester:
name: Test with Pester
needs: psscriptanalyzer
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-2022]
steps:
- uses: actions/checkout@v4
# Run Pester tests
- name: Run Pester tests
shell: powershell
working-directory: "${{ github.workspace }}"
env:
TENANT_ID: ${{ secrets.TENANT_ID }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
run: |
.\tests\Install-Pester.ps1
Import-Module -Name "Pester" -Force -ErrorAction "Stop"
Import-Module -Name "$env:GITHUB_WORKSPACE\VcRedist" -Force
$Config = New-PesterConfiguration
$Config.Run.Path = "$env:GITHUB_WORKSPACE\tests"
$Config.Run.PassThru = $True
$Config.CodeCoverage.Enabled = $True
$Config.CodeCoverage.Path = "$env:GITHUB_WORKSPACE\VcRedist"
$Config.CodeCoverage.OutputFormat = "JaCoCo"
$Config.CodeCoverage.OutputPath = "$env:GITHUB_WORKSPACE\CodeCoverage-${{ matrix.os }}.xml"
$Config.TestResult.Enabled = $True
$Config.TestResult.OutputFormat = "NUnitXml"
$Config.TestResult.OutputPath = "$env:GITHUB_WORKSPACE\tests\TestResults-${{ matrix.os }}.xml"
$Config.Output.Verbosity = "Detailed"
Invoke-Pester -Configuration $Config
- name: Upload artifacts
id: upload-artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: pester-test-results
path: |
${{ github.workspace }}\tests\TestResults-${{ matrix.os }}.xml
# Publish Pester test results
- name: Publish Pester test results
uses: EnricoMi/publish-unit-test-result-action/composite@v2
if: always()
with:
nunit_files: "${{ github.workspace }}//tests//TestResults-${{ matrix.os }}.xml"
- name: Upload to Codecov
id: codecov
if: always()
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./CodeCoverage-${{ matrix.os }}.xml
verbose: true
- name: Install and cache PowerShell modules
id: psmodulecache
uses: potatoqualitee/[email protected]
with:
modules-to-cache: BuildHelpers
shell: powershell
- name: Update module version
shell: powershell
working-directory: "${{ github.workspace }}"
run: |
Import-Module -Name BuildHelpers
Step-ModuleVersion -Path .\VcRedist\VcRedist.psd1 -By Build
# Import GPG key so that we can sign the commit
- 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: "Update module version"
commit_user_name: ${{ secrets.COMMIT_NAME }}
commit_user_email: ${{ secrets.COMMIT_EMAIL }}