Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSOE-884: Add option to enable diagnostics mode for dotnet test, renaming ui-test-artifact-retention-days to test-artifact-retention-days #373

Merged
merged 14 commits into from
Jul 19, 2024
Merged
11 changes: 9 additions & 2 deletions .github/actions/test-dotnet/Invoke-SolutionTests.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
param ($Solution, $Verbosity, $Filter, $Configuration, $BlameHangTimeout, $TestProcessTimeout)
param (
[string] $Solution,
[string] $Verbosity,
[string] $Filter,
[string] $Configuration,
[string] $BlameHangTimeout,
[string] $TestProcessTimeout,
[boolean] $EnableDiagnosticMode)

# Note that this script will only find tests if they were previously build in Release mode.

Expand Down Expand Up @@ -40,7 +47,6 @@ $Env:Lombiq_Tests_UI__BrowserConfiguration__Headless = 'true'
$solutionName = [System.IO.Path]::GetFileNameWithoutExtension($Solution)
$solutionDirectory = [System.IO.Path]::GetDirectoryName($Solution)


Write-Output "Running tests for the $Solution solution."

Write-Output 'Gathering test projects.'
Expand Down Expand Up @@ -201,6 +207,7 @@ foreach ($test in $tests)
'--verbosity', $Verbosity
$BlameHangTimeout ? ('--blame-hang-timeout', $BlameHangTimeout, '--blame-hang-dump-type', 'full') : ''
$Filter ? '--filter', $Filter : ''
$EnableDiagnosticMode ? '--diag DiagnosticLogs/dotnet-test.log' : ''
$test
)

Expand Down
36 changes: 27 additions & 9 deletions .github/actions/test-dotnet/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,24 @@ inputs:
Determines how many UI tests will run in parallel. Affects both xUnit's maxParallelThreads configuration and the
MaxParallelTests configuration of Lombiq UI Testing Toolbox. If set to "-1" then the configuration coming from the
code won't be overridden.
ui-test-artifact-retention-days:
artifact-retention-days:
dministro marked this conversation as resolved.
Show resolved Hide resolved
required: false
default: '7'
description: >
Duration in days after which the artifact of UI testing (if any) will expire. See
https://github.com/actions/upload-artifact#retention-period for more details.
Duration in days after which the artifacts of testing (e.g. UI testing failure dump, hang dump, if any) will
expire. See https://github.com/actions/upload-artifact#retention-period for more details.
xunit-max-parallel-threads:
required: false
default: '0'
description: >
Sets the maxParallelThreads configuration in all available xUnit xunit.runner.json configuration files. See
https://xunit.net/docs/configuration-files#maxParallelThreads for details on available values.
enable-diagnostic-mode:
required: false
default: 'false'
description: >
Enables diagnostic mode for `dotnet test` with the `--diag` flag and writes diagnostic messages to log files, to
be uploaded as artifacts. See https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-test for details.

runs:
using: composite
Expand Down Expand Up @@ -103,6 +109,7 @@ runs:
Configuration = "${{ inputs.test-configuration }}"
BlameHangTimeout = "${{ inputs.blame-hang-timeout }}"
TestProcessTimeout = ${{ inputs.dotnet-test-process-timeout }}
EnableDiagnosticMode = $${{ inputs.enable-diagnostic-mode }}
}

Invoke-SolutionTests @switches
Expand All @@ -128,15 +135,15 @@ runs:
name: ui-test-failure-dump-${{ steps.setup.outputs.artifact-name-suffix }}
path: ${{ inputs.build-directory }}/FailureDumps/
if-no-files-found: ignore
retention-days: ${{ inputs.ui-test-artifact-retention-days }}
retention-days: ${{ inputs.artifact-retention-days }}

- name: Merge BlameHangDumps
- name: Merge Blame Hang Dumps
id: merge-blame-hang-dumps
shell: pwsh
if: failure() && steps.run-tests.outputs.test-count != 0 && inputs.blame-hang-timeout != ''
run: Merge-BlameHangDumps -Directory "${{ inputs.build-directory }}" -Configuration "${{ inputs.test-configuration }}"

- name: Upload BlameHangDumps
- name: Upload Blame Hang Dumps
uses: Lombiq/GitHub-Actions/.github/actions/upload-artifact@dev
if: |
failure() &&
Expand All @@ -147,16 +154,27 @@ runs:
name: ui-test-blame-hang-dump-${{ steps.setup.outputs.artifact-name-suffix }}
path: ${{ inputs.build-directory }}/BlameHangDumps/
if-no-files-found: ignore
retention-days: ${{ inputs.ui-test-artifact-retention-days }}
retention-days: ${{ inputs.artifact-retention-days }}

