Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 10 additions & 22 deletions .github/workflows/gua-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ jobs:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
permissions:
contents: read
uses: link1345/gua-tester/.github/workflows/unity.yml@v2.2
uses: link1345/gua-tester/.github/workflows/unity.yml@v3.1
with:
project-path: .
scene-path: Assets/Scenes/Main.unity
test-project: tests/GuaUiLab.Unity.Tests.csproj
artifact-key: unity-sample
platform: LinuxX64
unity-version: auto
gua-tag: gua-v0.18.0
gua-tag: gua-v1.0.4
artifact-path: artifacts/gua
secrets:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
Expand All @@ -38,7 +39,7 @@ jobs:
visual-report-demo:
needs: unity-tests
if: github.event_name == 'workflow_dispatch' && inputs.visual-report-demo && needs.unity-tests.result == 'success'
runs-on: windows-latest
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- name: Check out repository
Expand All @@ -49,20 +50,6 @@ jobs:
with:
dotnet-version: 10.0.x

- name: Set deterministic Windows display resolution
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
if ($null -eq (Get-Command Set-DisplayResolution -ErrorAction SilentlyContinue)) {
throw "Set-DisplayResolution is unavailable on this Windows runner image."
}
Set-DisplayResolution -Width 1920 -Height 1080 -Force
Add-Type -AssemblyName System.Windows.Forms
$bounds = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds
if ($bounds.Width -ne 1920 -or $bounds.Height -ne 1080) {
throw "Windows display resolution is $($bounds.Width)x$($bounds.Height); expected 1920x1080."
}

- name: Download Unity Player
uses: actions/download-artifact@v4
with:
Expand All @@ -73,14 +60,15 @@ jobs:
id: player
shell: pwsh
run: |
$player = Get-ChildItem -LiteralPath artifacts/unity-player -Filter GuaPlayer.exe -Recurse -File | Select-Object -First 1
$player = Get-ChildItem -LiteralPath artifacts/unity-player -Filter GuaPlayer -Recurse -File | Select-Object -First 1
if ($null -eq $player) {
throw "Downloaded Unity Player executable was not found."
}
chmod +x $player.FullName
"path=$($player.FullName)" | Out-File -FilePath $env:GITHUB_OUTPUT -Append

- name: Restore Unity tests
shell: pwsh
shell: bash
run: dotnet restore tests/GuaUiLab.Unity.Tests.csproj

- name: Generate intentional Unity visual difference
Expand All @@ -90,7 +78,7 @@ jobs:
GUA_UNITY_ARTIFACT_PLAYER: ${{ steps.player.outputs.path }}
GUA_VISUAL_REPORT_DEMO: "1"
run: >-
dotnet test tests/GuaUiLab.Unity.Tests.csproj
xvfb-run --auto-servernum dotnet test tests/GuaUiLab.Unity.Tests.csproj
--configuration Release
--no-restore
--filter VisualReportViewerDemoProducesPixelDifferenceArtifact
Expand Down Expand Up @@ -150,7 +138,7 @@ jobs:

