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

Communication tests and build #2

Open
wants to merge 68 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
ed73bd3
first try
ianjennings Jan 23, 2025
61131b5
build
ianjennings Jan 23, 2025
019fb73
i take suggestions
ianjennings Jan 23, 2025
fd5ae41
remove working dir setting
ianjennings Jan 23, 2025
b045639
I think we don't need these anymore either
ianjennings Jan 23, 2025
1385a8e
upload right artifact and debug
ianjennings Jan 23, 2025
7137fde
update release target, remove ls command
ianjennings Jan 23, 2025
97828e2
add build commnad
ianjennings Jan 31, 2025
107b34b
Update test-build-windows.yml
spoisseroux Feb 2, 2025
6551356
Update test-build-windows.yml
spoisseroux Feb 2, 2025
c6dd4bd
Update test-build-windows.yml
spoisseroux Feb 2, 2025
2f0f785
communication tests
spoisseroux Feb 2, 2025
4f49a88
add communication tests
spoisseroux Feb 2, 2025
540832a
Update test-build-windows.yml
spoisseroux Feb 2, 2025
d0a8a8a
Update test-build-windows.yml
spoisseroux Feb 2, 2025
6b5c2a5
Update test-build-windows.yml
spoisseroux Feb 2, 2025
7e88665
Update test-build-windows.yml
spoisseroux Feb 2, 2025
c891e31
Update test-build-windows.yml
spoisseroux Feb 2, 2025
565e764
Update test-build-windows.yml
spoisseroux Feb 2, 2025
1d47085
Update test-build-windows.yml
spoisseroux Feb 2, 2025
25be297
Update test-build-windows.yml
spoisseroux Feb 2, 2025
1597e25
change path, upload correct artifact
spoisseroux Feb 2, 2025
1eea580
rollback test-build-windows.yml
spoisseroux Feb 2, 2025
3647273
rollback test-build-windows.yml
spoisseroux Feb 2, 2025
64df16c
Update test-build-windows.yml, fix signature issue and artifact handl…
spoisseroux Feb 2, 2025
8d608ce
Update test-build-windows.yml, pnpm path
spoisseroux Feb 2, 2025
3436518
Update test-build-windows.yml, pnpm confirm
spoisseroux Feb 2, 2025
73e5d8e
Update test-build-windows.yml, disable corepack
spoisseroux Feb 2, 2025
3f40430
Update test-build-windows.yml, corepack changes
spoisseroux Feb 2, 2025
1eac10d
Update test-build-windows.yml, ensure pnpm after corepack install
spoisseroux Feb 2, 2025
610dfbf
Update test-build-windows.yml, install pnpm before node
spoisseroux Feb 2, 2025
7e64d8f
Update test-build-windows.yml, update artifact url
spoisseroux Feb 2, 2025
4528fe5
Update test-build-windows.yml
spoisseroux Feb 2, 2025
a567ded
Update test-build-windows.yml, set gh variable correctly
spoisseroux Feb 2, 2025
f46d7b6
Update test-build-windows.yml, match artifact names
spoisseroux Feb 2, 2025
769a25f
Update test-build-windows.yml, get most recent artifact, run id not g…
spoisseroux Feb 2, 2025
16bc7c8
minimize, dark mode tests added
spoisseroux Feb 2, 2025
f40cd62
Update test-build-windows.yml
spoisseroux Feb 2, 2025
0d2fe0e
Merge branch 'spoisseroux-comm-tests' of https://github.com/testdrive…
spoisseroux Feb 2, 2025
77f82d8
Create tauri_api_install.yml
spoisseroux Feb 2, 2025
4b55848
add comm/ui tests to main yml
spoisseroux Feb 2, 2025
3e4df29
Update test-build-windows.yml, remove wait from installation
spoisseroux Feb 3, 2025
4ba918e
Update test-build-windows.yml, remove wave.exe optional run
spoisseroux Feb 3, 2025
fbf2dac
Update test-build-windows.yml, remove dummy prompt
spoisseroux Feb 3, 2025
b3967c3
Update test-build-windows.yml, reorder prompts
spoisseroux Feb 3, 2025
5023a4e
Update test-build-windows.yml, corepack enable
spoisseroux Feb 3, 2025
7de2351
Update dark_light_mode.yml
spoisseroux Feb 3, 2025
9201f1a
Update minimize_maximize.yml
spoisseroux Feb 3, 2025
feace59
Update test-build-windows.yml
spoisseroux Feb 3, 2025
851568f
add testdriver readme
spoisseroux Feb 3, 2025
ac65d0f
Update test-build-windows.yml, backend wasnt working
spoisseroux Feb 3, 2025
7809ddf
Update test-build-windows.yml, remove run in dev
spoisseroux Feb 3, 2025
eec29ba
Update test-build-windows.yml
spoisseroux Feb 3, 2025
45b96b6
Update test-build-windows.yml
spoisseroux Feb 3, 2025
520bab6
Update test-build-windows.yml
spoisseroux Feb 3, 2025
acfcb40
Update README.md in testdriver dir
spoisseroux Feb 4, 2025
ef4cb73
Update README.md
spoisseroux Feb 4, 2025
4686cc3
Update test-build-windows.yml, add run api exe
spoisseroux Feb 8, 2025
1ad9357
Update test-build-windows.yml, restore one artifact, remove api tests…
spoisseroux Feb 10, 2025
9102a7d
upload create_window.yml testdriver test
spoisseroux Feb 10, 2025
41323d0
upload set_window_title
spoisseroux Feb 10, 2025
de312cf
Update test-build-windows.yml
spoisseroux Feb 10, 2025
d28199f
minimize_window
spoisseroux Feb 10, 2025
add63a9
Merge branch 'spoisseroux-comm-tests' of https://github.com/testdrive…
spoisseroux Feb 10, 2025
fe93131
Update test-build-windows.yml, add minimize_window.yml
spoisseroux Feb 10, 2025
9f421f9
Update test-build-windows.yml, remove corepack for prettier
spoisseroux Feb 10, 2025
9ff3129
Update test-build-windows.yml, formatting
spoisseroux Feb 10, 2025
ed9321d
Update test-build-windows.yml
spoisseroux Feb 10, 2025
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
163 changes: 163 additions & 0 deletions .github/workflows/test-build-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# Copyright 2019-2024 Tauri Programme within The Commons Conservancy
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: MIT
name: Build EXE for TestDriver

