Files PR Validation #8687
Workflow file for this run
This file contains hidden or 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) Files Community | |
| # Licensed under the MIT 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: 'Files.slnx' | |
| STARTUP_PROJECT_PATH: 'src\Files.App\Files.App.csproj' | |
| APPX_ARTIFACTS_PATH: 'src\Files.App\AppPackages' | |
| AUTOMATED_TESTS_ARCHITECTURE: 'x64' | |
| AUTOMATED_TESTS_CONFIGURATION: 'Release' | |
| AUTOMATED_TESTS_PROJECT_DIR: 'tests\Files.InteractionTests' | |
| AUTOMATED_TESTS_PROJECT_PATH: 'tests\Files.InteractionTests\Files.InteractionTests.csproj' | |
| AUTOMATED_TESTS_ASSEMBLY_DIR: 'artifacts\TestsAssembly' | |
| APPX_SELFSIGNED_CERT_PATH: '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 | |
| 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 | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| global-json-file: global.json | |
| - if: env.CONFIGURATION != env.AUTOMATED_TESTS_CONFIGURATION || env.ARCHITECTURE != env.AUTOMATED_TESTS_ARCHITECTURE | |
| name: Build Files | |
| run: | | |
| . './.github/scripts/Build-AppSolution.ps1' ` | |
| -ReleaseBranch "$env:CONFIGURATION" ` | |
| -SolutionPath "$env:SOLUTION_PATH" ` | |
| -StartupProjectPath "$env:STARTUP_PROJECT_PATH" ` | |
| -Configuration "$env:CONFIGURATION" ` | |
| -Platform "$env:ARCHITECTURE" | |
| - if: env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION && env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE | |
| name: Build and package Files | |
| run: | | |
| # Generate self signing certificate | |
| . './.github/scripts/Generate-SelfCertPfx.ps1' ` | |
| -Destination "$env:APPX_SELFSIGNED_CERT_PATH" | |
| # Restore and build | |
| . './.github/scripts/Build-AppSolution.ps1' ` | |
| -ReleaseBranch "$env:CONFIGURATION" ` | |
| -SolutionPath "$env:SOLUTION_PATH" ` | |
| -StartupProjectPath "$env:STARTUP_PROJECT_PATH" ` | |
| -Configuration "$env:CONFIGURATION" ` | |
| -Platform "$env:ARCHITECTURE" ` | |
| -AppxPackageCertKeyFile "$env:APPX_SELFSIGNED_CERT_PATH" | |
| # Build test project | |
| msbuild ` | |
| $env:AUTOMATED_TESTS_PROJECT_PATH ` | |
| /clp:ErrorsOnly ` | |
| /p:Configuration=$env:CONFIGURATION ` | |
| /p:Platform=$env:ARCHITECTURE | |
| 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.APPX_ARTIFACTS_PATH }} | |
| 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 | |
| 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.APPX_ARTIFACTS_PATH }} | |
| - name: Prepare for the tests | |
| shell: powershell | |
| run: | | |
| Set-Location "$env:APPX_ARTIFACTS_PATH" | |
| $AppxPackageBundleDir = Get-ChildItem -Directory | Where-Object { $_.Name -match '^Files\.App_\d+\.\d+\.\d+\.\d+_Test$' } | Select-Object -First 1 | |
| Set-Location $AppxPackageBundleDir | |
| ./Install.ps1 -Force | |
| Get-AppxPackage | |
| Set-DisplayResolution -Width 1920 -Height 1080 -Force | |
| 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 ` | |
| --test-modules **\Files.InteractionTests.dll ` | |
| --root-directory $env:AUTOMATED_TESTS_ASSEMBLY_DIR ` | |
| --results-directory $env:AUTOMATED_TESTS_ASSEMBLY_DIR | |
| - if: github.event_name == 'pull_request' | |
| uses: geekyeggo/delete-artifact@v5 | |
| with: | |
| name: '*' |