- name: Upload pull-request visual report
if: github.event_name == 'pull_request' && steps.visual-outcome.outputs.value == 'failure'
uses: link1345/gua-tester/visual-report@v2.2
uses: link1345/gua-tester/visual-report@v3.1
with:
artifact-path: downloaded
test-outcome: ${{ steps.visual-outcome.outputs.value }}
Expand All @@ -161,7 +149,7 @@ jobs:
- name: Prepare latest main visual report
id: pages-report
if: always() && (github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch')
uses: link1345/gua-tester/visual-report@v2.2
uses: link1345/gua-tester/visual-report@v3.1
with:
artifact-path: downloaded
test-outcome: ${{ steps.visual-outcome.outputs.value }}
Expand Down
2 changes: 1 addition & 1 deletion Packages/com.link1345.gua/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.link1345.gua",
"version": "0.18.0",
"version": "1.0.4",
Comment thread
link1345 marked this conversation as resolved.
"displayName": "Gua Runtime UI Automation",
"description": "Managed Unity adapter for the Gua runtime UI automation protocol.",
"unity": "6000.5",
Expand Down
10 changes: 5 additions & 5 deletions README-ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

ウィンドウはリサイズ可能です。541×857のデザイン比率を維持して一様に拡大・縮小し、画面比率から余る領域は黒いレターボックスとして表示します。

UI自動化にはGua v0.18.0のUnity UPMパッケージを使用しています。実行中は既定で `ws://127.0.0.1:8765` にGua bridgeを開き、標準uGUIツリーを自動的に公開します。ポートは環境変数 `GUA_BRIDGE_PORT` で変更できます。
UI自動化にはGua v1.0.4のUnity UPMパッケージを使用しています。実行中は既定で `ws://127.0.0.1:8765` にGua bridgeを開き、標準uGUIツリーを自動的に公開します。ポートは環境変数 `GUA_BRIDGE_PORT` で変更できます。

## 実行

1. Unity Hubでこのディレクトリを開きます。
2. Unity `6000.5.3f1`で `Assets/Scenes/Main.unity` を開きます。
3. Playを押します。

Guaの管理DLLとWindows x64ネイティブDLLを含む公式UPMパッケージ v0.18.0は `Packages/com.link1345.gua` に固定しています。そのため、隣接するGuaソースリポジトリへの参照や別途のパッケージダウンロードは不要です。
Guaの管理DLLとWindows/Linux x64 native libraryを含む公式UPMパッケージ v1.0.4は `Packages/com.link1345.gua` に固定しています。そのため、隣接するGuaソースリポジトリへの参照や別途のパッケージダウンロードは不要です。

## UIテスト

Expand Down Expand Up @@ -55,13 +55,13 @@ Remove-Item Env:GUA_VISUAL_REPORT_DEMO

## GitHub Actions

`.github/workflows/gua-tests.yml`で[`link1345/gua-tester`](https://github.com/link1345/gua-tester) v2.2を使用し、`main`へのpushとpull requestでUnity 6のWindows x64 Mono PlayerをビルドしてUIテストを実行します。Unity Playerのビルドにはrepository secretsの`UNITY_EMAIL`、`UNITY_PASSWORD`と、Personal用の`UNITY_LICENSE`またはProfessional用の`UNITY_SERIAL`が必要です。
`.github/workflows/gua-tests.yml`で[`link1345/gua-tester`](https://github.com/link1345/gua-tester) v3.1を使用し、`main`へのpushとpull requestでUnity 6のLinux x64 Mono Playerをビルドし、Xvfb上でUIテストを実行します。Unity Playerのビルドにはrepository secretsの`UNITY_EMAIL`、`UNITY_PASSWORD`と、Personal用の`UNITY_LICENSE`またはProfessional用の`UNITY_SERIAL`が必要です。

forkからのpull requestではUnity credentialsを渡さず、Unity jobをスキップします。`pull_request_target`は使用しません。

### Visual差分Viewer

pull requestでVisual比較が失敗すると、`visual-report@v2.2`が`comparison.json`とPNGを静的Viewerへ変換し、`gua-visual-report`というActions artifactとして保存します。通常のUnity build log、Player、TRX、Gua診断・Visual成果物も`gua-tester` v2.2のworkflow artifactとして保存されます。
pull requestでVisual比較が失敗すると、`visual-report@v3.1`が`comparison.json`とPNGを静的Viewerへ変換し、`gua-visual-report`というActions artifactとして保存します。通常のUnity build log、Player、TRX、Gua診断・Visual成果物も`gua-tester` v3.1のworkflow artifactとして保存されます。

`main`へのpushと手動実行では、最新結果をGitHub Pages artifactとしてアップロードし、専用jobからPagesへdeployします。repositoryのPages sourceを事前に **GitHub Actions** へ設定してください。

Expand All @@ -82,4 +82,4 @@ pull requestでVisual比較が失敗すると、`visual-report@v2.2`が`comparis
| `cancel_exit` | button | 終了確認 |
| `confirm_exit` | button | 終了確認 |

Gua v0.18.0で検証するUnity構成に合わせ、Windows x64・Monoを対象にしています。IL2CPPとWindows以外のPlayerはこのサンプルの検証対象外です。
Gua v1.0.4のクロスプラットフォームUnity構成に合わせ、CIではLinux x64・Monoを対象にしています。IL2CPPはこのサンプルの検証対象外です。
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ This is a Unity sample project for [Gua](https://github.com/link1345/gua). It re

The window is resizable. The UI scales uniformly while preserving its 541×857 design aspect ratio, and any space outside that ratio is rendered as black letterboxing.

UI automation uses the Gua v0.18.0 Unity UPM package. At runtime, it opens a Gua bridge at `ws://127.0.0.1:8765` by default and automatically exposes the standard uGUI tree. Set the `GUA_BRIDGE_PORT` environment variable to use a different port.
UI automation uses the Gua v1.0.4 Unity UPM package. At runtime, it opens a Gua bridge at `ws://127.0.0.1:8765` by default and automatically exposes the standard uGUI tree. Set the `GUA_BRIDGE_PORT` environment variable to use a different port.

## Run the sample

1. Open this directory in Unity Hub.
2. Open `Assets/Scenes/Main.unity` with Unity `6000.5.3f1`.
3. Enter Play Mode.

The official UPM package v0.18.0, including the managed assemblies and Windows x64 native libraries, is pinned in `Packages/com.link1345.gua`. No adjacent Gua source repository or separate package download is required.
The official UPM package v1.0.4, including the managed assemblies and Windows and Linux x64 native libraries, is pinned in `Packages/com.link1345.gua`. No adjacent Gua source repository or separate package download is required.

## UI tests

Expand Down Expand Up @@ -54,13 +54,13 @@ Remove-Item Env:GUA_VISUAL_REPORT_DEMO

## GitHub Actions

`.github/workflows/gua-tests.yml` uses [`link1345/gua-tester`](https://github.com/link1345/gua-tester) v2.2 to build a Unity 6 Windows x64 Mono Player and run UI tests on pushes to `main` and on pull requests. Building the Unity Player requires the repository secrets `UNITY_EMAIL`, `UNITY_PASSWORD`, and either `UNITY_LICENSE` for a Personal license or `UNITY_SERIAL` for a Professional license.
`.github/workflows/gua-tests.yml` uses [`link1345/gua-tester`](https://github.com/link1345/gua-tester) v3.1 to build a Unity 6 Linux x64 Mono Player and run UI tests under Xvfb on pushes to `main` and on pull requests. Building the Unity Player requires the repository secrets `UNITY_EMAIL`, `UNITY_PASSWORD`, and either `UNITY_LICENSE` for a Personal license or `UNITY_SERIAL` for a Professional license.

Pull requests from forks do not receive Unity credentials, so the Unity job is skipped. The workflow does not use `pull_request_target`.

### Visual difference viewer

When a visual comparison fails in a pull request, `visual-report@v2.2` turns `comparison.json` and its PNGs into a static viewer and stores it as the `gua-visual-report` Actions artifact. The normal Unity build log, Player, TRX file, and Gua diagnostic and visual artifacts are also stored in the `gua-tester` v2.2 workflow artifact.
When a visual comparison fails in a pull request, `visual-report@v3.1` turns `comparison.json` and its PNGs into a static viewer and stores it as the `gua-visual-report` Actions artifact. The normal Unity build log, Player, TRX file, and Gua diagnostic and visual artifacts are also stored in the `gua-tester` v3.1 workflow artifact.

On pushes to `main` and manual runs, the latest report is uploaded as a GitHub Pages artifact and deployed by a dedicated job. Configure the repository's Pages source as **GitHub Actions** first.

Expand All @@ -81,4 +81,4 @@ Enable `visual-report-demo` in a manual run to reuse the Unity Player from the n
| `cancel_exit` | button | Exit confirmation |
| `confirm_exit` | button | Exit confirmation |

This sample targets Windows x64 and Mono, matching the validated Unity configuration in Gua v0.18.0. IL2CPP and non-Windows Players are outside the sample's validated scope.
This sample's CI targets Linux x64 and Mono, matching the cross-platform Unity configuration in Gua v1.0.4. IL2CPP remains outside the sample's validated scope.
6 changes: 4 additions & 2 deletions tests/AdvancedValidationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ public sealed class AdvancedValidationTests
private const int RenderedHeight = 700;
private static readonly string VisualVariant =
Environment.GetEnvironmentVariable("GUA_VISUAL_VARIANT")
?? "windows-unity-6000.5.3f1-d3d11-541x700";
?? (OperatingSystem.IsLinux()
? "unity-LinuxX64"
: "windows-unity-6000.5.3f1-d3d11-541x700");
Comment thread
link1345 marked this conversation as resolved.
private static readonly TimeSpan ShortTimeout = TimeSpan.FromSeconds(5);
private static readonly TimeSpan RecordingActionTimeout = TimeSpan.FromSeconds(15);
private static readonly TimeSpan PollInterval = TimeSpan.FromMilliseconds(20);
Expand Down Expand Up @@ -76,7 +78,7 @@ await GuaAssertions.WaitForVisibleAsync(
"visual-report-demo-baselines");
var artifactDirectory = Path.Combine(ProjectRoot, "artifacts", "gua");
const string comparisonName = "visual-report-viewer-demo";
const string variant = "windows-unity-6000.5.3f1-d3d11-541x700";
var variant = VisualVariant;
var comparisonArtifactDirectory = Path.Combine(artifactDirectory, comparisonName);

await GuaVisualAssertions.ExpectScreenshotAsync(
Expand Down
10 changes: 5 additions & 5 deletions tests/GuaUiLab.Unity.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Gua.Core" Version="0.18.0" />
<PackageReference Include="Gua.Testing" Version="0.18.0" />
<PackageReference Include="Gua.Testing.Recording" Version="0.18.0" />
<PackageReference Include="Gua.Testing.Unity" Version="0.18.0" />
<PackageReference Include="Gua.Testing.Visual" Version="0.18.0" />
<PackageReference Include="Gua.Core" Version="1.0.4" />
<PackageReference Include="Gua.Testing" Version="1.0.4" />
<PackageReference Include="Gua.Testing.Recording" Version="1.0.4" />
<PackageReference Include="Gua.Testing.Unity" Version="1.0.4" />
<PackageReference Include="Gua.Testing.Visual" Version="1.0.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.7.0" />
<PackageReference Include="NUnit" Version="4.6.1" />
<PackageReference Include="NUnit3TestAdapter" Version="6.2.0" />
Expand Down