-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (63 loc) · 2.66 KB
/
validate-powershell.yml
File metadata and controls
71 lines (63 loc) · 2.66 KB
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
# this workflow uses https://github.com/microsoft/action-psscriptanalyzer . For
# more information on PSScriptAnalyzer in general, see
# https://github.com/PowerShell/PSScriptAnalyzer
name: Validate Powershell
run-name: >-
Validate
${{ github.event_name == 'push' && format('— {0}', github.event.head_commit.message)
|| github.event_name == 'pull_request' && format('PR #{0}: {1}', github.event.pull_request.number, github.event.pull_request.title)
|| github.event_name == 'schedule' && 'Scheduled'
|| github.event_name == 'workflow_dispatch' && 'Manual Dispatch'
|| github.event_name == 'workflow_run' && format('— {0}', github.event.workflow_run.display_title)
|| format('CI Run for commit {0}', github.sha)
}}
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '28 7 * * 4'
# allow manual run
workflow_dispatch:
permissions:
contents: read
jobs:
validate:
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
# Ubuntu-latest doesn't have the right LDAP lib for pwsh.
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
# build any .NET projects in the directory tree.
- name: dotnet build
shell: pwsh
run: |
Get-ChildItem *.sln -Recurse | ForEach-Object { dotnet build $_.FullName }
- name: Run PSScriptAnalyzer
uses: microsoft/psscriptanalyzer-action@6b2948b1944407914a58661c49941824d149734f
with:
# Check https://github.com/microsoft/action-psscriptanalyzer for more info about the options.
# The below set up runs PSScriptAnalyzer to your entire repository and runs some basic security rules.
path: .\src\
recurse: true
# Include your own basic security rules. Removing this option will run all the rules
includeRule: '"PSAvoidGlobalAliases", "PSAvoidUsingConvertToSecureStringWithPlainText"'
output: results.sarif
# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: results.sarif
- name: Install Pester
shell: pwsh
run: |
Install-Module -Name Pester -Scope CurrentUser
- name: Run Pester Unit Tests
shell: pwsh
# Pester by default searches for any pester tests that are *.test.ps1
run: |
Invoke-Pester .\src\ -CI