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

Improve macOS app test script reliability and error handling #885

Merged
merged 2 commits into from
Oct 24, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
repository: ${{ env.REPO }}

- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: '3.10'

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Set up Node.js
Expand Down Expand Up @@ -184,7 +184,7 @@ jobs:
fetch-depth: 0
token: ${{ secrets.ADMIN_TOKEN }} # Use the new token for authentication
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install the latest version of the project
Expand Down Expand Up @@ -235,7 +235,7 @@ jobs:
with:
ref: main
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Publish to PyPI
Expand Down
52 changes: 20 additions & 32 deletions build_scripts/test_app_run_macos.sh
Original file line number Diff line number Diff line change
@@ -1,53 +1,41 @@
#!/bin/bash

# unzip the app

# Unzip the app
ZIPFILE_PATH="$(pwd)/dist/OpenAdapt.app.zip"
unzip -o "$ZIPFILE_PATH" -d "$(pwd)/dist"

APP_PATH="$(pwd)/dist/OpenAdapt.app/Contents/MacOS/OpenAdapt.app"

# print current directory
# Current directory for reference
echo "Current directory: $(pwd)"
echo "App path: $APP_PATH"

# Run the app
open "$APP_PATH"

# Allow some time for the application to launch
sleep 30
# Path to the app
APP_PATH="$(pwd)/dist/OpenAdapt.app"
EXECUTABLE_PATH="$APP_PATH/Contents/MacOS/OpenAdapt"
echo "App path: $APP_PATH"
echo "Executable path: $EXECUTABLE_PATH"

# Verify that the executable exists
if [ -z "$APP_PATH" ]; then
echo "Error: Could not find executable in $APP_PATH"
# Verify app exists
if [ ! -d "$APP_PATH" ]; then
echo "Error: Could not find app at $APP_PATH"
exit 1
fi

# Get the process IDs
PIDS=$(pgrep -f "$APP_PATH")

# Verify that the process IDs were found
if [ -z "$PIDS" ]; then
echo "Error: Could not find process IDs for $APP_PATH"
if [ ! -f "$EXECUTABLE_PATH" ]; then
echo "Error: Could not find executable at $EXECUTABLE_PATH"
exit 1
fi

# Variable to track if any process is still running
ALL_PROCESSES_RUNNING=true
# Run the app
open "$APP_PATH"

# Check if the processes are still running
for PID in $PIDS; do
if ! ps -p $PID > /dev/null; then
echo "Process $PID is not running"
ALL_PROCESSES_RUNNING=false
break
fi
done
# Wait for app to start
sleep 30

# Set the exit code variable based on the processes' status
if [ "$ALL_PROCESSES_RUNNING" = true ]; then
# Check for running process - try both the app name and binary name
if pgrep -f "OpenAdapt" > /dev/null || pgrep -f "OpenAdapt.app" > /dev/null; then
echo "Process is running"
EXIT_CODE=0
else
echo "Error: Could not find process IDs for OpenAdapt"
EXIT_CODE=1
fi

Expand Down
Loading