Skip to content

Commit 89dfda2

Browse files
committed
Merge branch 'release/2019.1020'
2 parents e9faf24 + 3c9ec0e commit 89dfda2

26 files changed

+133
-262
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
bin/
22
venv/
3-
.git/
43
.buildozer/
54
.pytest_cache/
65
.tox/

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ bin/
88
build/
99
dist/
1010
*.egg-info/
11+
htmlcov/
12+
.coverage
13+
.coverage.*

.travis.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,15 @@ language: generic
44

55
services:
66
- docker
7+
- xvfb
78

89
env:
9-
global:
10-
- DISPLAY=:99.0
1110
matrix:
1211
- TAG=zbarcam-linux DOCKERFILE=dockerfiles/Dockerfile-linux COMMAND='make test'
13-
- TAG=zbarcam-linux DOCKERFILE=dockerfiles/Dockerfile-linux COMMAND='make uitest'
1412
- TAG=zbarcam-android DOCKERFILE=dockerfiles/Dockerfile-android COMMAND='buildozer android debug'
1513

16-
before_install:
17-
- sudo apt update -qq > /dev/null
18-
- sudo apt install --yes --no-install-recommends xvfb
19-
20-
install:
21-
- docker build --tag=$TAG --file=$DOCKERFILE --build-arg CI .
22-
2314
before_script:
24-
- sh -e /etc/init.d/xvfb start
15+
- docker build --tag=$TAG --file=$DOCKERFILE --build-arg CI .
2516

2617
script:
27-
- travis_wait docker run -e DISPLAY -e CI -v /tmp/.X11-unix:/tmp/.X11-unix $TAG $COMMAND
18+
- travis_wait 30 docker run --env-file dockerfiles/env.list -v /tmp/.X11-unix:/tmp/.X11-unix $TAG $COMMAND

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## [2019.1020]
4+
5+
- Setup coverage testing
6+
- Bump to `xcamera>=2019.928`
7+
- Continuous integration improvements
8+
39
## [2019.0910]
410

511
- Use new `xcamera` from PyPI

Makefile

Lines changed: 54 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,69 @@
1-
VENV_NAME=venv
2-
PIP=$(VENV_NAME)/bin/pip
1+
VIRTUAL_ENV ?= venv
2+
PIP=$(VIRTUAL_ENV)/bin/pip
33
TOX=`which tox`
4-
GARDEN=$(VENV_NAME)/bin/garden
5-
PYTHON=$(VENV_NAME)/bin/python
6-
ISORT=$(VENV_NAME)/bin/isort
7-
FLAKE8=$(VENV_NAME)/bin/flake8
4+
PYTHON=$(VIRTUAL_ENV)/bin/python
5+
ISORT=$(VIRTUAL_ENV)/bin/isort
6+
FLAKE8=$(VIRTUAL_ENV)/bin/flake8
7+
PYTEST=$(VIRTUAL_ENV)/bin/pytest
88
TWINE=`which twine`
99
SOURCES=src/ tests/ setup.py setup_meta.py
1010
# using full path so it can be used outside the root dir
1111
SPHINXBUILD=$(shell realpath venv/bin/sphinx-build)
1212
DOCS_DIR=doc
1313
SYSTEM_DEPENDENCIES= \
14-
libpython$(PYTHON_VERSION)-dev \
14+
build-essential \
15+
ccache \
16+
cmake \
17+
curl \
18+
git \
1519
libsdl2-dev \
20+
libsdl2-image-dev \
21+
libsdl2-mixer-dev \
22+
libsdl2-ttf-dev \
23+
libpython3.6-dev \
24+
libpython$(PYTHON_VERSION)-dev \
1625
libzbar-dev \
26+
pkg-config \
27+
python3.6 \
28+
python3.6-dev \
29+
python$(PYTHON_VERSION) \
30+
python$(PYTHON_VERSION)-dev \
1731
tox \
1832
virtualenv
19-
OS=$(shell lsb_release -si)
33+
OS=$(shell lsb_release -si 2>/dev/null || uname)
2034
PYTHON_MAJOR_VERSION=3
21-
PYTHON_MINOR_VERSION=6
35+
PYTHON_MINOR_VERSION=7
2236
PYTHON_VERSION=$(PYTHON_MAJOR_VERSION).$(PYTHON_MINOR_VERSION)
37+
PYTHON_MAJOR_MINOR=$(PYTHON_MAJOR_VERSION)$(PYTHON_MINOR_VERSION)
2338
PYTHON_WITH_VERSION=python$(PYTHON_VERSION)
2439

