-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (134 loc) · 4.68 KB
/
Copy pathTests.yml
File metadata and controls
154 lines (134 loc) · 4.68 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
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
145
146
147
148
149
150
151
152
153
154
name: Run Tests
on:
push:
branches-ignore:
- main
pull_request:
branches:
- main
- develop
schedule:
- cron: '0 * * * *'
workflow_dispatch:
permissions:
contents: read
actions: read
defaults:
run:
shell: pwsh
jobs:
test-and-coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install required CI PowerShell modules
run: ./scripts/build/ci/Install-CiPowerShellModules.ps1
- name: Run NovaModuleTools CI test
run: ./scripts/build/ci/Invoke-NovaModuleToolsCI.ps1 -OutputDirectory ./artifacts
- name: Validate release history files with Test-KeepAChangelogFile
run: |
foreach ($path in @('./CHANGELOG.md', './RELEASE_NOTE.md')) {
$result = Test-KeepAChangelogFile -Path $path
if (-not $result.IsValid) {
$errors = $result.Errors -join [Environment]::NewLine
throw "Validation failed for $path$([Environment]::NewLine)$errors"
}
}
- name: Upload CI artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: nova-ci-artifacts
if-no-files-found: warn
path: |
artifacts/
dist/
- name: Generate Report
if: always()
run: |
$reportLines = @(
'## CI Output Files',
'',
'### artifacts/',
''
)
$artifactFiles = Get-ChildItem -Path ./artifacts -Recurse -File -ErrorAction SilentlyContinue | Sort-Object FullName
if ($artifactFiles) {
$reportLines += '| Name | Directory |'
$reportLines += '| --- | --- |'
$reportLines += $artifactFiles | ForEach-Object {
$name = ('' + $_.Name).Replace('|', '\|')
$directory = ('' + $_.Directory).Replace('|', '\|')
"| $name | $directory |"
}
}
else {
$reportLines += 'No files found in `./artifacts`.'
}
$reportLines += @('', '### dist/', '')
$files = Get-ChildItem -Path ./dist -Recurse -ErrorAction SilentlyContinue | Sort-Object FullName
if ($files) {
$reportLines += '| Name | Directory |'
$reportLines += '| --- | --- |'
$reportLines += $files | ForEach-Object {
$name = ('' + $_.Name).Replace('|', '\|')
$directory = ('' + $_.Directory).Replace('|', '\|')
"| $name | $directory |"
}
}
else {
$reportLines += 'No files found in `./dist`.'
}
$report = $reportLines -join [Environment]::NewLine
Add-Content -LiteralPath $env:GITHUB_STEP_SUMMARY -Value $report
Write-Output $report
codescene-coverage-gates:
runs-on: ubuntu-latest
needs:
- test-and-coverage
if: ${{ needs.test-and-coverage.result == 'success' && github.event_name == 'pull_request' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download CI artifacts
uses: actions/download-artifact@v4
with:
name: nova-ci-artifacts
path: coverage/
- name: Check coverage gates in CodeScene
uses: ./.github/actions/check-coverage
with:
access-token: ${{ secrets.CS_ACCESS_TOKEN }}
project-url: ${{ format('{0}/v2/projects/{1}', vars.CS_URL, vars.CS_PROJECT_ID) }}
coverage-files: '**/coverage.xml'
codescene-analysis:
runs-on: ubuntu-latest
needs:
- test-and-coverage
if: ${{ needs.test-and-coverage.result == 'success' && (github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref_name == 'develop')) }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download CI artifacts
uses: actions/download-artifact@v4
with:
name: nova-ci-artifacts
path: .
- name: Install CodeScene coverage CLI
shell: bash
run: |
set -euo pipefail
curl -fsSL -o install-cs-coverage-tool.sh https://downloads.codescene.io/enterprise/cli/install-cs-coverage-tool.sh
bash install-cs-coverage-tool.sh -y
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Upload coverage to CodeScene and trigger analysis
env:
CS_URL: ${{ vars.CS_URL }}
CS_PROJECT_ID: ${{ vars.CS_PROJECT_ID }}
CS_ACCESS_TOKEN: ${{ secrets.CS_ACCESS_TOKEN }}
run: ./scripts/build/ci/Invoke-CodeSceneAnalysis.ps1 -UploadCoverage -TriggerAnalysis