Skip to content

Commit

Permalink
maestro_cli: fix iOS artifacts extracting to a wrong place
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekpacia committed Aug 12, 2022
1 parent 706e8ef commit 9e276ec
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 14 deletions.
23 changes: 17 additions & 6 deletions .github/workflows/maestro_cli-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ jobs:
runs-on: ubuntu-latest
needs: check_versions

defaults:
run:
working-directory: AutomatorServer/android

steps:
- name: Clone repository
uses: actions/checkout@v3
Expand All @@ -34,15 +30,22 @@ jobs:
run: |
tag=${{ github.ref_name }}
prefix=maestro_cli-v
version=${tag#"$prefix"}
version=${tag#"$prefix"} # version without the prefix
echo "version: $version"
server_file="server-$version.apk"
echo "server file: $server_file"
instrumentation_file="instrumentation-$version.apk"
ios_zip_directory="ios-$version.zip"
echo "server file: $server_file"
echo "instrumentation file: $instrumentation_file"
echo "ios zip directory: $ios_zip_directory"
echo "VERSION=$version" >> $GITHUB_ENV
echo "SERVER_FILE=$server_file" >> $GITHUB_ENV
echo "INSTRUMENTATION_FILE=$instrumentation_file" >> $GITHUB_ENV
echo "IOS_ZIP_DIRECTORY=$ios_zip_directory" >> $GITHUB_ENV
# set whether is prerelease
is_prerelease=false
if [[ "$version" == 0.* ]]; then
Expand All @@ -56,17 +59,24 @@ jobs:
echo "tag message: $tag_message"
- name: Build server APK
working-directory: AutomatorServer/android
run: |
echo "server file: $SERVER_FILE"
./gradlew assembleDebug
mv app/build/outputs/apk/debug/app-debug.apk $SERVER_FILE
- name: Build instrumentation APK
working-directory: AutomatorServer/android
run: |
echo "instrumentation file: $INSTRUMENTATION_FILE"
./gradlew assembleDebugAndroidTest
mv app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk $INSTRUMENTATION_FILE
- name: Create iOS zip archive
working-directory: AutomatorServer/ios
run: |
echo "ios zip directory: $IOS_ZIP_DIRECTORY"
- name: Create release
uses: softprops/action-gh-release@v1
with:
Expand All @@ -80,6 +90,7 @@ jobs:
AutomatorServer/android/${{ env.INSTRUMENTATION_FILE }}
- name: Upload artifacts to Azure Storage
working-directory: AutomatorServer/android
env:
AZURE_STORAGE_URL: https://lncdmaestrostorage.blob.core.windows.net/artifacts
AZURE_SAS_TOKEN: ${{ secrets.AZURE_SAS_TOKEN }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class MaestroAutomator {
Logger.d("openNotifications()")
val success = uiDevice.openNotification()
if (!success) {
throw IllegalStateException("Could not open notifications")
throw MaestroException("Could not open notifications")
}
delay()
}
Expand All @@ -228,7 +228,7 @@ class MaestroAutomator {
Logger.d("openNotifications()")
val success = uiDevice.openQuickSettings()
if (!success) {
throw IllegalStateException("Could not open quick settings")
throw MaestroException("Could not open quick settings")
}
delay()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ data class SelectorQuery(

fun toBySelector(): BySelector {
if (isEmpty()) {
throw IllegalStateException("SelectorQuery is empty")
throw MaestroException("SelectorQuery is empty")
}

var matchedText = false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail

# make is a convenience command for running common Gradle tasks.
# debugcopy is a convenience program for running common Gradle tasks.

adb uninstall pl.leancode.automatorserver 1> /dev/null 2>&1 || true
adb uninstall pl.leancode.automatorserver.test 1> /dev/null 2>&1 || true
Expand Down
8 changes: 7 additions & 1 deletion AutomatorServer/ios/debugcopy
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ set -euo pipefail

# debugcopy is a convenience program for copying iOS project to $MAESTRO_CACHE.

cp -r . ~/.maestro/ios
if [ "$(basename "$PWD")" = "ios" ]; then
rm -rf ~/.maestro/ios
cp -r . ~/.maestro/ios
else
echo "this program must be run from the ios project directory"
exit 1
fi
12 changes: 12 additions & 0 deletions AutomatorServer/ios/makearchive
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -euo pipefail

# makearchive is a convenience program which creates a zip archive of the iOS
# AutomatorServer.

if [ "$(basename "$PWD")" = "ios" ]; then
zip -r
else
echo "this program must be run from the ios project directory"
exit 1
fi
7 changes: 4 additions & 3 deletions packages/maestro_cli/lib/src/common/artifacts_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ArtifactsRepository {
bool areDebugArtifactsPresent() {
final serverApk = File(paths.debugServerArtifactPath);
final instrumentationApk = File(paths.debugInstrumentationArtifactPath);
final iosDir = Directory(paths.debugIOSArtifactDir);
final iosDir = Directory(paths.debugIosArtifactDirPath);

return serverApk.existsSync() &&
instrumentationApk.existsSync() &&
Expand All @@ -56,8 +56,9 @@ class ArtifactsRepository {
final archive = ZipDecoder().decodeBytes(bytes);

for (final archiveFile in archive) {
final file = archiveFile.name;
final extractPath = paths.iosArtifactDir + Platform.pathSeparator + file;
final filename = archiveFile.name;
final extractPath =
paths.iosArtifactDirPath + Platform.pathSeparator + filename;
if (archiveFile.isFile) {
final data = archiveFile.content as List<int>;
final newFile = File(extractPath);
Expand Down

0 comments on commit 9e276ec

Please sign in to comment.