2540

2641
all: system_dependencies virtualenv
2742

28-
venv:
29-
test -d venv || virtualenv -p $(PYTHON_WITH_VERSION) venv
43+
system_dependencies:
44+
ifeq ($(OS), Ubuntu)
45+
sudo apt install --yes --no-install-recommends $(SYSTEM_DEPENDENCIES)
46+
endif
3047

31-
virtualenv: venv
48+
$(VIRTUAL_ENV):
49+
virtualenv -p $(PYTHON_WITH_VERSION) $(VIRTUAL_ENV)
3250
$(PIP) install Cython==0.28.6
33-
$(PIP) install -r requirements/requirements.txt
51+
$(PIP) install -r requirements.txt
52+
53+
virtualenv: $(VIRTUAL_ENV)
3454

3555
virtualenv/test: virtualenv
3656
$(PIP) install -r requirements/requirements-test.txt
3757

38-
system_dependencies:
39-
ifeq ($(OS), Ubuntu)
40-
sudo apt install --yes --no-install-recommends $(SYSTEM_DEPENDENCIES)
41-
endif
42-
43-
run/linux: virtualenv
58+
run: virtualenv
4459
$(PYTHON) src/main.py
4560

46-
run: run/linux
47-
4861
test:
4962
$(TOX)
63+
@if test -n "$$CI"; then .tox/py$(PYTHON_MAJOR_MINOR)/bin/coveralls; fi; \
5064

51-
uitest: virtualenv/test
52-
PYTHONPATH=src $(PYTHON) -m unittest discover --top-level-directory=. --start-directory=tests/ui/
65+
pytest: virtualenv/test
66+
PYTHONPATH=src $(PYTEST) --cov src/ --cov-report html tests/
5367

5468
lint/isort-check: virtualenv/test
5569
$(ISORT) --check-only --recursive --diff $(SOURCES)
@@ -65,7 +79,7 @@ lint: lint/isort-check lint/flake8
6579
docs/clean:
6680
rm -rf $(DOCS_DIR)/build/
6781

68-
docs:
82+
docs: virtualenv
6983
cd $(DOCS_DIR) && SPHINXBUILD=$(SPHINXBUILD) make html
7084

