-
Notifications
You must be signed in to change notification settings - Fork 53
91 lines (79 loc) · 3.07 KB
/
test-redirections.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
name: "Test ConvertTo-RedirectionsXml"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
on:
push:
branches:
- main
paths:
- 'Redirections/**.ps1'
- 'Redirections/**.csv'
workflow_dispatch:
jobs:
validate:
name: "Validate script"
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
- 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: ./Redirections
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@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 }}\\Redirections"
run: |
Import-Module -Name "Pester" -Force -ErrorAction "Stop"
$Config = New-PesterConfiguration
$Config.Run.Path = "$env:GITHUB_WORKSPACE\ConvertTo-RedirectionsXml.Tests.ps1"
$Config.Run.PassThru = $true
$Config.CodeCoverage.Enabled = $true
$Config.CodeCoverage.CoveragePercentTarget = 50
$Config.CodeCoverage.Path = "$env:GITHUB_WORKSPACE\Redirections\ConvertTo-RedirectionsXml.ps1"
$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\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 }}\\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 }}\\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