env:
DEBUG: napi:*

on:
pull_request:

jobs:
build:
name: build windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- run: corepack enable

- name: Install pnpm explicitly
run: |
npm install -g pnpm
pnpm --version # Verify pnpm is installed and available

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
architecture: x64

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc

- name: Install dependencies (root)
run: pnpm install --frozen-lockfile --ignore-scripts

- name: Install dependencies (examples/api)
working-directory: examples/api
run: pnpm i

- name: Build CLI
run: pnpm run build:cli
shell: bash

- name: Build API
run: pnpm run build:api
shell: bash

- name: Run app in dev mode (background)
working-directory: examples/api
run: Start-Process -NoNewWindow -FilePath "cmd.exe" -ArgumentList "/c pnpm tauri dev"
shell: powershell

- name: Build API Example App
working-directory: examples/api
run: pnpm tauri build

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-x86_64-pc-windows-msvc
path: target\release\bundle\nsis\*
if-no-files-found: error

- name: Set environment variables
run: |
echo "GITHUB_REPOSITORY=${{ github.repository }}" >> $GITHUB_ENV
echo "GITHUB_RUN_ID=${{ github.run_id }}" >> $GITHUB_ENV

- uses: testdriverai/action@main
with:
key: ${{ secrets.TESTDRIVER_API_KEY }}
prompt: |
1. /run testdriver/tauri_api_install.yml
2. /run testdriver/create_window.yml
3. /run testdriver/dark_light_mode.yml
4. /run testdriver/set_window_title.yml
#1. /run testdriver/minimize_window.yml
#1. /run testdriver/comm_echo.yml
#1. /run testdriver/comm_send_event_rust.yml
#1. /run testdriver/comm_spam.yml
#1. /run testdriver/comm_call_request_api.yml
#1. /run testdriver/comm_call_log_api.yml

prerun: |
$headers = @{
Authorization = "token ${{ secrets.GITHUB_TOKEN }}"
}

$downloadFolder = "./download"
$artifactName = "bindings-x86_64-pc-windows-msvc"
Write-Host "Starting the artifact download process..."

# Create the download directory if it doesn't exist
if (-not (Test-Path -Path $downloadFolder)) {
Write-Host "Creating download folder..."
mkdir $downloadFolder
} else {
Write-Host "Download folder already exists."
}

# Fetch the artifact upload URL (no need for GITHUB_RUN_ID)
Write-Host "Fetching the artifact upload URL..."
$artifactUrl = (Invoke-RestMethod -Uri "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" -Headers $headers).artifacts[0].archive_download_url

