Execution, CI, Allure & deployment
Connect local execution to CI: environment preparation, Windows GUI execution, evidence preservation, Allure aggregation and report deployment.
Execution, CI, evidence and reporting
Desktop automation does not end when a test method passes locally. The repository also defines how both stacks are installed, invoked, given artifact directories, aggregated into Allure results and executed on Windows in CI. This layer is part of the automation system because environment differences can change desktop behavior even when test code is unchanged.
PowerShell / GitHub Actions
↓
prepare Python + .NET dependencies
↓
run pytest and dotnet test
↓
write screenshots + Allure result files
↓
preserve artifacts even on failure
↓
generate / deploy report where allowedRead this section with two questions in mind: what must exist on the Windows runner before GUI interaction is possible, and what evidence must survive when the test fails? if: always()-style artifact/reporting steps matter precisely because failure diagnostics are most valuable when the normal test path did not complete.
Local PowerShell runner: orchestrate both stacks and fail fast
Trace the local script from environment diagnostics through tests to Allure generation.
Concept
One script gives a developer the same ordered workflow every time and documents the actual commands CI will later automate. Explicit $LASTEXITCODE checks prevent failed native commands from being mistaken for success.
Code from the project
Reviewed source: `scripts/run-local.ps1`
$ErrorActionPreference = "Stop"
$env:DESKTOP_TEST_ENVIRONMENT = "local-windows"
$env:DESKTOP_TEST_ARTIFACTS_DIR = (Join-Path $PWD "test-artifacts")
Remove-Item -Recurse -Force allure-results, allure-report, test-artifacts -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force -Path allure-results | Out-Null
Write-Host "Running FlaUI suite..."
dotnet test flaui/Notepad.Tests/Notepad.Tests.csproj --configuration Debug
if ($LASTEXITCODE -ne 0) {
throw "FlaUI tests failed with exit code $LASTEXITCODE."
}
Write-Host "Running pywinauto suite with Allure results..."
python -m pytest python/tests -vv --alluredir=allure-results
if ($LASTEXITCODE -ne 0) {
throw "pywinauto tests failed with exit code $LASTEXITCODE."
}
npx -y allure@3.16.0 generate allure-results --config ./allurerc.mjs
Detailed explanation
PowerShell sets strict error behavior and shared environment variables, removes stale report/artifact directories, creates a clean Allure result directory, executes the C# suite and explicitly checks its native exit code, then does the same for pytest. Only after both suites succeed does it invoke the pinned Allure CLI to turn raw results into the HTML report.
Initially, possibly stale results and no guarantee about execution order. Once this step completes, both suites have run against the local interactive desktop and a fresh combined Allure report exists, or the script stopped at the first functional failure.
Design reasoning
Keeping stale allure-results can mix old and new tests. Ignoring $LASTEXITCODE can allow report generation to hide a failing suite behind a successful final command.
Key points
- Orchestration scripts define execution contracts.
- Native command exit codes must be propagated deliberately in PowerShell.
Common pitfalls
- Assuming
$ErrorActionPreference = 'Stop'automatically converts every non-zero native exit code into a terminating PowerShell error.
GitHub Actions: triggers, concurrency and the Windows runner
Read the workflow header as the rule that decides when and where CI exists.
Concept
This header defines the CI contract before any command executes: events, permissions, cancellation behavior, operating system and maximum duration.
Code from the project
Reviewed source: `.github/workflows/desktop-ui-tests.yml`
name: Desktop UI tests
on:
workflow_dispatch:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
concurrency:
group: desktop-ui-${{ github.ref }}
cancel-in-progress: true
jobs:
desktop-tests:
name: Notepad UI tests + screenshots + Allure
runs-on: windows-latest
timeout-minutes: 20
Detailed explanation
GitHub creates a workflow run for manual dispatch, pushes to main, and pull requests targeting main. The job gets read-only repository content permission, shares a concurrency group keyed by Git ref so a newer run can cancel an obsolete in-progress run for the same ref, and is scheduled onto a temporary GitHub-hosted windows-latest runner with a 20-minute job limit.
Initially, there is no runner. Once this step completes, a fresh hosted Windows environment exists and can execute the declared steps.
Design reasoning
Using a Linux runner would make Windows Notepad/UIA tests impossible. Removing concurrency cancellation can waste runner time on superseded commits. Omitting a timeout can leave a stuck desktop job consuming capacity much longer.
Key points
- CI starts from events and runner selection, not from test commands.
- Hosted runners are ephemeral execution environments.
Common pitfalls
- Reading
runs-onas a label only instead of the operating-system/runtime boundary for the whole job.
CI environment setup: checkout, .NET, Python and Node
See how a blank hosted runner becomes capable of executing the repository.
Concept
A hosted runner should be treated as reproducible infrastructure, not as your laptop. The workflow explicitly prepares the tools it relies on instead of assuming a developer's preconfigured environment.
Code from the project
Reviewed source: `.github/workflows/desktop-ui-tests.yml`
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: 8.0.x
- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: "3.12"
cache: pip
cache-dependency-path: python/requirements.txt
- name: Setup Node for Allure
uses: actions/setup-node@v7
with:
node-version: "22"
Detailed explanation
checkout places the repository commit into the runner workspace. The setup actions then select the required .NET SDK, Python 3.12 and Node 22 toolchains. Python setup also enables pip caching keyed from the dependency file, while Node exists because Allure 3 is invoked later through npx.
Initially, a fresh Windows runner with its image defaults. Once this step completes, repository files are present and the required language/tool runtimes are selected for subsequent commands.
Design reasoning
Without checkout, relative repository paths do not exist. A mismatched .NET/Python version can make dependency restore or tests fail. Without Node, the later npx allure command cannot run.
Key points
- CI recreates tools declaratively.
- Each setup action prepares a dependency for later steps.
Common pitfalls
- Assuming
windows-latestguarantees the exact runtime versions your project expects forever.
CI test execution and if: always() semantics
Understand why later diagnostic/reporting work can run after an earlier suite fails.
Concept
For a comparison lab, one failing stack should not automatically prevent collecting evidence from the other stack. always() allows the run to produce a fuller diagnostic picture and later report/artifact stages can still preserve evidence.
Code from the project
Reviewed source: `.github/workflows/desktop-ui-tests.yml`
- name: Run ALL FlaUI tests
shell: pwsh
run: >-
dotnet test flaui/Notepad.Tests/Notepad.Tests.csproj
--configuration Release
--logger "trx;LogFileName=flaui.trx"
--results-directory flaui/TestResults
- name: Install Python dependencies
if: always()
shell: pwsh
run: python -m pip install -r python/requirements.txt
- name: Run ALL pywinauto tests
if: always()
shell: pwsh
run: >-
python -m pytest python/tests -vv
--junitxml=pywinauto-pytest.xml
--alluredir=allure-results
Detailed explanation
The job first runs the complete C# project in Release mode and writes TRX results. The next two steps explicitly use the GitHub Actions status function always(), so they are still evaluated/run even if the FlaUI step failed (subject to broader run cancellation). Python dependencies are installed, then pytest writes both JUnit XML and Allure result files.
Initially, toolchains exist and result folders are clean. Once this step completes, one or both test stacks have produced their native and Allure results, even when the first stack did not pass.
Design reasoning
Without if: always(), GitHub's default success condition can skip Python execution after a FlaUI failure, reducing diagnostic coverage. Using always() indiscriminately, however, can run actions that should genuinely stop after a prerequisite failure.
Key points
- Step conditions are part of control flow.
- Failure collection and functional success are different concerns.
Common pitfalls
- Reading
always()as 'ignore failure' rather than 'still run this step according to the always status function'.
Allure pipeline: raw results → one HTML report → preserved artifacts
Follow reporting data after the functional test commands have finished.
Concept
Reporting should fail clearly when no test results exist; an empty-looking successful report is misleading. Keeping raw evidence alongside HTML allows later debugging without depending solely on the rendered report.
Code from the project
Reviewed source: `.github/workflows/desktop-ui-tests.yml`
- name: Show collected Allure results
if: always()
shell: pwsh
run: |
$results = @(Get-ChildItem allure-results -Filter "*-result.json" -File -ErrorAction SilentlyContinue)
Write-Host "Allure test result files in shared directory: $($results.Count)"
if ($results.Count -eq 0) {
throw "No Allure test result files were produced."
}
- name: Generate Allure report
if: always()
shell: pwsh
run: npx --prefer-offline -y allure@3.16.0 generate allure-results --config ./allurerc.mjs
- name: Upload report and screenshots
if: always()
uses: actions/upload-artifact@v7
with:
name: desktop-ui-test-report
path: |
allure-report
allure-results
test-artifacts
desktop-environment.txt
flaui/TestResults
pywinauto-pytest.xml
retention-days: 7
Detailed explanation
The workflow first validates that shared Allure result JSON files actually exist. The Allure CLI then converts the raw result model and attachments into a browsable HTML report. Finally GitHub Actions uploads both processed and raw evidence—report, result files, screenshots, environment diagnostics, TRX directory and pytest JUnit XML—as a seven-day workflow artifact.
Initially, test frameworks produced raw files. Once this step completes, a combined human-readable report exists and GitHub stores a downloadable evidence bundle independent of later deployment.
Design reasoning
Skipping the result-count guard can make a reporting configuration failure look like a test run with no cases. Uploading only HTML discards lower-level evidence useful for debugging.
Key points
- Allure results and the generated report are different artifacts.
- Preserve raw diagnostics as well as presentation output.
Common pitfalls
- Treating report generation success as proof that functional tests passed.
Secrets, SSH and report deployment to Hetzner
Trace the deployment step without confusing repository variables, secrets, runner files and remote commands.
Concept
Secrets and ordinary configuration have different sensitivity. The private key belongs in secrets, while host/user/ports can be repository variables or defaults. PRs are prevented from publishing the shared live report, avoiding untrusted/temporary branch output replacing the latest main report.
Code from the project
Reviewed source: `.github/workflows/desktop-ui-tests.yml`
- name: Publish latest Allure report to Hetzner
if: always() && github.event_name != 'pull_request'
shell: pwsh
env:
HETZNER_SSH_KEY: ${{ secrets.HETZNER_SSH_KEY }}
HETZNER_HOST: ${{ vars.HETZNER_HOST || '46.224.218.150' }}
HETZNER_SSH_USER: ${{ vars.HETZNER_SSH_USER || 'root' }}
HETZNER_SSH_PORT: ${{ vars.HETZNER_SSH_PORT || '22' }}
HETZNER_WEB_PORT: ${{ vars.HETZNER_WEB_PORT || '8089' }}
run: |
$keyText = $env:HETZNER_SSH_KEY.Trim().Replace('\n', "`n").Replace("`r", "")
[System.IO.File]::WriteAllText($keyPath, $keyText + "`n", [System.Text.UTF8Encoding]::new($false))
tar -czf $archive -C allure-report .
& scp -P $sshPort @sshOptions $archive scripts/hetzner/deploy-allure.sh "$sshUser@$hostName`:/tmp/"
& ssh -p $sshPort @sshOptions "$sshUser@$hostName" "bash /tmp/deploy-allure.sh '$releaseId' '$webPort' && rm -f /tmp/deploy-allure.sh"
Detailed explanation
This step is eligible after tests/reporting even on failure, but it is excluded from pull-request events. GitHub expression evaluation places the secret key and configurable variables into this step's environment. PowerShell writes the private key into a temporary runner file, creates a compressed report archive, copies the archive plus deployment script to the remote host via SCP, then executes that script over SSH with a release ID and web port.
Initially, generated report exists only on the runner. Once this step completes, archive and deploy script were transferred, remote deployment ran, and the runner can remove the temporary key/archive while GitHub still retains the workflow artifact separately.
Design reasoning
Putting the private key in repository variables or source exposes credentials. Publishing from PR events can let review code overwrite shared report state. Skipping key validation/permissions can make SSH fail or weaken secret handling.
Key points
- GitHub expressions resolve secrets/variables before shell code consumes environment variables.
- CI deployment has a trust boundary separate from test execution.
Common pitfalls
- Treating
${{ secrets.NAME }}and$env:NAMEas the same mechanism; the first is workflow expression/context resolution, the second is PowerShell environment access.
Screenshots and environment diagnostics are evidence, not test truth
Understand why the project captures evidence around state changes while assertions remain machine-readable.
Concept
Screenshots help investigate desktop failures and prove what the UI looked like, but a reporting subsystem should not change a correct functional result just because image capture failed. Assertions against UIA/file state remain the source of test truth.
Code from the project
Reviewed source: `flaui/Notepad.Tests/NotepadTestBase.cs`
protected void CaptureWindow(string step)
{
if (_window is null)
{
return;
}
try
{
var configuredRoot = Environment.GetEnvironmentVariable("DESKTOP_TEST_ARTIFACTS_DIR");
var artifactsRoot = string.IsNullOrWhiteSpace(configuredRoot)
? Path.Combine(Directory.GetCurrentDirectory(), "flaui", "TestArtifacts")
: Path.GetFullPath(configuredRoot);
var testDirectory = Path.Combine(artifactsRoot, SanitizeFileName(TestContext.CurrentContext.Test.Name));
Directory.CreateDirectory(testDirectory);
var screenshotPath = Path.Combine(testDirectory, $"{DateTime.UtcNow:HHmmssfff}-{SanitizeFileName(step)}.png");
_window.CaptureToFile(screenshotPath);
TestContext.AddTestAttachment(screenshotPath, $"Notepad: {step}");
AllureApi.AddAttachment($"Notepad - {step}", "image/png", screenshotPath);
}
catch (Exception ex)
{
TestContext.Progress.WriteLine($"Screenshot warning: {ex.Message}");
}
}
Detailed explanation
The helper chooses an artifact root from the shared environment variable or a local fallback, creates a test-specific directory, captures the current Notepad window to a timestamped PNG, attaches the same file to NUnit's test context and to Allure, and deliberately converts screenshot failures into warnings rather than functional test failures.
Initially, only live UI state exists. Once this step completes, there is a timestamped diagnostic image attached to both native and Allure reporting channels, or a warning explaining why capture failed.
Design reasoning
If screenshot capture throws through the test, a reporting problem can create false functional failures. If screenshots are never taken, debugging intermittent UI state becomes substantially harder.
Key points
- Evidence collection should support, not redefine, assertions.
- Environment variables let local and CI runs share one artifact convention.
Common pitfalls
- Using visual evidence as the only validation for deterministic text/file state.
Put it all together: CI, report delivery and the full state machine
Finish by tracing one commit from GitHub event to cleaned desktop tests, report evidence and published output.
Concept
This final trace separates continuous integration—reproducibly integrating code and executing validation—from the small delivery/deployment part that publishes the generated report. The test code, CI control flow, reporting and deployment are different systems connected by explicit files, exit statuses and environment/context values.
Code from the project
Reviewed source: `.github/workflows/desktop-ui-tests.yml`
push / pull_request / manual
↓
GitHub-hosted windows-latest runner
↓
checkout + .NET + Python + Node
↓
FlaUI tests → TRX + screenshots + Allure results
↓
pywinauto tests → JUnit XML + screenshots + Allure results
↓
Allure generate → HTML report
↓
GitHub artifact (always)
↓
Hetzner publish (non-PR events)
Detailed explanation
A repository event creates an ephemeral Windows runner. The workflow materializes source and toolchains, runs two independent automation implementations against real Notepad UI, captures functional and diagnostic results, renders one report, preserves the evidence bundle in GitHub and—outside PR events—delivers the latest rendered report to the configured Hetzner host. Each test also creates and cleans only its unique file/tab resources.
Initially, a commit/PR exists in GitHub. Once this step completes, tests have executed in a clean hosted Windows environment; owned desktop resources are cleaned; raw and rendered evidence is preserved; for eligible events the latest report is also deployed remotely.
Design reasoning
Collapsing all of these stages into 'CI runs tests' hides important failure boundaries: setup can fail before tests, one stack can fail while another still produces evidence, report generation can fail after tests, artifact upload can preserve evidence even when deployment fails, and deployment is intentionally event-gated.
Key points
- CI is a state machine of events, environments, commands, conditions and artifacts.
- Functional testing, reporting and deployment have distinct success/failure boundaries.
Common pitfalls
- Calling the whole workflow 'deployment' or the whole workflow 'tests' and losing the boundaries between stages.