From 28f62524cf7918b1c8c4c194403b790d4e9d21e8 Mon Sep 17 00:00:00 2001 From: Andre Miras Date: Tue, 25 Feb 2025 13:43:02 +0100 Subject: [PATCH] :construction_worker: Migrate to GitHub Actions Also bump a few versions to get the CI to pass. In future iterations we could bump more dependencies. Bumped versions: - Ubunto 18.04 to 24.04 - Python 3.7 to 3.11 & 3.12 - Cython==0.28.6 to Cython==0.29.15 - Kivy==2.0.0rc2 to Kivy==2.3.1 - p4a v2020.04.29 to v2024.01.21 - hostpython3==3.8.1 to hostpython3==3.10.12 - Android NDK 19b to 25b - OpenJDK 8 to 17 --- .github/workflows/android-build.yml | 29 +++++++++++++++++++++ .github/workflows/linux-build.yml | 39 +++++++++++++++++++++++++++++ .travis.yml | 18 ------------- Makefile | 6 ++--- README.md | 3 ++- buildozer.spec | 14 +++++------ dockerfiles/Dockerfile-android | 21 ++++++++++------ dockerfiles/Dockerfile-linux | 2 +- dockerfiles/env.list | 10 +++++--- requirements/requirements-base.txt | 6 ++--- tox.ini | 18 +++++++++++-- 11 files changed, 120 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/android-build.yml create mode 100644 .github/workflows/linux-build.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/android-build.yml b/.github/workflows/android-build.yml new file mode 100644 index 0000000..acc75cd --- /dev/null +++ b/.github/workflows/android-build.yml @@ -0,0 +1,29 @@ +name: Android Build + +on: + # TODO + # push: + pull_request: + +jobs: + android-build: + runs-on: ubuntu-latest + name: Android Build + + steps: + - uses: actions/checkout@v4 + + - name: Set up Docker + uses: docker/setup-buildx-action@v3 + + - name: Build Docker image + run: | + docker build --tag=zbarcam-android \ + --file=dockerfiles/Dockerfile-android \ + --build-arg CI . + + - name: Build Android app + run: | + docker run --env-file dockerfiles/env.list \ + zbarcam-android buildozer android debug + timeout-minutes: 30 diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml new file mode 100644 index 0000000..8098c63 --- /dev/null +++ b/.github/workflows/linux-build.yml @@ -0,0 +1,39 @@ +name: Linux Build + +on: + push: + pull_request: + +jobs: + linux-build: + runs-on: ubuntu-latest + name: Linux Build + + steps: + - uses: actions/checkout@v4 + + - name: Set up Docker + uses: docker/setup-buildx-action@v3 + + - name: Build Docker image + run: | + docker build --tag=zbarcam-linux \ + --file=dockerfiles/Dockerfile-linux \ + --build-arg CI . + + - name: Setup virtual frame buffer + run: | + sudo apt-get update + sudo apt-get install -y xvfb + Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & + echo "DISPLAY=:99" >> $GITHUB_ENV + + - name: Run tests + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + docker run --env-file dockerfiles/env.list \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e DISPLAY=$DISPLAY \ + zbarcam-linux make test + timeout-minutes: 30 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3f289da..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -sudo: required - -language: generic - -services: - - docker - - xvfb - -env: - matrix: - - TAG=zbarcam-linux DOCKERFILE=dockerfiles/Dockerfile-linux COMMAND='make test' - - TAG=zbarcam-android DOCKERFILE=dockerfiles/Dockerfile-android COMMAND='buildozer android debug' - -before_script: - - docker build --tag=$TAG --file=$DOCKERFILE --build-arg CI . - -script: - - travis_wait 30 docker run --env-file dockerfiles/env.list -v /tmp/.X11-unix:/tmp/.X11-unix $TAG $COMMAND diff --git a/Makefile b/Makefile index 97e41b4..34ee97b 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ SYSTEM_DEPENDENCIES= \ libsdl2-image-dev \ libsdl2-mixer-dev \ libsdl2-ttf-dev \ - libpython3.7-dev \ + libpython$(PYTHON_VERSION)-dev \ libpython$(PYTHON_VERSION)-dev \ libzbar-dev \ pkg-config \ @@ -31,7 +31,7 @@ SYSTEM_DEPENDENCIES= \ virtualenv OS=$(shell lsb_release -si 2>/dev/null || uname) PYTHON_MAJOR_VERSION=3 -PYTHON_MINOR_VERSION=7 +PYTHON_MINOR_VERSION=12 PYTHON_VERSION=$(PYTHON_MAJOR_VERSION).$(PYTHON_MINOR_VERSION) PYTHON_MAJOR_MINOR=$(PYTHON_MAJOR_VERSION)$(PYTHON_MINOR_VERSION) PYTHON_WITH_VERSION=python$(PYTHON_VERSION) @@ -46,7 +46,7 @@ endif $(VIRTUAL_ENV): $(PYTHON_WITH_VERSION) -m venv $(VIRTUAL_ENV) - $(PIP) install Cython==0.28.6 + $(PIP) install Cython==0.29.15 $(PIP) install -r requirements.txt virtualenv: $(VIRTUAL_ENV) diff --git a/README.md b/README.md index a27e58c..4da946a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # zbarcam -[![Build Status](https://travis-ci.org/kivy-garden/zbarcam.svg?branch=develop)](https://travis-ci.org/kivy-garden/zbarcam) +[![Android Build](/~https://github.com/kivy-garden/zbarcam/actions/workflows/android-build.yml/badge.svg)](/~https://github.com/kivy-garden/zbarcam/actions/workflows/android-build.yml) +[![Linux Build](/~https://github.com/kivy-garden/zbarcam/actions/workflows/linux-build.yml/badge.svg)](/~https://github.com/kivy-garden/zbarcam/actions/workflows/linux-build.yml) [![Coverage Status](https://coveralls.io/repos/github/kivy-garden/zbarcam/badge.svg?branch=develop)](https://coveralls.io/github/kivy-garden/zbarcam?branch=develop) [![PyPI version](https://badge.fury.io/py/zbarcam.svg)](https://badge.fury.io/py/zbarcam) [![Documentation Status](https://readthedocs.org/projects/zbarcam/badge/?version=latest)](https://zbarcam.readthedocs.io/en/latest/?badge=latest) diff --git a/buildozer.spec b/buildozer.spec index 78eb4ed..506afd8 100644 --- a/buildozer.spec +++ b/buildozer.spec @@ -38,12 +38,12 @@ version.filename = %(source.dir)s/kivy_garden/zbarcam/version.py # comma seperated e.g. requirements = sqlite3,kivy requirements = android, - hostpython3==3.8.1, - Kivy==58e70b1, + hostpython3==3.10.12, + Kivy==2.3.1, libiconv, libzbar, - Pillow==7.0.0, - python3==3.8.1, + Pillow==8.4.0, + python3==3.10.12, pyzbar==0.1.8, xcamera==2019.928 @@ -78,7 +78,7 @@ orientation = portrait osx.python_version = 3 # Kivy version to use -osx.kivy_version = 1.9.1 +osx.kivy_version = 2.3.1 # # Android specific @@ -107,7 +107,7 @@ android.minapi = 21 android.sdk = 20 # (str) Android NDK version to use -android.ndk = 19b +android.ndk = 25b # (int) Android NDK API to use. This is the minimum API your app will support, it should usually match android.minapi. android.ndk_api = 21 @@ -219,7 +219,7 @@ android.arch = armeabi-v7a #p4a.fork = kivy # (str) python-for-android branch to use, defaults to master -p4a.branch = v2020.04.29 +p4a.branch = v2024.01.21 # (str) python-for-android git clone directory (if empty, it will be automatically cloned from github) #p4a.source_dir = diff --git a/dockerfiles/Dockerfile-android b/dockerfiles/Dockerfile-android index 2feb111..ad2d4e6 100644 --- a/dockerfiles/Dockerfile-android +++ b/dockerfiles/Dockerfile-android @@ -7,9 +7,11 @@ # docker run zbarcam-android 'buildozer android debug' # Or for interactive shell: # docker run -it --rm zbarcam-android -FROM ubuntu:18.04 +FROM ubuntu:24.04 ARG CI=false +ARG PYTHON_VERSION=3.12 +ARG JAVA_VERSION=17 ENV USER="user" ENV HOME_DIR="/home/${USER}" ENV WORK_DIR="${HOME_DIR}" \ @@ -35,16 +37,16 @@ RUN apt update -qq > /dev/null && apt install -qq --yes --no-install-recommends git \ libffi-dev \ libltdl-dev \ - libpython3.7-dev \ + libpython${PYTHON_VERSION}-dev \ libssl-dev \ libtool \ make \ - openjdk-8-jdk \ + openjdk-${JAVA_VERSION}-jdk \ + patch \ pkg-config \ - python3.7 \ + python${PYTHON_VERSION} \ + python${PYTHON_VERSION}-venv \ python3-pip \ - python3-setuptools \ - python \ sudo \ unzip \ xz-utils \ @@ -59,8 +61,13 @@ RUN useradd --create-home --shell /bin/bash ${USER} && \ USER ${USER} WORKDIR ${WORK_DIR} +# Create and activate a virtual environment +RUN python3 -m venv ${HOME_DIR}/venv +ENV PATH="${HOME_DIR}/venv/bin:${PATH}" \ + VIRTUAL_ENV="${HOME_DIR}/venv" + # install buildozer & dependencies -RUN pip3 install --user --upgrade buildozer Cython==0.28.6 +RUN pip install --upgrade buildozer setuptools Cython==0.29.33 COPY . ${WORK_DIR} # limits the amount of logs for Travis diff --git a/dockerfiles/Dockerfile-linux b/dockerfiles/Dockerfile-linux index 822fa4d..12c3e25 100644 --- a/dockerfiles/Dockerfile-linux +++ b/dockerfiles/Dockerfile-linux @@ -10,7 +10,7 @@ # docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix zbarcam-linux 'make uitest' # Or for interactive shell: # docker run -it --rm zbarcam-linux -FROM ubuntu:18.04 +FROM ubuntu:24.04 ENV USER="user" ENV HOME_DIR="/home/${USER}" diff --git a/dockerfiles/env.list b/dockerfiles/env.list index 732d46e..223ccf0 100644 --- a/dockerfiles/env.list +++ b/dockerfiles/env.list @@ -1,9 +1,11 @@ # used by coveralls.io, refs: # https://coveralls-python.readthedocs.io/en/latest/usage/tox.html#travisci CI -TRAVIS -TRAVIS_BRANCH -TRAVIS_JOB_ID -TRAVIS_PULL_REQUEST +# TODO: needed? +GITHUB_* +GITHUB_ACTIONS +GITHUB_TOKEN +# TODO: needed? +COVERALLS_REPO_TOKEN # used for running UI tests DISPLAY diff --git a/requirements/requirements-base.txt b/requirements/requirements-base.txt index 09f2679..1b87f94 100644 --- a/requirements/requirements-base.txt +++ b/requirements/requirements-base.txt @@ -1,7 +1,7 @@ -Kivy==2.0.0rc2 +Kivy==2.3.1 Kivy-Garden==0.1.4 -numpy==1.18.4 -opencv-python==4.2.0.34 +numpy==1.26.4 +opencv-python==4.8.1.78 Pillow==8.2.0 pyzbar==0.1.8 xcamera==2019.928 diff --git a/tox.ini b/tox.ini index 1b218a0..8061d97 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = pep8,isort-check,py36,py37 +envlist = pep8,isort-check,py312 # no setup.py to be ran skipsdist = True @@ -7,7 +7,10 @@ skipsdist = True setenv = PYTHONPATH = {toxinidir}/src/ SOURCES = src/ tests/ setup.py setup_meta.py -passenv = DISPLAY +passenv = + CI + DISPLAY + GITHUB_* deps = -r{toxinidir}/requirements.txt commands = pytest --cov src/ tests/ @@ -16,3 +19,14 @@ commands = flake8 {env:SOURCES} [testenv:isort-check] commands = isort --check-only --recursive --diff {env:SOURCES} + +# TODO: DRY +# TODO: needed? +[testenv:coveralls] +passenv = + CI + DISPLAY + GITHUB_* +setenv = + COVERALLS_SERVICE_NAME = github +commands = coveralls