-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revamping Travis and Docker setup introducing a `Makefile`. The idea is to move the CI complexity from .travis.yml to `Makefile`. That makes a single entry point via `make` command and reproducible builds via Docker. It makes it easy to run some commands outside docker, such as: ```sh make testapps/python3/armeabi-v7a ``` Or the same command inside docker: ```sh make docker/run/make/testapps/python3/armeabi-v7a ``` This pull request also starts introducing some docker layer cache optimization as needed by #2009 to speed up docker pull/push and rebuilds from cache. It also introduces other Docker images good practices like ordering dependencies alphabetically or always enforcing `apt update` prior install, refs: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/ Subsequent pull requests would simplify the process furthermore and leverage the cache to speed up builds.
- Loading branch information
1 parent
080ac01
commit a975015
Showing
4 changed files
with
156 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# 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 | ||
# used for running UI tests | ||
DISPLAY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
VIRTUAL_ENV ?= venv | ||
PIP=$(VIRTUAL_ENV)/bin/pip | ||
TOX=`which tox` | ||
ACTIVATE=$(VIRTUAL_ENV)/bin/activate | ||
PYTHON=$(VIRTUAL_ENV)/bin/python | ||
FLAKE8=$(VIRTUAL_ENV)/bin/flake8 | ||
PYTEST=$(VIRTUAL_ENV)/bin/pytest | ||
SOURCES=src/ tests/ | ||
PYTHON_MAJOR_VERSION=3 | ||
PYTHON_MINOR_VERSION=6 | ||
PYTHON_VERSION=$(PYTHON_MAJOR_VERSION).$(PYTHON_MINOR_VERSION) | ||
PYTHON_MAJOR_MINOR=$(PYTHON_MAJOR_VERSION)$(PYTHON_MINOR_VERSION) | ||
PYTHON_WITH_VERSION=python$(PYTHON_VERSION) | ||
DOCKER_IMAGE=kivy/python-for-android | ||
ANDROID_SDK_HOME ?= $(HOME)/.android/android-sdk | ||
ANDROID_NDK_HOME ?= $(HOME)/.android/android-ndk | ||
|
||
|
||
all: virtualenv | ||
|
||
$(VIRTUAL_ENV): | ||
virtualenv --python=$(PYTHON_WITH_VERSION) $(VIRTUAL_ENV) | ||
$(PIP) install Cython==0.28.6 | ||
$(PIP) install -e . | ||
|
||
virtualenv: $(VIRTUAL_ENV) | ||
|
||
# ignores test_pythonpackage.py since it runs for too long | ||
test: | ||
$(TOX) -- tests/ --ignore tests/test_pythonpackage.py | ||
@if test -n "$$CI"; then .tox/py$(PYTHON_MAJOR_MINOR)/bin/coveralls; fi; \ | ||
|
||
rebuild_updated_recipes: virtualenv | ||
$(PYTHON) ci/rebuild_updated_recipes.py | ||
|
||
testapps/python2/armeabi-v7a: virtualenv | ||
. $(ACTIVATE) && cd testapps/ && \ | ||
python setup_testapp_python2_sqlite_openssl.py apk --sdk-dir $(ANDROID_SDK_HOME) --ndk-dir $(ANDROID_NDK_HOME) \ | ||
--requirements sdl2,pyjnius,kivy,python2,openssl,requests,sqlite3,setuptools,numpy | ||
|
||
testapps/python3/arm64-v8a: virtualenv | ||
. $(ACTIVATE) && cd testapps/ && \ | ||
python setup_testapp_python3_sqlite_openssl.py apk --sdk-dir $(ANDROID_SDK_HOME) --ndk-dir $(ANDROID_NDK_HOME) \ | ||
--arch=arm64-v8a | ||
|
||
testapps/python3/armeabi-v7a: virtualenv | ||
. $(ACTIVATE) && cd testapps/ && \ | ||
python setup_testapp_python3_sqlite_openssl.py apk --sdk-dir $(ANDROID_SDK_HOME) --ndk-dir $(ANDROID_NDK_HOME) \ | ||
--requirements libffi,sdl2,pyjnius,kivy,python3,openssl,requests,sqlite3,setuptools \ | ||
--arch=armeabi-v7a | ||
|
||
clean: | ||
find . -type d -name "__pycache__" -exec rm -r {} + | ||
find . -type d -name "*.egg-info" -exec rm -r {} + | ||
|
||
clean/all: clean | ||
rm -rf $(VIRTUAL_ENV) .tox/ | ||
|
||
docker/pull: | ||
docker pull $(DOCKER_IMAGE):latest || true | ||
|
||
docker/build: | ||
docker build --cache-from=$(DOCKER_IMAGE) --tag=$(DOCKER_IMAGE) --file=Dockerfile.py3 . | ||
|
||
docker/push: | ||
docker push $(DOCKER_IMAGE) | ||
|
||
docker/run/test: docker/build | ||
docker run --rm --env-file=.env $(DOCKER_IMAGE) 'make test' | ||
|
||
docker/run/command: docker/build | ||
docker run --rm --env-file=.env $(DOCKER_IMAGE) /bin/sh -c "$(COMMAND)" | ||
|
||
docker/run/make/%: docker/build | ||
docker run --rm --env-file=.env $(DOCKER_IMAGE) make $* | ||
|
||
docker/run/shell: docker/build | ||
docker run --rm --env-file=.env -it $(DOCKER_IMAGE) |