-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
269 lines (227 loc) · 8.69 KB
/
ci.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
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# Copyright (c) 2024 Files Community
# Licensed under the MIT License. See the LICENSE.
# Abstract:
# This CI is executed when a new commit is created on the main branch or
# on a PR whose head branch is the main branch.
# However, the CI will not be executed if files not directly related to
# source code maintenance are updated.
name: Files CI
on:
push:
branches:
- main
paths-ignore:
- 'assets/**'
- 'builds/**'
- 'docs/**'
- '*.md'
pull_request:
paths-ignore:
- 'assets/**'
- 'builds/**'
- 'docs/**'
- '*.md'
run-name: ${{ github.event_name == 'pull_request' && 'Files PR Validation' || 'Files CI Validation' }}
env:
WORKING_DIR: ${{ github.workspace }} # Default: 'D:\a\Files\Files'
SOLUTION_PATH: '${{ github.workspace }}\Files.sln'
PACKAGE_PROJECT_DIR: '${{ github.workspace }}\src\Files.App (Package)'
PACKAGE_PROJECT_PATH: '${{ github.workspace }}\src\Files.App (Package)\Files.Package.wapproj'
AUTOMATED_TESTS_ARCHITECTURE: 'x64'
AUTOMATED_TESTS_CONFIGURATION: 'Release'
AUTOMATED_TESTS_PROJECT_DIR: '${{ github.workspace }}\tests\Files.InteractionTests'
AUTOMATED_TESTS_PROJECT_PATH: '${{ github.workspace }}\tests\Files.InteractionTests\Files.InteractionTests.csproj'
AUTOMATED_TESTS_ASSEMBLY_DIR: '${{ github.workspace }}\artifacts\TestsAssembly'
ARTIFACTS_STAGING_DIR: '${{ github.workspace }}\artifacts'
APPX_PACKAGE_DIR: '${{ github.workspace }}\artifacts\AppxPackages'
APPX_SELFSIGNED_CERT_PATH: '${{ github.workspace }}\.github\workflows\FilesApp_SelfSigned.pfx'
WINAPPDRIVER_EXE86_PATH: 'C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe'
WINAPPDRIVER_EXE64_PATH: 'C:\Program Files\Windows Application Driver\WinAppDriver.exe'
jobs:
check-formatting:
if: github.repository_owner == 'files-community'
runs-on: windows-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
- name: Install XamlStyler.Console
run: 'dotnet tool install --global XamlStyler.Console'
- name: Check XAML formatting
id: check-step
run: |
$changedFiles = (git diff --diff-filter=d --name-only HEAD~1) -split "\n" | Where-Object {$_ -like "*.xaml"}
foreach ($file in $changedFiles)
{
xstyler -p -l None -f $file
if ($LASTEXITCODE -ne 0)
{
echo "::error file=$file::Format check failed"
}
}
continue-on-error: true
- name: Fail if necessary
if: steps.check-step.outcome == 'failure'
run: exit 1
build:
if: github.repository_owner == 'files-community'
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
configuration: [Debug, Release]
platform: [x64, arm64]
env:
CONFIGURATION: ${{ matrix.configuration }}
ARCHITECTURE: ${{ matrix.platform }}
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Setup NuGet
uses: NuGet/setup-nuget@v2
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Restore NuGet
shell: pwsh
run: 'nuget restore $env:SOLUTION_PATH'
- name: Restore Files
shell: pwsh
run: |
msbuild $env:SOLUTION_PATH `
-t:Restore `
-p:Platform=$env:ARCHITECTURE `
-p:Configuration=$env:CONFIGURATION `
-p:PublishReadyToRun=true
- if: env.CONFIGURATION != env.AUTOMATED_TESTS_CONFIGURATION || env.ARCHITECTURE != env.AUTOMATED_TESTS_ARCHITECTURE
name: Build Files
run: |
msbuild `
$env:PACKAGE_PROJECT_PATH `
-t:Build `
-clp:ErrorsOnly `
-p:Configuration=$env:CONFIGURATION `
-p:Platform=$env:ARCHITECTURE `
-p:AppxBundle=Never
- if: env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION && env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE
name: Create self signed cert as a pfx file
run: ./.github/scripts/Generate-SelfCertPfx.ps1 -Destination "$env:APPX_SELFSIGNED_CERT_PATH"
- if: env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION && env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE
name: Build & package Files
run: |
msbuild `
$env:PACKAGE_PROJECT_PATH `
-t:Build `
-t:_GenerateAppxPackage `
-clp:ErrorsOnly `
-p:Configuration=$env:CONFIGURATION `
-p:Platform=$env:ARCHITECTURE `
-p:AppxBundlePlatforms=$env:AUTOMATED_TESTS_ARCHITECTURE `
-p:AppxBundle=Always `
-p:UapAppxPackageBuildMode=SideloadOnly `
-p:AppxPackageDir=$env:APPX_PACKAGE_DIR `
-p:AppxPackageSigningEnabled=true `
-p:PackageCertificateKeyFile=$env:APPX_SELFSIGNED_CERT_PATH `
-p:PackageCertificatePassword="" `
-p:PackageCertificateThumbprint=""
- if: env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE && env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION
name: Build interaction tests
run: |
msbuild $env:AUTOMATED_TESTS_PROJECT_PATH `
-t:Build `
-clp:ErrorsOnly `
-p:Configuration=$env:CONFIGURATION `
-p:Platform=$env:AUTOMATED_TESTS_ARCHITECTURE
- if: env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE && env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION
name: Copy tests bin to the artifacts dir
shell: pwsh
run: |
Copy-Item `
-Path "$env:AUTOMATED_TESTS_PROJECT_DIR\bin" `
-Destination "$env:AUTOMATED_TESTS_ASSEMBLY_DIR" -Recurse
- if: env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE && env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION
name: Upload the packages to the Artifacts
uses: actions/upload-artifact@v4
with:
name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.ARCHITECTURE }})'
path: ${{ env.ARTIFACTS_STAGING_DIR }}
test:
if: github.repository_owner == 'files-community' && always()
needs: [build]
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
configuration: [Release]
platform: [x64]
env:
CONFIGURATION: ${{ matrix.configuration }}
permissions:
contents: read
pull-requests: write
steps:
- if: contains(join(needs.*.result, ','), 'failure')
name: Fail if necessary
run: exit 1
- name: Checkout the repository
uses: actions/checkout@v4
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Download the packages from the Artifacts
uses: actions/download-artifact@v4
with:
name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.AUTOMATED_TESTS_ARCHITECTURE }})'
path: ${{ env.ARTIFACTS_STAGING_DIR }}
- name: Install Files
shell: powershell
run: |
Set-Location "$env:APPX_PACKAGE_DIR"
$AppxPackageBundleDir = Get-ChildItem -Filter Files.Package_*_Test -Name
Set-Location $AppxPackageBundleDir
./Install.ps1 -Force
Get-AppxPackage
- name: Set full HD resolution
run: Set-DisplayResolution -Width 1920 -Height 1080 -Force
- name: Start WinAppDriver process
shell: pwsh
run: Start-Process -FilePath "$env:WINAPPDRIVER_EXE86_PATH"
# Retry integration tests if first attempt fails
- name: Run interaction tests
uses: nick-fields/retry@v3
with:
timeout_minutes: 15
max_attempts: 2
shell: pwsh
command: |
dotnet test `
$env:AUTOMATED_TESTS_ASSEMBLY_DIR\**\Files.InteractionTests.dll `
--logger "trx;LogFileName=$env:AUTOMATED_TESTS_ASSEMBLY_DIR\testResults.trx"
- if: github.event_name == 'pull_request'
uses: geekyeggo/delete-artifact@v5
with:
name: '*'
# - name: Generate markdown from the tests result
# shell: pwsh
# run: |
# . './scripts/Convert-TrxToMarkdown.ps1' `
# -Source "$env:AUTOMATED_TESTS_ASSEMBLY_DIR\testResults.trx" `
# -Destination "$env:AUTOMATED_TESTS_ASSEMBLY_DIR\testResults.md"
# env:
# PULL_REQUEST_ID: ${{ github.event.pull_request_id }}
# - name: Display the markdown on the output (temp)
# shell: pwsh
# run: |
# Get-Content $env:AUTOMATED_TESTS_ASSEMBLY_DIR\testResults.md
# - name: Publish tests result
# uses: marocchino/sticky-pull-request-comment@v2
# with:
# header: test-result
# path: '${{ env.AUTOMATED_TESTS_ASSEMBLY_DIR }}\testResults.md'