GitHub: Added build CI #25
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2023 Files Community | |
# Licensed under the MIT License. See the LICENSE. | |
# Abstract: | |
# This CI is triggered when a commit was added in the main branch directly or | |
# a commit was added in a PR whose base branch is the main branch within this repository. | |
name: Build & test Files | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- 'docs/**' | |
- '*.md' | |
pull_request: | |
paths-ignore: | |
- 'docs/**' | |
- '*.md' | |
env: | |
APPLICATION_NAME: 'Files' | |
SOLUTION_NAME: 'Files.sln' | |
PRIMARY_ARCHITECTURE: 'x64' | |
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' | |
INTERACTION_TESTS_PROJECT_DIR: '${{ github.workspace }}\tests\Files.InteractionTests' | |
INTERACTION_TESTS_PROJECT_PATH: '${{ github.workspace }}\tests\Files.InteractionTests\Files.InteractionTests.csproj' | |
WORKING_DIR: ${{ github.workspace }} # Default: 'D:\a\Files\Files' | |
ARTIFACTS_STAGING_DIR: ${{ github.workspace }}\artifacts | |
APPX_PACKAGE_DIR: ${{ github.workspace }}\artifacts\AppxPackages | |
APPX_SELFSIGNED_CERT_PATH: '${{ github.workspace }}\builds\Files_SelfSigned.pfx' | |
jobs: | |
build: | |
runs-on: windows-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
configuration: [Debug] | |
platform: [x64, arm64] | |
env: | |
CONFIGURATION: ${{ matrix.configuration }} | |
ARCHITECTURE: ${{ matrix.platform }} | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
- name: Setup MSBuild | |
uses: microsoft/setup-msbuild@v1 | |
- name: Setup NuGet | |
uses: NuGet/[email protected] | |
- name: Setup .NET 7 | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '7.0.x' | |
- 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.ARCHITECTURE != env.PRIMARY_ARCHITECTURE | |
name: Build Files | |
run: | | |
msbuild $env:PACKAGE_PROJECT_PATH ` | |
-t:Build ` | |
-p:Configuration=$env:CONFIGURATION ` | |
-p:Platform=$env:ARCHITECTURE ` | |
-p:AppxBundle=Never | |
- if: env.ARCHITECTURE == env.PRIMARY_ARCHITECTURE | |
name: Build & Publish Files | |
run: | | |
msbuild $env:PACKAGE_PROJECT_PATH ` | |
-t:Build ` | |
-t:_GenerateAppxPackage ` | |
-p:Configuration=$env:CONFIGURATION ` | |
-p:Platform=$env:ARCHITECTURE ` | |
-p:AppxBundlePlatforms=$env:PRIMARY_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.PRIMARY_ARCHITECTURE | |
name: Upload the packages to GitHub Actions | |
uses: actions/upload-artifact@v3 | |
with: | |
name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.PRIMARY_ARCHITECTURE }})' | |
path: ${{ env.ARTIFACTS_STAGING_DIR }} | |
test: | |
needs: [build] | |
runs-on: windows-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
configuration: [Debug] | |
platform: [x64] | |
env: | |
CONFIGURATION: ${{ matrix.configuration }} | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
- name: Setup MSBuild | |
uses: microsoft/setup-msbuild@v1 | |
- name: Setup NuGet | |
uses: NuGet/[email protected] | |
- name: Setup .NET 7 | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '7.0.x' | |
- uses: actions/download-artifact@v3 | |
with: | |
name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.PRIMARY_ARCHITECTURE }})' | |
path: ${{ env.ARTIFACTS_STAGING_DIR }} | |
- name: Install package | |
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 | |
run: Start-Process -FilePath "C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe" | |
- name: Restore NuGet | |
shell: pwsh | |
run: 'nuget restore $env:SOLUTION_PATH' | |
- name: Build interaction tests | |
run: | | |
msbuild $env:INTERACTION_TESTS_PROJECT_PATH ` | |
-t:Build ` | |
-p:Configuration=$env:CONFIGURATION ` | |
-p:Platform=$env:PRIMARY_ARCHITECTURE | |
- name: Run interaction tests | |
run: | | |
dotnet test $env:INTERACTION_TESTS_PROJECT_DIR\bin\**\Files.InteractionTests.dll ` | |
-a $env:PRIMARY_ARCHITECTURE ` | |
-c $env:CONFIGURATION |