diff --git a/.github/scripts/Build-AppSolution.ps1 b/.github/scripts/Build-AppSolution.ps1 new file mode 100644 index 000000000000..b781c02bc234 --- /dev/null +++ b/.github/scripts/Build-AppSolution.ps1 @@ -0,0 +1,94 @@ +# Copyright (c) Files Community +# Licensed under the MIT License. + +param( + [string]$ReleaseBranch = "Debug", # Debug, Release, SideloadPreview, SideloadStable, StorePreview, or StoreStable + [string]$SolutionPath = "Files.slnx", + [string]$StartupProjectPath = "", + [string]$Platform = "x64", + [string]$Configuration = "Debug", + [string]$AppxBundlePlatforms = "x64|arm64", + [string]$AppxPackageDir = "", + [string]$AppInstallerUrl = "", # Sideload only + [string]$AppxPackageCertKeyFile = "" # Debug only +) + +# Restore the solution +msbuild $SolutionPath /t:Restore /p:Platform=$Platform /p:Configuration=$Configuration /p:PublishReadyToRun=true + +if ($ReleaseBranch -eq "Debug") +{ + msbuild $StartupProjectPath ` + /t:Build ` + /clp:ErrorsOnly ` + /p:Platform=$Platform ` + /p:Configuration=$Configuration ` + /p:AppxBundle=Never ` + /v:quiet +} +elseif ($ReleaseBranch -eq "Release") +{ + if ($Platform -eq "x64") + { + msbuild $StartupProjectPath ` + /t:Build ` + /clp:ErrorsOnly ` + /p:Platform=$Platform ` + /p:Configuration=$Configuration ` + /p:AppxBundlePlatforms=$Platform ` + /p:AppxBundle=Always ` + /p:UapAppxPackageBuildMode=SideloadOnly ` + /p:AppxPackageDir=$AppxPackageDir ` + /p:AppxPackageSigningEnabled=true ` + /p:PackageCertificateKeyFile=$AppxPackageCertKeyFile ` + /p:PackageCertificatePassword="" ` + /p:PackageCertificateThumbprint="" ` + /v:quiet + } + else + { + msbuild $StartupProjectPath ` + /t:Build ` + /clp:ErrorsOnly ` + /p:Platform=$Platform ` + /p:Configuration=$Configuration ` + /p:AppxBundle=Never ` + /v:quiet + } +} +elseif ($ReleaseBranch -contains "Sideload") +{ + msbuild $StartupProjectPath ` + /t:Build ` + /t:_GenerateAppxPackage ` + /clp:ErrorsOnly ` + /p:Platform=$Platform ` + /p:Configuration=$Configuration ` + /p:AppxBundlePlatforms=$AppxBundlePlatforms ` + /p:AppxPackageDir=$AppxPackageDir ` + /p:AppxBundle=Always ` + /p:UapAppxPackageBuildMode=Sideload ` + /p:GenerateAppInstallerFile=True ` + /p:AppInstallerUri=$AppInstallerUrl ` + /v:quiet + + $newSchema = 'http://schemas.microsoft.com/appx/appinstaller/2018' + $localFilePath = '$AppxPackageDir/Files.Package.appinstaller' + $fileContent = Get-Content $localFilePath + $fileContent = $fileContent.Replace('http://schemas.microsoft.com/appx/appinstaller/2017/2', $newSchema) + $fileContent | Set-Content $localFilePath +} +elseif ($ReleaseBranch -contains "Store") +{ + msbuild $StartupProjectPath ` + /t:Build ` + /t:_GenerateAppxPackage ` + /clp:ErrorsOnly ` + /p:Platform=$Platform ` + /p:Configuration=$Configuration ` + /p:AppxBundlePlatforms=$AppxBundlePlatforms ` + /p:AppxPackageDir=$AppxPackageDir ` + /p:AppxBundle=Always ` + /p:UapAppxPackageBuildMode=StoreUpload ` + /v:quiet +} diff --git a/.github/scripts/Configure-AppxManifest.ps1 b/.github/scripts/Configure-AppxManifest.ps1 index 4140bccc38df..23ec48ffa58c 100644 --- a/.github/scripts/Configure-AppxManifest.ps1 +++ b/.github/scripts/Configure-AppxManifest.ps1 @@ -2,12 +2,12 @@ # Licensed under the MIT License. param( - [string]$Branch = "", # This has to correspond with one of the AppEnvironment enum values - [string]$PackageManifestPath = "", - [string]$Publisher = "", - [string]$WorkingDir = "", - [string]$SecretBingMapsKey = "", - [string]$SecretSentry = "", + [string]$Branch = "", # SideloadPreview, SideloadStable, StorePreview, or StoreStable + [string]$PackageManifestPath = "", + [string]$Publisher = "", + [string]$WorkingDir = "", + [string]$SecretBingMapsKey = "", + [string]$SecretSentry = "", [string]$SecretGitHubOAuthClientId = "" ) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9234b5c8ccf1..d0378d3e25da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,20 +28,20 @@ on: 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.slnx' - 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' + WORKING_DIR: '${{ github.workspace }}' # Default: 'D:\a\Files\Files' + SOLUTION_PATH: '${{ github.workspace }}\Files.slnx' + PACKAGE_PROJECT_DIR: '${{ github.workspace }}\src\Files.App (Package)' + PACKAGE_PROJECT_PATH: '${{ github.workspace }}\src\Files.App (Package)\Files.Package.wapproj' + AUTOMATED_TESTS_PLATFORM: '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' + 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: @@ -93,7 +93,7 @@ jobs: platform: [x64, arm64] env: CONFIGURATION: ${{ matrix.configuration }} - ARCHITECTURE: ${{ matrix.platform }} + PLATFORM: ${{ matrix.platform }} steps: @@ -108,72 +108,49 @@ jobs: with: global-json-file: global.json - - name: Restore Files - shell: pwsh - run: | - msbuild $env:SOLUTION_PATH ` - -t:Restore ` - -p:Platform=$env:ARCHITECTURE ` - -p:Configuration=$env:CONFIGURATION ` - -p:PublishReadyToRun=true ` - -v:quiet - - - if: env.CONFIGURATION != env.AUTOMATED_TESTS_CONFIGURATION || env.ARCHITECTURE != env.AUTOMATED_TESTS_ARCHITECTURE + - if: env.CONFIGURATION != env.AUTOMATED_TESTS_CONFIGURATION || env.PLATFORM != env.AUTOMATED_TESTS_PLATFORM name: Build Files run: | - msbuild ` - $env:PACKAGE_PROJECT_PATH ` - -t:Build ` - -p:Configuration=$env:CONFIGURATION ` - -p:Platform=$env:ARCHITECTURE ` - -p:AppxBundle=Never ` - -v:quiet - - - 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 + . './.github/scripts/Build-AppSolution.ps1' ` + -ReleaseBranch "$env:CONFIGURATION" ` + -SolutionPath "$env:SOLUTION_PATH" ` + -StartupProjectPath "$env:PACKAGE_PROJECT_PATH" ` + -Configuration "$env:CONFIGURATION" ` + -Platform "$env:PLATFORM" + + - if: env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION && env.PLATFORM == env.AUTOMATED_TESTS_PLATFORM + 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:PACKAGE_PROJECT_PATH" ` + -Configuration "$env:CONFIGURATION" ` + -Platform "$env:PLATFORM" ` + -AppxBundlePlatforms "$env:PLATFORM" ` + -AppxPackageDir "$env:APPX_PACKAGE_DIR" ` + -AppxPackageCertKeyFile "$env:APPX_SELFSIGNED_CERT_PATH" + # Build test project msbuild ` - $env:PACKAGE_PROJECT_PATH ` - -t:Build ` - -t:_GenerateAppxPackage ` - -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="" ` - -v:quiet - - - 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 ` - -p:Configuration=$env:CONFIGURATION ` - -p:Platform=$env:AUTOMATED_TESTS_ARCHITECTURE ` - -v:quiet - - - if: env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE && env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION - name: Copy tests bin to the artifacts dir - shell: pwsh - run: | + $env:AUTOMATED_TESTS_PROJECT_PATH ` + /t:Build ` + /clp:ErrorsOnly ` + /p:Configuration=$env:CONFIGURATION ` + /p:Platform=$env:PLATFORM Copy-Item ` - -Path "$env:AUTOMATED_TESTS_PROJECT_DIR\bin" ` - -Destination "$env:AUTOMATED_TESTS_ASSEMBLY_DIR" -Recurse + -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 + - if: env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION && env.PLATFORM == env.AUTOMATED_TESTS_PLATFORM + name: Upload the packages to GitHub Actions uses: actions/upload-artifact@v4 with: - name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.ARCHITECTURE }})' + name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.PLATFORM }})' path: ${{ env.ARTIFACTS_STAGING_DIR }} test: @@ -189,6 +166,7 @@ jobs: platform: [x64] env: CONFIGURATION: ${{ matrix.configuration }} + PLATFORM: ${{ matrix.platform }} permissions: contents: read pull-requests: write @@ -209,10 +187,10 @@ jobs: - name: Download the packages from the Artifacts uses: actions/download-artifact@v4 with: - name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.AUTOMATED_TESTS_ARCHITECTURE }})' + name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.PLATFORM }})' path: ${{ env.ARTIFACTS_STAGING_DIR }} - - name: Install Files + - name: Prepare for the tests shell: powershell run: | Set-Location "$env:APPX_PACKAGE_DIR" @@ -220,13 +198,8 @@ jobs: 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" + 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 @@ -244,23 +217,3 @@ jobs: 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'