if ($artifactUrl) {
Write-Host "Artifact URL successfully fetched: $artifactUrl"
} else {
Write-Error "Failed to fetch the artifact URL."
exit 1
}

# Download the artifact (zipped file)
Write-Host "Starting artifact download..."
$artifactZipPath = "$env:TEMP\artifact.zip"
try {
Invoke-WebRequest -Uri $artifactUrl `
-Headers $headers `
-OutFile $artifactZipPath `
-MaximumRedirection 5
Write-Host "Artifact downloaded successfully to $artifactZipPath"
} catch {
Write-Error "Error downloading artifact: $_"
exit 1
}

# Unzip the artifact
$artifactUnzipPath = "$env:TEMP\artifact"
Write-Host "Unzipping the artifact to $artifactUnzipPath..."
try {
Expand-Archive -Path $artifactZipPath -DestinationPath $artifactUnzipPath -Force
Write-Host "Artifact unzipped successfully to $artifactUnzipPath"
} catch {
Write-Error "Failed to unzip the artifact: $_"
exit 1
}

# Find the installer or app executable
$artifactInstallerPath = Get-ChildItem -Path $artifactUnzipPath -Filter *.exe -Recurse | Select-Object -First 1
if ($artifactInstallerPath) {
Write-Host "Executable file found: $($artifactInstallerPath.FullName)"
} else {
Write-Error "Executable file not found. Exiting."
exit 1
}

# Run the installer and log the result
Write-Host "Running the installer: $($artifactInstallerPath.FullName)..."
try {
Start-Process -FilePath $artifactInstallerPath.FullName
Write-Host "Installer ran successfully."
} catch {
Write-Error "Failed to run the installer: $_"
exit 1
}

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FORCE_COLOR: "3"
61 changes: 61 additions & 0 deletions testdriver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Tauri API with TestDriver.ai

Hello! I'm going to show you how to create a new [TestDriver.ai](http://TestDriver.ai) regression test and implement it into the TestDriver.ai github action, specifically for the Tauri API Validation app.

## How it works

In the Tauri repo there is a directory called '**testdriver**' which holds all of our created TestDriver.ai regression tests.

Right now, the file .github/workflows/test-build-windows.yml is our main TestDrivier. workflow for building and testing the Tauri API validation application.

TestDriver.ai github action uses this workflow to spin up an ephemeral VM, open the app, and test it by starting up a local TestDriver.ai agent and using our regression tests passed into the workflow file from the '**testdriver**' directory. (Reference testdrivers workflow docs [here](https://docs.testdriver.ai/continuous-integration/github-setup)).

Of course, before being able to test the API example app we need to build and install the app on our VM. Which already happens in our [prerun script](https://docs.testdriver.ai/continuous-integration/prerun-scripts) in the workflow.

In the workflow, we can see `/run` commands under the `prompt:` we use these to run our tests sequentially after the app has been built and launched ([parallel testing](https://docs.testdriver.ai/continuous-integration/parallel-testing) can also be done).

## Creating regression tests

After [installing TestDriver.ai](https://docs.testdriver.ai/overview/installing-via-npm) on your local machine, navigate to the root of your local Tauri repo.

Once at the root, it may be beneficial to select your desired preferences for TestDriver.ai by using `testdriverai init` ,there you can select whether to receive desktop notifications, minimize the terminal when creating tests (this helps TestDriver.ai resolve quicker), and more.

Then use `testdriverai testdriver/[new test name].yml` to create a new test within the '**testdriver'** directory.

Now, TestDriver.ai should start and be awaiting a prompt. So, let's open the Tauri API validation app, and place it next to our terminal, and begin creating a test.

If we give TestDriver.ai a prompt like '**click the Communication tab in the sidebar**', TestDriver.ai will do so, and give us something like this resulting YAML.

```
- prompt: click the Communication tab in the sidebar
commands:
- command: hover-text
text: Communication
description: >-
Communication tab in the sidebar of the Tauri API Validation
application
action: click

```

When we give another prompt, like '**click the spam button**', TestDriver.ai will generate something like:

```
- prompt: Click the Spam button
commands:
- command: hover-text
text: Spam
description: >-
Spam button in the Communication section of the
Tauri API Validation application
action: click

```

And then automatically append it to our previously generated YAML!

([CLI commands](https://docs.testdriver.ai/reference/cli-commands) like `/undo` and `assert` are also important!)

We can do `/save` to ensure our YAML is saved. Then we can run the regression test we've just created with `/run testdriver/[new test name].yml` just like how the prompts are being run in the workflow file.

If we want to implement this test into our github action workflow, all we have to do is add the `/run testdriver/[new test name].yml` under a `prompt:` in the workflow. ([workflow doc](https://docs.testdriver.ai/continuous-integration/github-setup))
33 changes: 33 additions & 0 deletions testdriver/comm_call_log_api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: 4.1.58
session: 679ed1b8a1ad2d40a789e790
steps:
- prompt: focus tauri API Validation
commands:
- command: hover-text
text: Tauri API Validation
description: window title of the Tauri API Validation application
action: click
- prompt: click the Communication tab in the sidebar
commands:
- command: hover-text
text: Communication
description: >-
Communication tab in the sidebar of the Tauri API Validation
application
action: click
- prompt: Click the Call Log API button
commands:
- command: hover-text
text: Call Log API
description: >-
Call Log API button in the Communication section of the
Tauri API Validation application
action: click
- prompt: Wait 5 seconds
commands:
- command: wait
timeout: 5000
- prompt: Assert that the console shows a successful response
commands:
- command: assert
expect: the console shows a response
33 changes: 33 additions & 0 deletions testdriver/comm_call_request_api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: 4.1.58
session: 679ed1b8a1ad2d40a789e790
steps:
- prompt: focus tauri API Validation
commands:
- command: hover-text
text: Tauri API Validation
description: window title of the Tauri API Validation application
action: click
- prompt: click the Communication tab in the sidebar
commands:
- command: hover-text
text: Communication
description: >-
Communication tab in the sidebar of the Tauri API Validation
application
action: click
- prompt: Click the Call Request (async) API button
commands:
- command: hover-text
text: Call Request (async) API
description: >-
Call Request (async) API button in the Communication section of the
Tauri API Validation application
action: click
- prompt: Wait 5 seconds
commands:
- command: wait
timeout: 5000
- prompt: Assert that the console shows a successful response
commands:
- command: assert
expect: the console shows "message response"
33 changes: 33 additions & 0 deletions testdriver/comm_echo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: 4.1.58
session: 679ed1b8a1ad2d40a789e790
steps:
- prompt: focus tauri API Validation
commands:
- command: hover-text
text: Tauri API Validation
description: window title of the Tauri API Validation application
action: click
- prompt: click the Communication tab in the sidebar
commands:
- command: hover-text
text: Communication
description: >-
Communication tab in the sidebar of the Tauri API Validation
application
action: click
- prompt: Click the Echo button
commands:
- command: hover-text
text: Echo
description: >-
Echo button in the Communication section of the
Tauri API Validation application
action: click
- prompt: Wait 5 seconds
commands:
- command: wait
timeout: 5000
- prompt: Assert that the console shows a successful response
commands:
- command: assert
expect: the console shows a response with "Tauri JSON request!" and "1, 2, 3"
33 changes: 33 additions & 0 deletions testdriver/comm_send_event_rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: 4.1.58
session: 679ed1b8a1ad2d40a789e790
steps:
- prompt: focus tauri API Validation
commands:
- command: hover-text
text: Tauri API Validation
description: window title of the Tauri API Validation application
action: click
- prompt: click the Communication tab in the sidebar
commands:
- command: hover-text
text: Communication
description: >-
Communication tab in the sidebar of the Tauri API Validation
application
action: click
- prompt: Click the Send event to Rust button
commands:
- command: hover-text
text: Send event to Rust
description: >-
Send Event to Rust button in the Communication section of the
Tauri API Validation application
action: click
- prompt: Wait 5 seconds
commands:
- command: wait
timeout: 5000
- prompt: Assert that the console shows a successful response
commands:
- command: assert
expect: the console shows a response with an "event", "payload", and "id"
33 changes: 33 additions & 0 deletions testdriver/comm_spam.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: 4.1.58
session: 679ed1b8a1ad2d40a789e790
steps:
- prompt: focus tauri API Validation
commands:
- command: hover-text
text: Tauri API Validation
description: window title of the Tauri API Validation application
action: click
- prompt: click the Communication tab in the sidebar
commands:
- command: hover-text
text: Communication
description: >-
Communication tab in the sidebar of the Tauri API Validation
application
action: click
- prompt: Click the Spam button
commands:
- command: hover-text
text: Spam
description: >-
Spam button in the Communication section of the
Tauri API Validation application
action: click
- prompt: Wait 5 seconds
commands:
- command: wait
timeout: 5000
- prompt: Assert that the console shows a successful response
commands:
- command: assert
expect: the console shows a response with value 1000
Loading
Loading