Skip to content

Commit d23b0b3

Browse files
authored
GitHub: Added build CI (#13620)
1 parent cf13063 commit d23b0b3

File tree

7 files changed

+492
-174
lines changed

7 files changed

+492
-174
lines changed

.github/workflows/check-xaml-formatting.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
# Copyright (c) 2023 Files Community
2+
# Licensed under the MIT License. See the LICENSE.
3+
4+
# Abstract:
5+
# - This CI is executed when a new commit is created on the main branch or
6+
# on a PR whose head branch is the main branch.
7+
# - However, the CI will not be executed if files not directly related to
8+
# source code maintenance are updated.
9+
10+
name: Files CI
11+
12+
on:
13+
push:
14+
branches:
15+
- main
16+
paths-ignore:
17+
- 'specs/**'
18+
- '*.md'
19+
pull_request:
20+
paths-ignore:
21+
- 'specs/**'
22+
- '*.md'
23+
24+
run-name: ${{ github.event_name == 'pull_request' && 'Files PR Validation' || 'Files CI Validation' }}
25+
26+
env:
27+
WORKING_DIR: ${{ github.workspace }} # Default: 'D:\a\Files\Files'
28+
SOLUTION_PATH: '${{ github.workspace }}\Files.sln'
29+
PACKAGE_PROJECT_DIR: '${{ github.workspace }}\src\Files.App (Package)'
30+
PACKAGE_PROJECT_PATH: '${{ github.workspace }}\src\Files.App (Package)\Files.Package.wapproj'
31+
AUTOMATED_TESTS_ARCHITECTURE: 'x64'
32+
AUTOMATED_TESTS_CONFIGURATION: 'Release'
33+
AUTOMATED_TESTS_PROJECT_DIR: '${{ github.workspace }}\tests\Files.InteractionTests'
34+
AUTOMATED_TESTS_PROJECT_PATH: '${{ github.workspace }}\tests\Files.InteractionTests\Files.InteractionTests.csproj'
35+
AUTOMATED_TESTS_ASSEMBLY_DIR: '${{ github.workspace }}\artifacts\TestsAssembly'
36+
ARTIFACTS_STAGING_DIR: '${{ github.workspace }}\artifacts'
37+
APPX_PACKAGE_DIR: '${{ github.workspace }}\artifacts\AppxPackages'
38+
APPX_SELFSIGNED_CERT_PATH: '${{ github.workspace }}\.github\workflows\FilesApp_SelfSigned.pfx'
39+
WINAPPDRIVER_EXE86_PATH: 'C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe'
40+
WINAPPDRIVER_EXE64_PATH: 'C:\Program Files\Windows Application Driver\WinAppDriver.exe'
41+
42+
jobs:
43+
44+
check-formatting:
45+
runs-on: ubuntu-latest
46+
defaults:
47+
run:
48+
shell: pwsh
49+
50+
steps:
51+
52+
- name: Checkout the repository
53+
uses: actions/checkout@v3
54+
with:
55+
fetch-depth: 2
56+
57+
- name: Install XamlStyler console
58+
run: 'dotnet tool install --global XamlStyler.Console'
59+
60+
- name: Check XAML formatting
61+
id: check-step
62+
run: |
63+
$changedFiles = (git diff --name-only HEAD~1) -split "\n" | Where-Object {$_ -like "*.xaml"}
64+
foreach ($file in $changedFiles)
65+
{
66+
xstyler -p -l None -f $file
67+
if ($LASTEXITCODE -ne 0)
68+
{
69+
echo "::error file=$file::Format check failed"
70+
}
71+
}
72+
continue-on-error: true
73+
74+
- name: Fail the job if the XamlStyler found unformatted file(s)
75+
if: steps.check-step.outcome == 'failure'
76+
run: exit 1
77+
78+
build:
79+
runs-on: windows-latest
80+
strategy:
81+
fail-fast: false
82+
matrix:
83+
configuration: [Debug, Release]
84+
platform: [x64, arm64]
85+
env:
86+
CONFIGURATION: ${{ matrix.configuration }}
87+
ARCHITECTURE: ${{ matrix.platform }}
88+
89+
steps:
90+
91+
- name: Checkout the repository
92+
uses: actions/checkout@v3
93+
94+
- name: Setup MSBuild
95+
uses: microsoft/setup-msbuild@v1
96+
97+
- name: Setup NuGet
98+
uses: NuGet/[email protected]
99+
100+
- name: Setup .NET 7
101+
uses: actions/setup-dotnet@v3
102+
with:
103+
dotnet-version: '7.0.x'
104+
105+
- name: Restore NuGet
106+
shell: pwsh
107+
run: 'nuget restore $env:SOLUTION_PATH'
108+
109+
- name: Restore Files
110+
shell: pwsh
111+
run: |
112+
msbuild $env:SOLUTION_PATH `
113+
-t:Restore `
114+
-p:Platform=$env:ARCHITECTURE `
115+
-p:Configuration=$env:CONFIGURATION `
116+
-p:PublishReadyToRun=true
117+
118+
- if: env.CONFIGURATION != env.AUTOMATED_TESTS_CONFIGURATION || env.ARCHITECTURE != env.AUTOMATED_TESTS_ARCHITECTURE
119+
name: Build Files
120+
run: |
121+
msbuild `
122+
$env:PACKAGE_PROJECT_PATH `
123+
-t:Build `
124+
-clp:ErrorsOnly `
125+
-p:Configuration=$env:CONFIGURATION `
126+
-p:Platform=$env:ARCHITECTURE `
127+
-p:AppxBundle=Never
128+
129+
- if: env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION && env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE
130+
name: Create self signed cert as a pfx file
131+
run: ./scripts/Generate-SelfCertPfx.ps1 -Destination "$env:APPX_SELFSIGNED_CERT_PATH"
132+
133+
- if: env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION && env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE
134+
name: Build & package Files
135+
run: |
136+
msbuild `
137+
$env:PACKAGE_PROJECT_PATH `
138+
-t:Build `
139+
-t:_GenerateAppxPackage `
140+
-clp:ErrorsOnly `
141+
-p:Configuration=$env:CONFIGURATION `
142+
-p:Platform=$env:ARCHITECTURE `
143+
-p:AppxBundlePlatforms=$env:AUTOMATED_TESTS_ARCHITECTURE `
144+
-p:AppxBundle=Always `
145+
-p:UapAppxPackageBuildMode=SideloadOnly `
146+
-p:AppxPackageDir=$env:APPX_PACKAGE_DIR `
147+
-p:AppxPackageSigningEnabled=true `
148+
-p:PackageCertificateKeyFile=$env:APPX_SELFSIGNED_CERT_PATH `
149+
-p:PackageCertificatePassword="" `
150+
-p:PackageCertificateThumbprint=""
151+
152+
- if: env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE && env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION
153+
name: Build interaction tests
154+
run: |
155+
msbuild $env:AUTOMATED_TESTS_PROJECT_PATH `
156+
-t:Build `
157+
-clp:ErrorsOnly `
158+
-p:Configuration=$env:CONFIGURATION `
159+
-p:Platform=$env:AUTOMATED_TESTS_ARCHITECTURE
160+
161+
- if: env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE && env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION
162+
name: Copy tests bin to the artifacts dir
163+
shell: pwsh
164+
run: |
165+
Copy-Item `
166+
-Path "$env:AUTOMATED_TESTS_PROJECT_DIR\bin" `
167+
-Destination "$env:AUTOMATED_TESTS_ASSEMBLY_DIR" -Recurse
168+
169+
- if: env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE && env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION
170+
name: Upload the packages to the Artifacts
171+
uses: actions/upload-artifact@v3
172+
with:
173+
name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.ARCHITECTURE }})'
174+
path: ${{ env.ARTIFACTS_STAGING_DIR }}
175+
176+
test:
177+
needs: [build]
178+
runs-on: windows-latest
179+
strategy:
180+
fail-fast: false
181+
matrix:
182+
configuration: [Release]
183+
platform: [x64]
184+
env:
185+
CONFIGURATION: ${{ matrix.configuration }}
186+
permissions:
187+
contents: read
188+
pull-requests: write
189+
190+
steps:
191+
192+
- name: Checkout the repository
193+
uses: actions/checkout@v3
194+
195+
- name: Download the packages from the Artifacts
196+
uses: actions/download-artifact@v3
197+
with:
198+
name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.AUTOMATED_TESTS_ARCHITECTURE }})'
199+
path: ${{ env.ARTIFACTS_STAGING_DIR }}
200+
201+
- name: Install Files
202+
shell: powershell
203+
run: |
204+
Set-Location "$env:APPX_PACKAGE_DIR"
205+
$AppxPackageBundleDir = Get-ChildItem -Filter Files.Package_*_Test -Name
206+
Set-Location $AppxPackageBundleDir
207+
./Install.ps1 -Force
208+
Get-AppxPackage
209+
210+
- name: Set full HD resolution
211+
run: Set-DisplayResolution -Width 1920 -Height 1080 -Force
212+
213+
- name: Start WinAppDriver process
214+
shell: pwsh
215+
run: Start-Process -FilePath "$env:WINAPPDRIVER_EXE86_PATH"
216+
217+
- name: Run interaction tests
218+
run: |
219+
dotnet test `
220+
$env:AUTOMATED_TESTS_ASSEMBLY_DIR\**\Files.InteractionTests.dll `
221+
--logger "trx;LogFileName=$env:AUTOMATED_TESTS_ASSEMBLY_DIR\testResults.trx"
222+
223+
# - name: Generate markdown from the tests result
224+
# shell: pwsh
225+
# run: |
226+
# . './scripts/Convert-TrxToMarkdown.ps1' `
227+
# -Source "$env:AUTOMATED_TESTS_ASSEMBLY_DIR\testResults.trx" `
228+
# -Destination "$env:AUTOMATED_TESTS_ASSEMBLY_DIR\testResults.md"
229+
# env:
230+
# PULL_REQUEST_ID: ${{ github.event.pull_request_id }}
231+
232+
# - name: Display the markdown on the output (temp)
233+
# shell: pwsh
234+
# run: |
235+
# Get-Content $env:AUTOMATED_TESTS_ASSEMBLY_DIR\testResults.md
236+
237+
# - name: Publish tests result
238+
# uses: marocchino/sticky-pull-request-comment@v2
239+
# with:
240+
# header: test-result
241+
# path: '${{ env.AUTOMATED_TESTS_ASSEMBLY_DIR }}\testResults.md'

builds/Files_SelfSigned.pfx

-2.47 KB
Binary file not shown.

0 commit comments

Comments
 (0)