Skip to content

Commit 7cd8817

Browse files
authored
Add CI job to test building on all 3 OSes, and test version output (#3275)
* CI: Fix gradle config to prevent android sentinel failures or iOS dependency failures * Add CI job to test building on all 3 OSes, and test version output Disable Maestro CLI analytics to not pollute the test Fix Windows path setting in GHA Merge e2e testing together Make CLI tests local-first * Extra test, improved usage and formatting * Fix Windows tests that output to stderr * Additional tests, deal with ANSI in bash
1 parent a5e06a1 commit 7cd8817

8 files changed

Lines changed: 173 additions & 11 deletions

File tree

.github/workflows/test-e2e.yaml

Lines changed: 69 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,22 @@ jobs:
138138
fi
139139
140140
build:
141-
name: Build on Java ${{ matrix.java-version }}
141+
name: Build on ${{ matrix.os }}
142142
needs: validate-inputs
143143
if: ${{ always() && (needs.validate-inputs.result == 'success' || needs.validate-inputs.result == 'skipped') }}
144-
runs-on: macos-latest
144+
runs-on: ${{ matrix.os }}
145145
timeout-minutes: 20
146146

147147
strategy:
148148
fail-fast: false
149149
matrix:
150+
os: [ubuntu-latest, macos-latest, windows-latest]
150151
java-version: [17]
151152

153+
defaults:
154+
run:
155+
shell: bash
156+
152157
steps:
153158
- name: Clone repository
154159
uses: actions/checkout@v6
@@ -161,19 +166,21 @@ jobs:
161166
cache: gradle
162167

163168
- name: Build xctest-runner
169+
if: runner.os == 'macOS'
164170
run: ./maestro-ios-xctest-runner/build-maestro-ios-runner.sh | xcbeautify
165171

166172
- name: Build Maestro CLI
167173
run: ./gradlew :maestro-cli:distZip
168174

169-
- name: Upload zipped Maestro CLI artifact
175+
- name: Upload Maestro CLI artifact
170176
uses: actions/upload-artifact@v7
171177
with:
172-
name: maestro-cli-jdk${{ matrix.java-version }}-run_id${{ github.run_id }}
178+
name: maestro-cli-${{ matrix.os }}-jdk${{ matrix.java-version }}-run_id${{ github.run_id }}
173179
path: maestro-cli/build/distributions/maestro.zip
174180
retention-days: 1
175181

176182
- name: Upload build/Products to artifacts
183+
if: runner.os == 'macOS'
177184
uses: actions/upload-artifact@v7
178185
with:
179186
name: build__Products-jdk${{ matrix.java-version }}
@@ -208,7 +215,7 @@ jobs:
208215
- name: Download artifacts
209216
uses: actions/download-artifact@v8
210217
with:
211-
name: maestro-cli-jdk17-run_id${{ github.run_id }}
218+
name: maestro-cli-macos-latest-jdk17-run_id${{ github.run_id }}
212219

213220
- name: Add Maestro CLI executable to PATH
214221
run: |
@@ -324,7 +331,7 @@ jobs:
324331
- name: Download Maestro build from previous job
325332
uses: actions/download-artifact@v8
326333
with:
327-
name: maestro-cli-jdk17-run_id${{ github.run_id }}
334+
name: maestro-cli-macos-latest-jdk17-run_id${{ github.run_id }}
328335

329336
- name: Add Maestro CLI executable to PATH
330337
run: |
@@ -435,7 +442,7 @@ jobs:
435442
- name: Download artifacts
436443
uses: actions/download-artifact@v8
437444
with:
438-
name: maestro-cli-jdk17-run_id${{ github.run_id }}
445+
name: maestro-cli-macos-latest-jdk17-run_id${{ github.run_id }}
439446

440447
- name: Add Maestro CLI executable to PATH
441448
run: |
@@ -527,7 +534,7 @@ jobs:
527534
- name: Download Maestro artifact
528535
uses: actions/download-artifact@v8
529536
with:
530-
name: maestro-cli-jdk17-run_id${{ github.run_id }}
537+
name: maestro-cli-macos-latest-jdk17-run_id${{ github.run_id }}
531538

532539
- name: Download build/Products artifact
533540
uses: actions/download-artifact@v8
@@ -560,3 +567,57 @@ jobs:
560567
path: ~/Library/Logs/maestro/xctest_runner_logs
561568
retention-days: 7
562569
include-hidden-files: true
570+
571+
test-cli:
572+
name: Verify CLI version on ${{ matrix.os }}
573+
runs-on: ${{ matrix.os }}
574+
needs: build
575+
if: ${{ always() && needs.build.result == 'success' }}
576+
timeout-minutes: 10
577+
578+
strategy:
579+
fail-fast: false
580+
matrix:
581+
os: [ubuntu-latest, macos-latest, windows-latest]
582+
java-version: [17]
583+
584+
defaults:
585+
run:
586+
shell: bash
587+
588+
steps:
589+
- name: Clone repository
590+
uses: actions/checkout@v6
591+
592+
- name: Set up Java
593+
uses: actions/setup-java@v5
594+
with:
595+
distribution: zulu
596+
java-version: ${{ matrix.java-version }}
597+
598+
- name: Download Maestro CLI artifact
599+
uses: actions/download-artifact@v8
600+
with:
601+
name: maestro-cli-${{ matrix.os }}-jdk${{ matrix.java-version }}-run_id${{ github.run_id }}
602+
603+
- name: Add Maestro CLI to PATH (Linux / macOS)
604+
if: runner.os != 'Windows'
605+
run: |
606+
unzip maestro.zip -d maestro_extracted
607+
echo "$PWD/maestro_extracted/maestro/bin" >> $GITHUB_PATH
608+
609+
- name: Add Maestro CLI to PATH (Windows)
610+
if: runner.os == 'Windows'
611+
shell: pwsh
612+
run: |
613+
Expand-Archive -Path maestro.zip -DestinationPath maestro_extracted
614+
"$PWD\maestro_extracted\maestro\bin" | Out-File -FilePath $env:GITHUB_PATH -Append
615+
616+
- name: Test CLI (Linux / macOS)
617+
if: runner.os != 'Windows'
618+
run: e2e/cli/test-cli.sh
619+
620+
- name: Test CLI (Windows)
621+
if: runner.os == 'Windows'
622+
shell: pwsh
623+
run: e2e/cli/test-cli.ps1

e2e/cli/test-cli.ps1

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
$env:MAESTRO_CLI_NO_ANALYTICS = 1
2+
$pass = 0; $fail = 0
3+
4+
function Check([string]$desc, [string]$cmd, [string]$assertion, [string]$expected) {
5+
$actual = (Invoke-Expression "$cmd 2>&1" | Out-String).Trim()
6+
$ok = switch ($assertion) {
7+
'equals' { $actual -eq $expected }
8+
'includes' { $actual -like "*$expected*" }
9+
'excludes' { $actual -notlike "*$expected*" }
10+
default { Write-Error "unknown assertion '$assertion' (use: equals, includes, excludes)"; exit 1 }
11+
}
12+
if ($ok) {
13+
Write-Host "PASS: $desc"
14+
$script:pass++
15+
} else {
16+
Write-Host ("FAIL: {0}" -f $desc)
17+
Write-Host (" {0,-11} {1}" -f "cmd:", $cmd)
18+
Write-Host (" {0,-11} {1}" -f "assertion:", $assertion)
19+
Write-Host (" {0,-11} {1}" -f "expected:", $expected)
20+
Write-Host (" {0,-11} {1}" -f "got:", $actual)
21+
$script:fail++
22+
}
23+
}
24+
25+
$version = (Select-String -Path 'maestro-cli/gradle.properties' -Pattern '^CLI_VERSION=').Line `
26+
-replace '^CLI_VERSION=', ''
27+
28+
# TESTS START HERE:
29+
30+
Check "maestro -v equals gradle.properties version" `
31+
"maestro -v" "equals" $version
32+
Check "maestro gives usage instructions when called without parameters" `
33+
"maestro" "includes" "Usage: maestro"
34+
Check "maestro gives usage instructions when called with --help" `
35+
"maestro --help" "includes" "Usage: maestro"
36+
Check "maestro test subcommand gives usage instructions when called with --help" `
37+
"maestro test --help" "includes" "Usage: maestro test"
38+
Check "maestro bugreport gives instruction" `
39+
"maestro bugreport" "includes" "https://github.com/mobile-dev-inc/Maestro/issues"
40+
41+
Write-Host ""
42+
Write-Host "$pass passed, $fail failed"
43+
if ($fail -gt 0) { exit 1 }
44+
exit 0

e2e/cli/test-cli.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
export MAESTRO_CLI_NO_ANALYTICS=1
4+
PASS=0; FAIL=0
5+
6+
trap 'echo "ERROR: script failed at line $LINENO" >&2' ERR
7+
8+
check() { # check <desc> <cmd> <assertion> <expected>
9+
local desc="$1" cmd="$2" assertion="$3" expected="$4"
10+
local actual actual_plain ok=0
11+
actual=$(eval "$cmd" 2>&1 | tr -d '\r') || true
12+
actual_plain=$(printf '%s' "$actual" | sed 's/\x1b\[[0-9;]*[mGKHF]//g') # strip ansi
13+
case "$assertion" in
14+
equals) [ "$actual_plain" = "$expected" ] && ok=1 ;;
15+
includes) printf '%s' "$actual_plain" | grep -qF "$expected" && ok=1 ;;
16+
excludes) ! printf '%s' "$actual_plain" | grep -qF "$expected" && ok=1 ;;
17+
*) echo "ERROR: unknown assertion '$assertion' (use: equals, includes, excludes)" >&2; exit 1 ;;
18+
esac
19+
if [ $ok -eq 1 ]; then
20+
echo "PASS: $desc"
21+
(( ++PASS ))
22+
else
23+
printf "FAIL: %s\n" "$desc"
24+
printf " %-11s %s\n" "cmd:" "$cmd"
25+
printf " %-11s %s\n" "assertion:" "$assertion"
26+
printf " %-11s %s\n" "expected:" "$expected"
27+
printf " %-11s %s\n" "got:" "$actual_plain"
28+
(( ++FAIL ))
29+
fi
30+
}
31+
32+
VERSION=$(grep '^CLI_VERSION=' maestro-cli/gradle.properties | cut -d= -f2)
33+
34+
# TESTS START HERE:
35+
36+
check "maestro -v equals gradle.properties version" \
37+
"maestro -v" equals "$VERSION"
38+
39+
check "maestro gives usage instructions when called without parameters" \
40+
"maestro" includes "Usage: maestro"
41+
42+
check "maestro gives usage instructions when called with --help" \
43+
"maestro --help" includes "Usage: maestro"
44+
45+
check "maestro test subcommand gives usage instructions when called with --help" \
46+
"maestro test --help" includes "Usage: maestro test"
47+
48+
check "maestro bugreport gives instruction" \
49+
"maestro bugreport" includes "https://github.com/mobile-dev-inc/Maestro/issues"
50+
51+
echo ""
52+
echo "$PASS passed, $FAIL failed"
53+
[ $FAIL -eq 0 ]

