-
-
Notifications
You must be signed in to change notification settings - Fork 301
192 lines (170 loc) · 6.41 KB
/
Copy pathci.yml
File metadata and controls
192 lines (170 loc) · 6.41 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
name: Continuous Integration
on:
push:
branches:
- develop
paths:
- 'src/**'
pull_request:
branches:
- main
- develop
paths:
- 'src/**'
workflow_dispatch:
branches: [main, develop]
permissions:
contents: read
pull-requests: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-test:
name: Build and Test
runs-on: windows-latest
outputs:
app_version: ${{ steps.version.outputs.app_version }}
unsigned_artifact_name: winmemorycleaner-${{ steps.version.outputs.app_version }}
test_artifact_name: ${{ steps.determine_artifact.outputs.name }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
nuget-
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Restore NuGet packages
shell: pwsh
run: nuget restore src\WinMemoryCleaner.sln
- name: Build solution
shell: pwsh
run: msbuild src\WinMemoryCleaner.sln /m /p:Configuration=Release /p:Platform="Any CPU"
- name: Get App Version
id: version
shell: pwsh
run: |
$assemblyInfoPath = "src/Properties/AssemblyInfo.cs"
if (-Not (Test-Path $assemblyInfoPath)) {
$assemblyInfoPath = "src/Properties/AssemblyInfo.cs"
}
if (-Not (Test-Path $assemblyInfoPath)) {
Write-Host "::error::AssemblyInfo.cs not found"
exit 1
}
$assemblyInfo = Get-Content $assemblyInfoPath
$versionLine = $assemblyInfo | Select-String -Pattern 'AssemblyVersion\("([0-9\.]+)"\)'
if ($versionLine -match 'AssemblyVersion\("([0-9\.]+)"\)') {
$fullVersion = $matches[1]
if ($fullVersion -match '^(\d+\.\d+\.\d+)') {
$appVersion = $matches[1]
echo "app_version=$appVersion" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
} else {
Write-Host "::error::Could not parse Major.Minor.Patch from version $fullVersion"
exit 1
}
} else {
Write-Host "::error::Could not find version in $assemblyInfoPath"
exit 1
}
- name: Upload unsigned EXE as artifact
id: upload-unsigned
uses: actions/upload-artifact@v4
with:
name: winmemorycleaner-${{ steps.version.outputs.app_version }}
path: src\bin\Release\WinMemoryCleaner.exe
if-no-files-found: error
- name: Submit to SignPath (Develop CI Signing)
if: github.repository == 'IgorMundstein/WinMemoryCleaner' && github.ref == 'refs/heads/develop'
id: signpath
uses: signpath/github-action-submit-signing-request@v1.1
with:
api-token: ${{ secrets.SIGNPATH_API_TOKEN }}
organization-id: ${{ secrets.SIGNPATH_ORGANIZATION_ID }}
project-slug: WinMemoryCleaner
signing-policy-slug: ci-signing
github-artifact-id: ${{ steps.upload-unsigned.outputs.artifact-id }}
wait-for-completion: true
output-artifact-directory: ./
- name: Upload signed build artifact
if: steps.signpath.conclusion == 'success'
uses: actions/upload-artifact@v4
with:
name: winmemorycleaner-${{ steps.version.outputs.app_version }}-signed
path: WinMemoryCleaner.exe
retention-days: 30
- name: Determine Test Artifact
id: determine_artifact
shell: pwsh
run: |
if ('${{ steps.signpath.conclusion }}' -eq 'success') {
echo "name=winmemorycleaner-${{ steps.version.outputs.app_version }}-signed" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
} else {
echo "name=winmemorycleaner-${{ steps.version.outputs.app_version }}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
}
test-ui:
name: UI Test on ${{ matrix.os }}
needs: build-and-test
strategy:
fail-fast: false
matrix:
os: [windows-2022, windows-2025]
runs-on: ${{ matrix.os }}
steps:
- name: Download build artifact for testing
uses: actions/download-artifact@v4
with:
name: ${{ needs.build-and-test.outputs.test_artifact_name }}
- name: Run UI Test
shell: pwsh
run: |
$appPath = ".\WinMemoryCleaner.exe"
$appName = "WinMemoryCleaner"
$screenshotPath = ".\screenshot-${{ matrix.os }}.png"
Start-Process -FilePath $appPath
Start-Sleep -Seconds 5
$process = Get-Process -Name $appName -ErrorAction SilentlyContinue
if (-not $process) {
Write-Host "::error::$appName process not found after starting."
exit 1
}
Add-Type -AssemblyName System.Windows.Forms
$bounds = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds
$bitmap = New-Object System.Drawing.Bitmap $bounds.Width, $bounds.Height
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
$graphics.CopyFromScreen($bounds.Location, [System.Drawing.Point]::Empty, $bounds.Size)
$bitmap.Save($screenshotPath, [System.Drawing.Imaging.ImageFormat]::Png)
$graphics.Dispose()
$bitmap.Dispose()
Stop-Process -Name $appName -Force
- name: Upload Screenshot Artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: ui-test-screenshot-${{ matrix.os }}
path: screenshot-${{ matrix.os }}.png
retention-days: 1
package-screenshots:
name: Package All Screenshots
needs: [build-and-test, test-ui]
runs-on: ubuntu-latest
steps:
- name: Download all screenshot artifacts
uses: actions/download-artifact@v4
with:
pattern: ui-test-screenshot-*
path: ./all-screenshots
merge-multiple: true
- name: List final files for verification
run: ls -R ./all-screenshots
- name: Upload final screenshot package
uses: actions/upload-artifact@v4
with:
name: all-screenshots-${{ needs.build-and-test.outputs.app_version }}
path: ./all-screenshots/
retention-days: 30