Skip to content

GitHub: Added build CI #11

GitHub: Added build CI

GitHub: Added build CI #11

Workflow file for this run

# 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'
PACKAGE_PROJECT_DIR: 'src\Files.App (Package)'
PACKAGE_PROJECT_PATH: 'src\Files.App (Package)\Files.Package.wapproj'
TEST_PROJECT_PATH: '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_NAME'
- name: Restore Files
shell: pwsh
run: |
msbuild $env:SOLUTION_NAME `
-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:
- uses: actions/download-artifact@v3
with:
name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.PRIMARY_ARCHITECTURE }})'
path: ${{ env.ARTIFACTS_STAGING_DIR }}
- name: Install package
shell: pwsh
run: |
Set-Location "$env:APPX_PACKAGE_DIR"
$AppxPackageBundleDir = Get-ChildItem -Filter Files.Package_*_Test -Name
Set-Location $AppxPackageBundleDir
Import-Module Appx
./Install.ps1 -Force
Get-AppxPackage
- name: Set full HD resolution
run: Set-DisplayResolution -Width 1920 -Height 1080 -Force
- name: Run UI tests
run: dotnet test