maestro-android/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ tasks.register("updateMaestroAndroidSourceSentinel") {
181181
.forEach { f ->
182182
md.update(f.relativeTo(projectDir).invariantSeparatorsPath.toByteArray())
183183
md.update(0)
184-
md.update(f.readBytes())
184+
md.update(f.readText(Charsets.UTF_8).replace("\r\n", "\n").toByteArray(Charsets.UTF_8)) // Keep consistent line endings for Windows builds
185185
md.update(0)
186186
}
187187
val bytes = md.digest()

maestro-client/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ val checkAndroidApksFresh = tasks.register("checkAndroidApksFresh") {
8181
.forEach { f ->
8282
md.update(f.relativeTo(maestroAndroidProjectDir).invariantSeparatorsPath.toByteArray())
8383
md.update(0)
84-
md.update(f.readBytes())
84+
md.update(f.readText(Charsets.UTF_8).replace("\r\n", "\n").toByteArray(Charsets.UTF_8)) // Keep consistent line endings for Windows builds
8585
md.update(0)
8686
}
8787
val bytes = md.digest()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a55395029a33bab56bab234ec6d9357716fbc8a3d6202d9bc186a39255dec9d0
1+
34bc39fa9a97aa37556e948a67d189a76d8c01d2919729dd3d35b30946758653
1.77 KB
Binary file not shown.

maestro-ios-driver/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,7 @@ tasks.register<Exec>("buildIosDriver") {
7878
tasks.named("processResources") {
7979
dependsOn("buildIosDriver")
8080
}
81+
82+
tasks.matching { it.name == "sourcesJar" }.configureEach {
83+
dependsOn("buildIosDriver")
84+
}

0 commit comments

Comments
 (0)