Skip to content
Closed
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
339 changes: 161 additions & 178 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
workflow_dispatch:

jobs:

linux-multi-python:
name: Linux ${{ matrix.install_variant }} with Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
Expand All @@ -15,201 +14,182 @@ jobs:

strategy:
matrix:
python-version: [3.10.8, 3.11, 3.12, 3.13]
install_variant: ["pip"]
include:
python-version: [3.10.8, 3.11, 3.12, 3.13, 3.14]
install_variant: ["pip"]
include:
- python-version: 3.12
install_variant: "rpm.fedora.40"
- python-version: 3.12
install_variant: "deb.ubuntu.noble"
fail-fast: false

steps:
- run: echo "Job triggered by a ${{ github.event_name }} event on branch is ${{ github.ref }} in repository is ${{ github.repository }}, runner on ${{ runner.os }}"
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: 'packaging/pip_requirements.txt'
if: matrix.install_variant == 'pip'
- name: Display Python version
run: python -c "import sys; print(sys.version)"
if: matrix.install_variant == 'pip'
- name: Refresh system packager mirrors and packages
run: sudo apt-get -y update
- name: Install non-python dependencies using system packager
run: |
# ocr
sudo apt-get -y install pkg-config tesseract-ocr libtesseract-dev
# xdotool
sudo apt-get -y install xdotool x11-apps imagemagick
# vncdotool
sudo apt-get -y install xfonts-base x11vnc
# pyautogui
sudo apt-get -y install gnome-screenshot
# pyqt6 for integration testing
sudo apt-get install libegl1 libxcb-cursor0
if: matrix.install_variant == 'pip'
- name: Install any dependencies and build the package
run: |
pip --default-timeout=60 install -r packaging/pip_requirements.txt
# build tools
pip install wheel twine
pushd packaging
python3 setup.py sdist bdist_wheel
popd
if: matrix.install_variant == 'pip'
- run: sleep 3
- name: Cache large ML models
uses: actions/cache@v4
with:
path: ~/.cache/torch/hub/checkpoints
key: fasterrcnn-258fb6c6+maskrcnn-bf2d0c1e
- name: Prepare virtual screen (fake display)
run: |
sudo apt-get -y install libx11-dev libxtst-dev xvfb vim-common
sudo apt-get install -y x11-utils libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0
Xvfb :99 -screen 0 1024x768x24 &> /tmp/xvfb.log &
sudo touch ~/.Xauthority
sudo xauth -f ~/.Xauthority add ${HOST}:99 . $(xxd -l 16 -p /dev/urandom)
sudo chmod a+rxw ~/.Xauthority
# give xvfb some time to start
sleep 3
- name: Run current semi-isolation semi-integration tests (to be separated in the future)
run: |
if [[ "${{ matrix.install_variant }}" != "pip" ]]; then cd packaging && bash packager_docker.sh;
else cd tests && bash coverage_analysis.sh; fi
env:
INSTALL_VARIANT: ${{ matrix.install_variant }}
TESSDATA_PREFIX: /usr/share/tesseract-ocr/5/tessdata
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: tests/coverage.xml
verbose: true
if: matrix.install_variant == 'pip'
- run: echo "🥑 This job's status is ${{ job.status }}."

