Skip to content

Commit

Permalink
Fix macos in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbruno25 committed Jun 6, 2024
1 parent b7893ec commit 12a59d8
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 5 deletions.
36 changes: 33 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
os: [macos-latest, ubuntu-latest, windows-latest]
# Temporarily limit versions
# https://github.com/python-poetry/poetry/issues/8139
python-version: ['3.10', '3.11', '3.12'] # '3.8', '3.9',

steps:
- uses: actions/checkout@v3
Expand All @@ -45,7 +47,7 @@ jobs:
run: poetry install --no-ansi

- name: Test linux
if: runner.os != 'Windows'
if: runner.os == 'Linux'
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
Expand All @@ -65,10 +67,38 @@ jobs:
mkdir -p screenshots
poetry run pytest -v
- name: Test mac [1]
if: runner.os == 'macOS'
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
# Xvfb not available until next job
command: |
brew install --cask xquartz
echo "/opt/X11/bin" >> $GITHUB_PATH
- name: Test mac [2]
if: runner.os == 'macOS'
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
command: |
mkdir -p screenshots
Xvfb :1 &
export DISPLAY=":1"
poetry run pytest -v
- name: Upload screenshots
uses: actions/upload-artifact@v3
if: always()
with:
name: screenshots
path: screenshots/*.png

- name: Setup tmate session
# Enables ssh session during manually triggered ci runs
uses: mxschmitt/action-tmate@v3
if: ${{ failure() && github.event_name == 'workflow_dispatch' }}

6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ mypy = "^1.2.0"
pillow = "^10.3.0"
pyautogui = "^0.9.54"
opencv-python = "^4.8.0.74"
pyvirtualdisplay = {version = "^3.0", platform = "linux"}
pyvirtualdisplay = [
{version = "^3.0", platform = "linux"},
{version = "^3.0", platform = "darwin"},
]
msvc-runtime = {version = "^14.34.31931", platform = "windows"}


[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/resources/images/darwin/start_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion tests/test_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import Xlib.display
from pyvirtualdisplay.smartdisplay import SmartDisplay

elif HOST_OS == "darwin":
from pyvirtualdisplay.smartdisplay import SmartDisplay

elif HOST_OS == "windows":
import pygetwindow

Expand Down Expand Up @@ -65,7 +68,7 @@ def virtual_gui(request, gui_process):
app_window = pygetwindow.getWindowsWithTitle(app_title)[0]
app_window.restore()

else:
elif HOST_OS == "linux":
# Attach pyautogui to the virtual display
pyautogui._pyautogui_x11._display = Xlib.display.Display(os.getenv("DISPLAY"))

Expand Down

0 comments on commit 12a59d8

Please sign in to comment.