7185
release/clean:
@@ -80,9 +94,21 @@ release/upload:
8094
$(TWINE) upload dist/*
8195

8296
clean: release/clean docs/clean
83-
py3clean src/
84-
find src/ -type d -name "__pycache__" -exec rm -r {} +
85-
find src/ -type d -name "*.egg-info" -exec rm -r {} +
97+
py3clean .
98+
find . -type d -name "__pycache__" -exec rm -r {} +
99+
find . -type d -name "*.egg-info" -exec rm -r {} +
86100

87101
clean/all: clean
88-
rm -rf $(VENV_NAME) .tox/
102+
rm -rf $(VIRTUAL_ENV) .tox/
103+
104+
docker/build:
105+
docker build --tag=zbarcam-linux --file=dockerfiles/Dockerfile-linux .
106+
107+
docker/run/test:
108+
docker run --env-file dockerfiles/env.list -v /tmp/.X11-unix:/tmp/.X11-unix zbarcam-linux 'make test'
109+
110+
docker/run/app:
111+
docker run --env-file dockerfiles/env.list -v /tmp/.X11-unix:/tmp/.X11-unix --device=/dev/video0:/dev/video0 zbarcam-linux 'make run'
112+
113+
docker/run/shell:
114+
docker run --env-file dockerfiles/env.list -v /tmp/.X11-unix:/tmp/.X11-unix --device=/dev/video0:/dev/video0 -it --rm zbarcam-linux

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# zbarcam
22

33
[![Build Status](https://travis-ci.org/kivy-garden/zbarcam.svg?branch=develop)](https://travis-ci.org/kivy-garden/zbarcam)
4+
[![Coverage Status](https://coveralls.io/repos/github/kivy-garden/zbarcam/badge.svg?branch=develop)](https://coveralls.io/github/kivy-garden/zbarcam?branch=develop)
45
[![PyPI version](https://badge.fury.io/py/zbarcam.svg)](https://badge.fury.io/py/zbarcam)
56
[![Documentation Status](https://readthedocs.org/projects/zbarcam/badge/?version=latest)](https://zbarcam.readthedocs.io/en/latest/?badge=latest)
67

@@ -37,7 +38,7 @@ make system_dependencies
3738

3839
Install zbarcam:
3940
```sh
40-
pip install --upgrade zbarcam
41+
pip install zbarcam
4142
```
4243
Then import it in your Python code via:
4344
```python

buildozer.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ requirements =
4444
Pillow==5.2.0,
4545
python3,
4646
pyzbar==0.1.8,
47-
xcamera
47+
xcamera==2019.928
4848
4949
5050
# (str) Custom source folders for requirements

dockerfiles/Dockerfile-android

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ENV WORK_DIR="${HOME_DIR}" \
1717
ENV DOCKERFILES_VERSION="v20190902" \
1818
DOCKERFILES_URL="https://raw.githubusercontent.com/AndreMiras/dockerfiles"
1919
ENV MAKEFILES_URL="${DOCKERFILES_URL}/${DOCKERFILES_VERSION}/buildozer_android"
20-
ENV BUILDOZER_VERSION="182d13f"
20+
ENV BUILDOZER_VERSION="81c31c4"
2121

2222

2323
# configure locale
@@ -29,7 +29,7 @@ ENV LANG="en_US.UTF-8" \
2929
LC_ALL="en_US.UTF-8"
3030

3131
# install system dependencies
32-
RUN apt install -qq --yes --no-install-recommends \
32+
RUN apt update -qq > /dev/null && apt install -qq --yes --no-install-recommends \
3333
autoconf \
3434
automake \
3535
ca-certificates \
@@ -54,20 +54,18 @@ RUN apt install -qq --yes --no-install-recommends \
5454
xz-utils \
5555
zip
5656

57-
# prepare non root env
58-
RUN useradd --create-home --shell /bin/bash ${USER}
59-
# with sudo access and no password
60-
RUN usermod -append --groups sudo ${USER}
61-
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
57+
# prepare non root env, with sudo access and no password
58+
RUN useradd --create-home --shell /bin/bash ${USER} && \
59+
usermod -append --groups sudo ${USER} && \
60+
echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
6261

6362
USER ${USER}
6463
WORKDIR ${WORK_DIR}
6564

66-
# install buildozer and dependencies
67-
RUN curl --location --progress-bar ${MAKEFILES_URL}/buildozer.mk --output buildozer.mk
68-
RUN make -f buildozer.mk
69-
# enforces buildozer master until next release
70-
RUN pip3 install --upgrade https://github.com/kivy/buildozer/archive/${BUILDOZER_VERSION}.zip
65+
# install buildozer & dependencies and enforces buildozer master until next release
66+
RUN curl --location --progress-bar ${MAKEFILES_URL}/buildozer.mk --output buildozer.mk && \
67+
make -f buildozer.mk && \
68+
pip3 install --upgrade https://github.com/kivy/buildozer/archive/${BUILDOZER_VERSION}.zip
7169

7270
COPY . ${WORK_DIR}
7371
# limits the amount of logs for Travis

dockerfiles/Dockerfile-linux

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,21 @@ ENV LANG="en_US.UTF-8" \
2626

2727
# install system dependencies
2828
RUN apt install --yes --no-install-recommends \
29-
build-essential \
30-
ccache \
31-
cmake \
32-
curl \
33-
libsdl2-dev \
34-
libsdl2-image-dev \
35-
libsdl2-mixer-dev \
36-
libsdl2-ttf-dev \
37-
libpython3.6-dev \
38-
libpython3.7-dev \
39-
libzbar-dev \
4029
lsb-release \
4130
make \
42-
pkg-config \
43-
python3.6 \
44-
python3.6-dev \
45-
python3.7 \
46-
python3.7-dev \
47-
sudo \
48-
tox \
49-
virtualenv
31+
sudo
5032

5133
# prepare non root env
5234
RUN useradd --create-home --shell /bin/bash ${USER}
5335
# with sudo access and no password
5436
RUN usermod -append --groups sudo ${USER}
5537
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
38+
# gives access to video so the camera can be accessed within the container
39+
RUN gpasswd --add ${USER} video
5640

5741
USER ${USER}
5842
WORKDIR ${WORK_DIR}
5943
COPY . ${WORK_DIR}
6044

61-
RUN make
45+
RUN sudo make system_dependencies && make virtualenv
6246
ENTRYPOINT ["./dockerfiles/start.sh"]

dockerfiles/env.list

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# used by coveralls.io, refs:
2+
# https://coveralls-python.readthedocs.io/en/latest/usage/tox.html#travisci
3+
CI
4+
TRAVIS
5+
TRAVIS_BRANCH
6+
TRAVIS_JOB_ID
7+
TRAVIS_PULL_REQUEST
8+
# used for running UI tests
9+
DISPLAY

0 commit comments

Comments
 (0)