- name: Set Artifacts and Release Variables
id: set_vars
run: |
VERSION="$( cat /home/runner/work/guibot/guibot/VERSION )"
# Get the part before the last dot "0.51" for example
prefix=${VERSION%.*}
# Get the part after the last dot "1" for example
suffix=${VERSION##*.}
# Combine them with a hyphen "0.51.1" -> "0.51-1"
VERSION_HYPHEN="${prefix}-${suffix}"
if [[ "$(echo ${{ matrix.install_variant }} | cut -d '.' -f 2)" == "fedora" ]]; then
readonly variant_version=$(echo ${{ matrix.install_variant }} | cut -d '.' -f 3)
PACKAGE_NAME="python3-guibot-${VERSION_HYPHEN}.fc${variant_version}.x86_64.rpm"
PACKAGE_PATH="/home/runner/work/guibot/guibot/${PACKAGE_NAME}"
elif [[ "${{ matrix.install_variant }}" == "pip" ]]; then
PACKAGE_NAME="guibot-${VERSION}-py3-none-any.whl"
PACKAGE_PATH="/home/runner/work/guibot/guibot/packaging/dist/${PACKAGE_NAME}"
else
PACKAGE_NAME="python3-guibot_${VERSION_HYPHEN}_all.deb"
PACKAGE_PATH="/home/runner/work/guibot/guibot/${PACKAGE_NAME}"
fi
echo "artifact_name=$PACKAGE_NAME" >> $GITHUB_ENV
echo "artifact_full_path=$PACKAGE_PATH" >> $GITHUB_ENV
- name: Upload Artifacts
uses: actions/upload-artifact@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: '${{ env.artifact_name }}'
path: '${{ env.artifact_full_path }}'
if: matrix.install_variant != 'pip' || matrix.python-version == 3.13
- run: echo "Job triggered by a ${{ github.event_name }} event on branch is ${{ github.ref }} in repository is ${{ github.repository }}, runner on ${{ runner.os }}"
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
if: matrix.install_variant == 'pip'
- name: Display Python version
run: python -c "import sys; print(sys.version)"
if: matrix.install_variant == 'pip'
- name: Refresh system packager mirrors and packages
run: sudo apt-get -y update
- name: Install non-python dependencies using system packager
run: |
# ocr
sudo apt-get -y install pkg-config tesseract-ocr libtesseract-dev
# xdotool
sudo apt-get -y install xdotool x11-apps imagemagick
# vncdotool
sudo apt-get -y install xfonts-base x11vnc
# pyautogui
sudo apt-get -y install gnome-screenshot
# pyqt6 for integration testing
sudo apt-get install libegl1 libxcb-cursor0
if: matrix.install_variant == 'pip'
- name: Install any dependencies and build the package
run: |
pip --default-timeout=60 install -r packaging/pip_requirements.txt
# build tools
pip install wheel twine
pushd packaging
python3 setup.py sdist bdist_wheel
popd
if: matrix.install_variant == 'pip'
- run: sleep 3
- name: Cache large ML models
uses: actions/cache@v4
with:
path: ~/.cache/torch/hub/checkpoints
key: fasterrcnn-258fb6c6+maskrcnn-bf2d0c1e
- name: Prepare virtual screen (fake display)
run: |
sudo apt-get -y install libx11-dev libxtst-dev xvfb vim-common
sudo apt-get install -y x11-utils libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0
Xvfb :99 -screen 0 1024x768x24 &> /tmp/xvfb.log &
sudo touch ~/.Xauthority
sudo xauth -f ~/.Xauthority add ${HOST}:99 . $(xxd -l 16 -p /dev/urandom)
sudo chmod a+rxw ~/.Xauthority
# give xvfb some time to start
sleep 3
- name: Run current semi-isolation semi-integration tests (to be separated in the future)
env:
INSTALL_VARIANT: ${{ matrix.install_variant }}
TESSDATA_PREFIX: /usr/share/tesseract-ocr/5/tessdata
DISABLE_AUTOPY: ${{ matrix.python-version == '3.14' && '1' || '0' }}
run: |
if [[ "${{ matrix.install_variant }}" != "pip" ]]; then cd packaging && bash packager_docker.sh;
else cd tests && bash coverage_analysis.sh; fi
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: tests/coverage.xml
verbose: true
if: matrix.install_variant == 'pip'
- run: echo "🥑 This job's status is ${{ job.status }}."

- name: Set Artifacts and Release Variables
id: set_vars
run: |
VERSION="$( cat /home/runner/work/guibot/guibot/VERSION )"
# Get the part before the last dot "0.51" for example
prefix=${VERSION%.*}
# Get the part after the last dot "1" for example
suffix=${VERSION##*.}
# Combine them with a hyphen "0.51.1" -> "0.51-1"
VERSION_HYPHEN="${prefix}-${suffix}"
PACKAGE_NAME="guibot-${VERSION}-py3-none-any.whl"
PACKAGE_PATH="/home/runner/work/guibot/guibot/packaging/dist/${PACKAGE_NAME}"
echo "artifact_name=$PACKAGE_NAME" >> $GITHUB_ENV
echo "artifact_full_path=$PACKAGE_PATH" >> $GITHUB_ENV
- name: Upload Artifacts
uses: actions/upload-artifact@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: '${{ env.artifact_name }}'
path: '${{ env.artifact_full_path }}'

windows:
name: Windows with any available coverage
runs-on: windows-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
cache-dependency-path: 'packaging/pip_requirements.txt'
- name: Local pip installation on Windows
run: |
cd packaging
pip install --upgrade pip
pip install -r pip_requirements.txt
pip install .
- name: Cache large ML models
uses: actions/cache@v4
with:
path: ~/.cache/torch/hub/checkpoints
key: fasterrcnn-258fb6c6+maskrcnn-bf2d0c1e
- name: Prepare virtual screen (fake display)
run: |
pip install wxPython==4.2.4
python -c "import wx; app = wx.App(); display = wx.Display()"
- name: Run current semi-isolation semi-integration tests (to be separated in the future)
run: |
cd tests
bash coverage_analysis.sh
env:
# tesseract doesn't have original installers for Windows
DISABLE_OCR: 1
# drag/drop and in particular drop has problems with AutoPy on Windows
DISABLE_DRAG: 1
# requires X server and thus only available on Linux
DISABLE_XDOTOOL: 1
# requires VNC server and thus only available on Linux
DISABLE_VNCDOTOOL: 1

- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Local pip installation on Windows
run: |
cd packaging
pip install --upgrade pip
pip install -r pip_requirements.txt
pip install .
- name: Cache large ML models
uses: actions/cache@v4
with:
path: ~/.cache/torch/hub/checkpoints
key: fasterrcnn-258fb6c6+maskrcnn-bf2d0c1e
- name: Prepare virtual screen (fake display)
run: |
pip install wxPython==4.2.4
python -c "import wx; app = wx.App(); display = wx.Display()"
- name: Run current semi-isolation semi-integration tests (to be separated in the future)
env:
# tesseract doesn't have original installers for Windows
DISABLE_OCR: 1
# drag/drop and in particular drop has problems with AutoPy on Windows
DISABLE_DRAG: 1
# requires X server and thus only available on Linux
DISABLE_XDOTOOL: 1
# requires VNC server and thus only available on Linux
DISABLE_VNCDOTOOL: 1
run: |
cd tests
bash coverage_analysis.sh
macos:
name: MacOS with any available coverage
# TODO: downgrade from "latest" to 14 due to MacOS 15 suddenly failing a lot of tests
# -> should be lifted once we add image logging artifacts to easily debug CI environment
runs-on: macos-14
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
cache-dependency-path: 'packaging/pip_requirements.txt'
- name: Install non-python dependencies using system packager
run: |
# ocr
brew install tesseract
- name: Local pip installation on macOS
run: |
cd packaging
pip install --upgrade pip
pip install -r pip_requirements.txt
pip install .
- name: Cache large ML models
uses: actions/cache@v4
with:
path: ~/.cache/torch/hub/checkpoints
key: fasterrcnn-258fb6c6+maskrcnn-bf2d0c1e
- name: Prepare virtual screen (fake display)
run: |
pip install wxPython==4.2.4
python -c "import wx; app = wx.App(); display = wx.Display()"
- name: Run current semi-isolation semi-integration tests (to be separated in the future)
run: |
cd tests
bash coverage_analysis.sh
env:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install non-python dependencies using system packager
run: |
# ocr
brew install tesseract
- name: Local pip installation on macOS
run: |
cd packaging
pip install --upgrade pip
pip install -r pip_requirements.txt
pip install .
- name: Cache large ML models
uses: actions/cache@v4
with:
path: ~/.cache/torch/hub/checkpoints
key: fasterrcnn-258fb6c6+maskrcnn-bf2d0c1e
- name: Prepare virtual screen (fake display)
run: |
pip install wxPython==4.2.4
python -c "import wx; app = wx.App(); display = wx.Display()"
- name: Run current semi-isolation semi-integration tests (to be separated in the future)
env:
# drag/drop and in particular drop has problems with AutoPy on macOS
DISABLE_DRAG: 1
# requires X server and thus only available on Linux
Expand All @@ -218,3 +198,6 @@ jobs:
DISABLE_VNCDOTOOL: 1
# TODO: enable PyAutoGUI for macOS if there is more interest
DISABLE_PYAUTOGUI: 1
run: |
cd tests
bash coverage_analysis.sh
3 changes: 1 addition & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
8 changes: 6 additions & 2 deletions guibot/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,12 @@ def __synchronize_backend(
"Backend '%s' has not been configured yet" % backend
)

import autopy

try:
import autopy
except ImportError:
raise UninitializedBackendError(
"AutoPy is not installed for this Python version/platform"
)
self._backend_obj = autopy

self._scale = self._backend_obj.screen.scale()
Expand Down
Loading