From d23b0b37e0c3240887776bca26a959b32af92d40 Mon Sep 17 00:00:00 2001 From: 0x5bfa <62196528+0x5bfa@users.noreply.github.com> Date: Fri, 10 Nov 2023 23:29:19 +0900 Subject: [PATCH] GitHub: Added build CI (#13620) --- .github/workflows/check-xaml-formatting.yml | 49 ---- .github/workflows/ci.yml | 241 ++++++++++++++++++ builds/Files_SelfSigned.pfx | Bin 2528 -> 0 bytes builds/azure-pipelines.yml | 122 --------- scripts/Convert-TrxToMarkdown.ps1 | 219 ++++++++++++++++ scripts/Generate-SelfCertPfx.ps1 | 28 ++ .../Files.InteractionTests/SessionManager.cs | 7 +- 7 files changed, 492 insertions(+), 174 deletions(-) delete mode 100644 .github/workflows/check-xaml-formatting.yml create mode 100644 .github/workflows/ci.yml delete mode 100644 builds/Files_SelfSigned.pfx delete mode 100644 builds/azure-pipelines.yml create mode 100644 scripts/Convert-TrxToMarkdown.ps1 create mode 100644 scripts/Generate-SelfCertPfx.ps1 diff --git a/.github/workflows/check-xaml-formatting.yml b/.github/workflows/check-xaml-formatting.yml deleted file mode 100644 index 44b034176ff3..000000000000 --- a/.github/workflows/check-xaml-formatting.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Check XAML Formatting -on: - workflow_dispatch: - push: - branches: - - 'main' - - 'service/**' - paths: - - '**.xaml' - pull_request: - branches: - - 'main' - - 'service/**' - paths: - - '**.xaml' - -jobs: - check-formatting: - runs-on: ubuntu-latest - defaults: - run: - shell: pwsh - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 2 - - - name: Install Xaml Styler - run: | - dotnet tool install --global XamlStyler.Console - - - name: Check Formatting - id: check-step - run: | - $changedFiles = (git diff --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 job if necessary - if: steps.check-step.outcome == 'failure' - run: exit 1 - diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000000..6d71c68f3d7c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,241 @@ +# Copyright (c) 2023 Files Community +# Licensed under the MIT License. See the 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: + - 'specs/**' + - '*.md' + pull_request: + paths-ignore: + - 'specs/**' + - '*.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: '${{ 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' + AUTOMATED_TESTS_ARCHITECTURE: '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' + +jobs: + + check-formatting: + runs-on: ubuntu-latest + defaults: + run: + shell: pwsh + + steps: + + - name: Checkout the repository + uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - name: Install XamlStyler console + run: 'dotnet tool install --global XamlStyler.Console' + + - name: Check XAML formatting + id: check-step + run: | + $changedFiles = (git diff --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 the job if the XamlStyler found unformatted file(s) + if: steps.check-step.outcome == 'failure' + run: exit 1 + + build: + 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@v3 + + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v1 + + - name: Setup NuGet + uses: NuGet/setup-nuget@v1.1.1 + + - 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.CONFIGURATION != env.AUTOMATED_TESTS_CONFIGURATION || env.ARCHITECTURE != env.AUTOMATED_TESTS_ARCHITECTURE + name: Build Files + run: | + msbuild ` + $env:PACKAGE_PROJECT_PATH ` + -t:Build ` + -clp:ErrorsOnly ` + -p:Configuration=$env:CONFIGURATION ` + -p:Platform=$env:ARCHITECTURE ` + -p:AppxBundle=Never + + - if: env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION && env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE + name: Create self signed cert as a pfx file + run: ./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 + run: | + msbuild ` + $env:PACKAGE_PROJECT_PATH ` + -t:Build ` + -t:_GenerateAppxPackage ` + -clp:ErrorsOnly ` + -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="" + + - 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 ` + -clp:ErrorsOnly ` + -p:Configuration=$env:CONFIGURATION ` + -p:Platform=$env:AUTOMATED_TESTS_ARCHITECTURE + + - if: env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE && env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION + name: Copy tests bin to the artifacts dir + shell: pwsh + run: | + 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@v3 + with: + name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.ARCHITECTURE }})' + path: ${{ env.ARTIFACTS_STAGING_DIR }} + + test: + 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: + + - name: Checkout the repository + uses: actions/checkout@v3 + + - name: Download the packages from the Artifacts + uses: actions/download-artifact@v3 + with: + name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.AUTOMATED_TESTS_ARCHITECTURE }})' + path: ${{ env.ARTIFACTS_STAGING_DIR }} + + - name: Install Files + 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 process + shell: pwsh + run: Start-Process -FilePath "$env:WINAPPDRIVER_EXE86_PATH" + + - name: Run interaction tests + run: | + dotnet test ` + $env:AUTOMATED_TESTS_ASSEMBLY_DIR\**\Files.InteractionTests.dll ` + --logger "trx;LogFileName=$env:AUTOMATED_TESTS_ASSEMBLY_DIR\testResults.trx" + + # - 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' diff --git a/builds/Files_SelfSigned.pfx b/builds/Files_SelfSigned.pfx deleted file mode 100644 index ad8719910d5b19be2eec5d8611a231500cc05ad7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2528 zcmZXUc{tQ-8^?dcFpYf}`>yQAX)tyP8HvblkUg>+${JxtlSxIklM>+&S<~2=Y$Yb* zC|R>4Lm1glyv+OSTvAg3_R2B)-`ulX+T1!#onu|Q zNFus5@nqU#eIuWH#(8(P6~jftC6@0@W{3BQ?~{=ZvdF}){*pl<^G-Q2=Lmj)!VMr(4vf=yCJlOl zDv!I;kH(I<0o)Bi!)*kU>kZ3921=!?{_*4&f`}5Pfk?U^UBWpopP_v7e3N9m|3OG_ z2v=#T?%o}4g^0l_e~RvL2<7sgUI3=)HI!jtC%vT29)pT?Ik7uMF|G9;53wIlh*o5g zn>=B(@j*(N|6_V}$uqs~dCE{zbH|6O9h7tdS8scE+B&SmBu^< z39*my_kqZl5gw(POwC0kx1-f`pn3db51T6W+J)Ndw(}HW^M$J;hZojv=x)U-e8 zQ899SZ1+xkxrpanP~)?leFZ3dk3Q;tiy^AEIuis?dPT0Eb@lT~SM{OyCJI_~O9N#b zVo;tk-=|&pR1rb87vr<1EjaT}5{i4nXws4^`R_{LH5{j=Y|1AI+pfu{G+XFo+SQY1 zt9oA1kgz6X06Q)_S%_=hD0^OO7EbAzIr*(Ris`6YLRLZJKQAY)~#;Vz^g^X+Y zx5^4O9&*q87CID~&{lqZj;49HaW_t5m`|9QT_?e}W4d4adDmgv8IwyDR!4L1`)=77 zm-QK~ODZAn4BA*a9 z>r`_#bSYFmo{HQTyA12QGoA}}zv0bO@nfM6*SrP??_M>A?hQYo-U=&v%`yKjVoSj| zDJ(8$j765NTUB&!7qDujlJ$RqOjlI1>C!YEG9g-Pzc&L>MYq{o$&FklG7}n=+b_SD z>1S+BCqHt#U0D;*m7-IlpDmpF`|7Z|${C7B=Jez`1h-eOhpvo>EqT#3p6=L44@rwg ztU3vvKW%wZ!>3bv#B|OlwGo@8StYpx9d@~*SjCFH zg?2@lPF7Mpa4eS%$EENRu$!anEICoNL5Z9zbmx{i2gU%dZs}5rlmE+r%=0@P5?AJ= z)9ZNn&bCsnZm3b~vM$`v?JDpOPDdz?n48J!nfjqZBDnCZasA%!)+Wz4VyL(>zs1eD z^_0)O0`?r5u61nH)Vk#O}GAtAxQCl?lvEvEop zxYRTgTzz%_kAb}rt7RiagMn@*X4@vk$;e27sA9=Lfv|afl%W;R9qDowRu^7Dq8*4=Q3{&0bNOz0;rcilhCz8iqf&SydPyW zyS6MO^SHL6M$;?S-=DmveBh{!!oI%tP8=%8ySEwBx3 zC{1)FV*t13X;$|5$R^@qQU_Xn{>?8X^us*I#m32_KS%kIV<@dy!WcyIQ-9%0pY2;p^QzY+^5&0o&_NdBoEVe!vo8UyVofz+xB6nayZnC z*3QN#WK79@UGHyD>diHGAd5feG`)6|%0(M^|L7#aL%zG&N%BEHHK zAazR~((#`@t|`x3-BF=YY%)Qh!E0#iabQ#85Zy+YNJc7tip8%d`#9)fcHHy9KB z3}j9~kYe**5Q6{G@8_weIh@>Twb^HC$CMqOwz7XUSIaF6h4<)Fhq37IHU%mNLIONa zJKAwuA5W4jj&=l=Y?<*E>p8)aSV7r#T)ALf!4Eg_xvE(|8zRA``Vowu(S4gG^9FIO z7fuqjV>05Z;Nuk4nGlRo{h|7Pp7Tv_2OXt{l0?B+S(Le$nM9yS`76A{hQ&>e~q4|7WZ diff --git a/builds/azure-pipelines.yml b/builds/azure-pipelines.yml deleted file mode 100644 index d117f2d60c12..000000000000 --- a/builds/azure-pipelines.yml +++ /dev/null @@ -1,122 +0,0 @@ -trigger: -- main - -pool: - vmImage: 'windows-latest' - -variables: - solution: '**/*.sln' - buildPlatform: 'x64' - buildConfiguration: 'Release' - appxPackageDir: '$(build.artifactStagingDirectory)\AppxPackages\\' - -steps: -- task: PowerShell@2 - inputs: - targetType: 'inline' - script: | - [xml]$xmlDoc = Get-Content '$(Build.SourcesDirectory)\src\Files.App (Package)\Package.appxmanifest' - $xmlDoc.Package.Identity.Name="49306atecsolution.FilesUWP" - $xmlDoc.Package.Identity.Publisher="CN=53EC4384-7F5B-4CF6-8C23-513FFE9D1AB7" - $xmlDoc.Package.Properties.DisplayName="Files" - $xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files" - $xmlDoc.Save('$(Build.SourcesDirectory)\src\Files.App (Package)\Package.appxmanifest') - failOnStderr: true - -- task: PowerShell@2 - displayName: 'Use Release Logo' - inputs: - targetType: 'inline' - script: | - gci $(Build.SourcesDirectory)\src -Include *.csproj, *.appxmanifest, *.wapproj -recurse | ForEach -Process { - (Get-Content $_ -Raw | ForEach -Process {$_ -replace "Assets\\AppTilesDev", "Assets\AppTiles"}) | Set-Content $_ -NoNewline - } - failOnStderr: true - -- task: DownloadSecureFile@1 - name: mapsDevKey - displayName: 'Download Bing Maps Dev Key' - inputs: - secureFile: 'BingMapsKey.txt' - -- task: CopyFiles@2 - inputs: - SourceFolder: '$(Agent.TempDirectory)' - Contents: '$(mapsDevKey.secureFilePath)' - TargetFolder: '$(Build.SourcesDirectory)\src\Files.App\Resources' - overWrite: true - -- task: UseDotNet@2 - inputs: - packageType: sdk - version: 7.0.x - includePreviewVersions: true - -- task: CmdLine@2 - inputs: - script: | - for /f %%a in ('dir /b /a:d %localappdata%\Microsoft\VisualStudio\17*') do echo UsePreviews=True>%localappdata%\Microsoft\VisualStudio\%%a\sdk.txt - -- task: MSBuild@1 - inputs: - platform: 'x64' - solution: '**/*.sln' - configuration: '$(buildConfiguration)' - msbuildArguments: '/t:restore /p:Configuration=Debug;Platform="$(buildPlatform)";PublishReadyToRun=true' - maximumCpuCount: true - -- task: MSBuild@1 - inputs: - platform: 'x64' - solution: '**/*.wapproj' - configuration: '$(buildConfiguration)' - msbuildArguments: '/t:build;_GenerateAppxPackage /p:Configuration=Debug;Platform="$(buildPlatform)";AppxBundle=Always;AppxBundlePlatforms="$(buildPlatform)";AppxPackageDir="$(appxPackageDir)";AppxPackageSigningEnabled=true;UapAppxPackageBuildMode=SideloadOnly;PackageCertificateKeyFile="$(Build.SourcesDirectory)\builds\Files_SelfSigned.pfx";PackageCertificatePassword="";PackageCertificateThumbprint=""' - maximumCpuCount: true - -- task: DotNetCoreCLI@2 - inputs: - command: 'build' - arguments: './tests/Files.InteractionTests/Files.InteractionTests.csproj --configuration $(buildConfiguration)' - -- task: PowerShell@2 - inputs: - targetType: 'inline' - script: | - # Find correct folder and run app install script. - cd $(appxPackageDir) - - $AppBundle = Get-ChildItem -Filter Files*Test -Name - echo $AppBundle - cd $AppBundle - ./Install.ps1 -Force - Get-AppxPackage - errorActionPreference: 'continue' - failOnStderr: true - workingDirectory: '$(System.DefaultWorkingDirectory)' - - -- task: Windows Application Driver@0 - inputs: - OperationType: 'Start' - AgentResolution: '1080p' - -- task: VSTest@2 - inputs: - testSelector: 'testAssemblies' - testAssemblyVer2: | - **\*Files.InteractionTests.dll - !**\*TestAdapter.dll - !**\obj\** - searchFolder: '$(System.DefaultWorkingDirectory)' - -- task: CopyFiles@2 - displayName: 'Copy Files to: $(build.artifactstagingdirectory)' - inputs: - SourceFolder: '$(system.defaultworkingdirectory)' - Contents: '**\bin\$(BuildConfiguration)\**' - TargetFolder: '$(build.artifactstagingdirectory)' - -- task: PublishBuildArtifacts@1 - displayName: 'Publish Artifact: drop' - inputs: - PathtoPublish: '$(build.artifactstagingdirectory)' diff --git a/scripts/Convert-TrxToMarkdown.ps1 b/scripts/Convert-TrxToMarkdown.ps1 new file mode 100644 index 000000000000..3c21ebf14dde --- /dev/null +++ b/scripts/Convert-TrxToMarkdown.ps1 @@ -0,0 +1,219 @@ +# Copyright (c) 2023 Files Community +# Licensed under the MIT License. See the LICENSE. + +# Abstract: +# This script analyzes the trx file that is the result of executing dotnet test and +# converts it to markdown, which is used for the Files CI. + +using namespace System.Collections.Generic; +using namespace System.Linq; + +param( + [string]$Source = "", + [string]$Destination = "" +) + +class Trx +{ + [ResultSummary] $ResultSummary + [TrxTimes] $Times + [TrxTestDefinition[]]$TestDefinitions + [TrxUnitTestResult[]]$Results + + Trx() + { + $this.Times = New-Object TrxTimes + $this.ResultSummary = New-Object ResultSummary + } +} + +class ResultSummary +{ + [int] $total + [int] $passed + [int] $failed +} + +class TrxTimes +{ + [Datetime] $creation + [Datetime] $queuing + [Datetime] $start + [Datetime] $finish +} + +class TrxTestDefinition +{ + [string] $id + [string] $name + [string] $className +} + +class TrxUnitTestResult +{ + [string] $id + [string] $result + [string] $name + [string] $errorMessage + [string] $errorStackTrace +} + +[xml]$xmlDoc = Get-Content $Source + +$trxObject = New-Object Trx + +# Result summary +$trxObject.ResultSummary.total = $xmlDoc.TestRun.ResultSummary.Counters.total +$trxObject.ResultSummary.passed = $xmlDoc.TestRun.ResultSummary.Counters.passed +$trxObject.ResultSummary.failed = $xmlDoc.TestRun.ResultSummary.Counters.failed + +# Times +$trxObject.Times.start = $xmlDoc.TestRun.Times.start +$trxObject.Times.finish = $xmlDoc.TestRun.Times.finish + +# Unit test definitions +foreach ($item in $xmlDoc.TestRun.TestDefinitions.UnitTest) +{ + $newOne = [TrxTestDefinition]::new() + + $newOne.id = $item.Execution.id + $newOne.name = $item.name + $newOne.className = $item.TestMethod.className + + $trxObject.TestDefinitions += $newOne +} + +# Unit tests +foreach ($item in $xmlDoc.TestRun.Results.UnitTestResult) +{ + $newOne = [TrxUnitTestResult]::new() + + $newOne.id = $item.executionId + $newOne.result = $item.outcome + $newOne.name = $item.testName + $newOne.errorMessage = $item.Output.ErrorInfo.Message + $newOne.errorStackTrace = $item.Output.ErrorInfo.StackTrace + + $trxObject.Results += $newOne +} + +$stringBuilder = New-Object System.Text.StringBuilder + +$title = "## Tested with Files " +$AbbreviatedOid = $env:GITHUB_SHA +$AbbreviatedOid = $AbbreviatedOid.Substring(0, 7) +$resultOverview = "" + +# Header +[void]$stringBuilder.AppendLine($title); +[void]$stringBuilder.AppendLine(""); + +$skippedIcon = "⏩" +$passedIcon = "✅" +$failedIcon = "❌" +$unknownIcon = "⚠️" + +# Skipped +if ($trxObject.ResultSummary.failed -ne 0 -and $trxObject.ResultSummary.passed -ne 0) +{ + $resultOverview = $partialSuccessfulfulIcon + "Some tests were not successful" +} +# Passed +elseif ($trxObject.ResultSummary.failed -eq 0) +{ + $resultOverview = $passedIcon + " All tests have passed" +} +# Failed +elseif ($trxObject.ResultSummary.failed -ne 0 -and $trxObject.ResultSummary.passed -eq 0) +{ + $resultOverview = $failedIcon + " All tests have failed" +} +else +{ + $resultOverview = $unknownIcon + " Unknown result" +} + +# Overview table +[void]$stringBuilder.AppendLine(""); +[void]$stringBuilder.AppendLine(""); +[void]$stringBuilder.AppendLine(""); +[void]$stringBuilder.AppendLine(""); +[void]$stringBuilder.AppendLine(""); +[void]$stringBuilder.AppendLine(""); +[void]$stringBuilder.AppendLine(""); +[void]$stringBuilder.AppendLine(""); +[void]$stringBuilder.AppendLine(""); +[void]$stringBuilder.AppendLine(""); +[void]$stringBuilder.AppendLine(""); +[void]$stringBuilder.AppendLine(""); +[void]$stringBuilder.AppendLine(""); +[void]$stringBuilder.AppendLine("
Commit:$AbbreviatedOid
Status:$resultOverview
Full log:https://github.com/files-community/Files/actions/runs/$GITHUB_RUN_ID/job/$GITHUB_JOB
"); +[void]$stringBuilder.AppendLine(""); + +if ($trxObject.ResultSummary.failed -eq 0) +{ + $stringBuilder.ToString() | Out-File -FilePath $Destination + Exit +} + +# Details Table +[void]$stringBuilder.AppendLine("### Details"); +[void]$stringBuilder.AppendLine("Name|Status|Failed class"); +[void]$stringBuilder.AppendLine(":---|:---|:---"); + +$index = 0 + +foreach ($item in $trxObject.Results) +{ + $resultStatus = "" + if ($item.result.Equals("Failed")) + { + $resultStatus = $failedIcon + " Failed" + } + elseif ($item.result.Equals("Passed")) + { + $resultStatus = $successfulIcon + " Passed" + } + else + { + $resultStatus = $skippedIcon + " Unknown" + } + + $failedClassName = "_None_" + $testName = $item.name + $baseClassName = $trxObject.TestDefinitions | Where-Object { $_.id -eq $item.id } + if ($null -ne $item.errorMessage) + { + $failedClassName = "" + $baseClassName.className + "." + $item.name + "" + } + + [void]$stringBuilder.AppendLine("$testName`|$resultStatus`|$failedClassName"); + + $index++ +} + +[void]$stringBuilder.AppendLine(""); + +[void]$stringBuilder.AppendLine("
"); +[void]$stringBuilder.AppendLine("View logs"); +[void]$stringBuilder.AppendLine("
"); +[void]$stringBuilder.AppendLine(""); + +foreach ($item in $trxObject.Results) +{ + $baseClassName = $trxObject.TestDefinitions | Where-Object { $_.id -eq $item.id } + $failedClassName = $baseClassName.className + "." + $item.name + [void]$stringBuilder.AppendLine("- **" + $failedClassName + "**"); + + $stackTraceText = $item.errorStackTrace + [void]$stringBuilder.AppendLine(" ``````"); + [void]$stringBuilder.Append("$stackTraceText"); + [void]$stringBuilder.AppendLine(" ``````"); +} + +[void]$stringBuilder.AppendLine(""); +[void]$stringBuilder.AppendLine("
"); +[void]$stringBuilder.AppendLine(""); + + +$stringBuilder.ToString() | Out-File -FilePath $Destination diff --git a/scripts/Generate-SelfCertPfx.ps1 b/scripts/Generate-SelfCertPfx.ps1 new file mode 100644 index 000000000000..e7ce69cc80d1 --- /dev/null +++ b/scripts/Generate-SelfCertPfx.ps1 @@ -0,0 +1,28 @@ +# Copyright (c) 2023 Files Community +# Licensed under the MIT License. See the LICENSE. + +# Abstract: +# This script generates a self-signed certificate for the temporary packaging as a pfx file. + +param( + [string]$Destination = "" +) + +$CertFriendlyName = "FilesApp_SelfSigned" +$CertPublisher = "CN=Files" +$CertStoreLocation = "Cert:\CurrentUser\My" + +# Generate self signed cert +$cert = New-SelfSignedCertificate ` + -Type Custom ` + -Subject $CertPublisher ` + -KeyUsage DigitalSignature ` + -FriendlyName $CertFriendlyName ` + -CertStoreLocation $CertStoreLocation ` + -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}") + +# Get size of the self signed cert +$certificateBytes = $cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pkcs12) + +# Save the self signed cert as a file +[System.IO.File]::WriteAllBytes($Destination, $certificateBytes) \ No newline at end of file diff --git a/tests/Files.InteractionTests/SessionManager.cs b/tests/Files.InteractionTests/SessionManager.cs index e0690bcbd445..6341542eea4f 100644 --- a/tests/Files.InteractionTests/SessionManager.cs +++ b/tests/Files.InteractionTests/SessionManager.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Files Community +// Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. using OpenQA.Selenium.Appium; @@ -15,8 +15,9 @@ public class SessionManager { private const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723"; private static string[] FilesAppIDs = new string[]{ - "49306atecsolution.FilesUWP_dwm5abbcs5pn0!App", - "FilesDev_ykqwq8d6ps0ag!App" + "FilesDev_ykqwq8d6ps0ag!App", // Needed to run on the local end and/or the CI + "FilesDev_9bhem8es8z4gp!App", // Needed to run on the local end and/or the CI + "FilesDev_dwm5abbcs5pn0!App", // Needed to run on the CI }; private static uint appIdIndex = 0;