- name: Upload DotnetTestHangDumps
- name: Upload Dotnet Test Hang Dumps
uses: Lombiq/GitHub-Actions/.github/actions/upload-artifact@dev
if: (success() || failure()) && steps.run-tests.outputs.test-count != 0 && steps.run-tests.outputs.dotnet-test-hang-dump != 0
with:
name: dotnet-test-hang-dump-${{ steps.setup.outputs.artifact-name-suffix }}
path: ${{ inputs.build-directory }}/DotnetTestHangDumps/
if-no-files-found: ignore
retention-days: ${{ inputs.ui-test-artifact-retention-days }}
retention-days: ${{ inputs.artifact-retention-days }}

- name: Upload Diagnostic Logs
uses: Lombiq/GitHub-Actions/.github/actions/upload-artifact@dev
# always() is needed because if the test process hangs and the workflow times out, we still need the diagnostic
# logs. We don't need additional conditions, because of the "if-no-files-found" setting.
if: always() && steps.run-tests.outputs.test-count != 0
with:
name: dotnet-test-diagnostic-logs-${{ steps.setup.outputs.artifact-name-suffix }}
path: ${{ inputs.build-directory }}/DiagnosticLogs/
if-no-files-found: ignore
retention-days: ${{ inputs.artifact-retention-days }}

- name: Test Report
# v15
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/build-and-test-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,24 @@ on:
description: >
Filter expression for dotnet test. See:
https://learn.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests.
test-artifact-retention-days:
type: string
default: '7'
description: >
Duration in days after which the artifacts of testing (e.g. hang dump, diagnostic logs, if any) will expire.
See https://github.com/actions/upload-artifact#retention-period for more details.
xunit-max-parallel-threads:
type: string
default: '0'
description: >
Sets the maxParallelThreads configuration in all available xUnit xunit.runner.json configuration files. See
https://xunit.net/docs/configuration-files#maxParallelThreads for details on available values.
enable-test-diagnostic-mode:
type: string
default: 'false'
description: >
Enables diagnostic mode for `dotnet test` with the `--diag` flag and writes diagnostic messages to log files,
to be uploaded as artifacts. See https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-test for details.
timeout-minutes:
type: number
default: 360
Expand Down Expand Up @@ -242,7 +254,9 @@ jobs:
solution-path: ${{ inputs.build-solution-path }}
test-verbosity: ${{ inputs.build-verbosity }}
test-filter: ${{ inputs.test-filter }}
artifact-retention-days: ${{ inputs.test-artifact-retention-days }}
xunit-max-parallel-threads: ${{ inputs.xunit-max-parallel-threads }}
enable-diagnostic-mode: ${{ inputs.enable-test-diagnostic-mode }}

- name: Cancel Workflow on Failure
if: failure() && inputs.cancel-workflow-on-failure == 'true'
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/build-and-test-orchard-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,24 @@ on:
Determines how many UI tests will run in parallel. Affects both xUnit's maxParallelThreads configuration and
the MaxParallelTests configuration of Lombiq UI Testing Toolbox. If set to "-1" then the configuration coming
from the code won't be overridden.
ui-test-artifact-retention-days:
test-artifact-retention-days:
type: string
default: '7'
description: >
Duration in days after which the artifact of UI testing (if any) will expire. See
https://github.com/actions/upload-artifact#retention-period for more details.
Duration in days after which the artifacts of testing (e.g. UI testing failure dump, hang dump, if any) will
expire. See https://github.com/actions/upload-artifact#retention-period for more details.
xunit-max-parallel-threads:
type: string
default: '0'
description: >
Sets the maxParallelThreads configuration in all available xUnit xunit.runner.json configuration files. See
https://xunit.net/docs/configuration-files#maxParallelThreads for details on available values.
enable-test-diagnostic-mode:
type: string
default: 'false'
description: >
Enables diagnostic mode for `dotnet test` with the `--diag` flag and writes diagnostic messages to log files,
to be uploaded as artifacts. See https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-test for details.
timeout-minutes:
type: number
default: 360
Expand Down Expand Up @@ -294,8 +300,9 @@ jobs:
test-verbosity: ${{ inputs.build-verbosity }}
test-filter: ${{ inputs.test-filter }}
ui-test-parallelism: ${{ inputs.ui-test-parallelism }}
ui-test-artifact-retention-days: ${{ inputs.ui-test-artifact-retention-days }}
artifact-retention-days: ${{ inputs.test-artifact-retention-days }}
xunit-max-parallel-threads: ${{ inputs.xunit-max-parallel-threads }}
enable-diagnostic-mode: ${{ inputs.enable-test-diagnostic-mode }}

- name: Cancel Workflow on Failure
if: failure() && inputs.cancel-workflow-on-failure == 'true'
Expand Down
Loading