Skip to content

Commit

Permalink
Merge pull request #39 from apiad/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
apiad authored Dec 22, 2019
2 parents e621f3d + 7044a0e commit 52e2a35
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 60 deletions.
11 changes: 8 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ cache: pip

python:
- 3.6
- 3.7
- 3.8
env:
global:
- BUILD_ENVIRONMENT=development

install: make install-bare
script: make test
after_success: make cov
install: make dev-install
script: make dev-test-full
after_success: make dev-cov

notifications:
webhooks: https://fathomless-fjord-24024.herokuapp.com/notify
Expand Down
18 changes: 10 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
version: "3"

services:
auditorium:
image: docker.pkg.github.com/apiad/auditorium/auditorium:latest
build: "."
volumes:
- "./:/code"
network_mode: host
command: auditorium demo
working_dir: "/"
auditorium-tester:
container_name: auditorium-tester-${PYTHON_VERSION}
image: docker.pkg.github.com/apiad/auditorium/auditorium:${PYTHON_VERSION}
build:
context: "."
args:
PYTHON_VERSION: ${PYTHON_VERSION}
volumes:
- "./:/code"
command: make dev-test-full
28 changes: 19 additions & 9 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
FROM python:3.6
# =====================
# Generic build system
# ---------------------

ARG PYTHON_VERSION

FROM python:${PYTHON_VERSION}

RUN echo Building image for Python:${PYTHON_VERSION}

# ==========================================
# Project-specific installation instruction
# ------------------------------------------

WORKDIR /code
COPY pyproject.toml poetry.lock makefile /code/

ENV XDG_CACHE_HOME="/opt/venv/cache"
ENV POETRY_VIRTUALENVS_PATH="/opt/venv"
ENV BUILD_ENVIRONMENT="development"
ENV XDG_CACHE_HOME="/opt/dev/cache"

RUN make install-bare
# Use system's Python for installing dev tools
RUN make dev-install

COPY . /code

RUN poetry install
RUN make test

VOLUME [ "/opt/venv" ]
CMD bash
VOLUME [ "/opt/dev" ]
CMD [ "bash" ]
63 changes: 44 additions & 19 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,57 @@
.PHONY: build clean install test lint cov
.PHONY: clean lint test-fast test-full shell

# TODO: Update your project folder
PROJECT=auditorium
BASE_VERSION := 3.8
ALL_VERSIONS := 3.6 3.7 3.8

test-fast:
PYTHON_VERSION=${BASE_VERSION} docker-compose run auditorium-tester make dev-test-fast

shell:
PYTHON_VERSION=${BASE_VERSION} docker-compose run auditorium-tester bash

build:
poetry build
PYTHON_VERSION=${BASE_VERSION} docker-compose run auditorium-tester make dev-build

clean:
git clean -fxd

install-base:
pip install -U pip
pip install poetry
lint:
PYTHON_VERSION=${BASE_VERSION} docker-compose run auditorium-tester poetry run pylint auditorium

install-bare: install-base
poetry config virtualenvs.create false
poetry install
test-full:
$(foreach VERSION, $(ALL_VERSIONS), PYTHON_VERSION=${VERSION} docker-compose up;)

docker-build:
$(foreach VERSION, $(ALL_VERSIONS), PYTHON_VERSION=${VERSION} docker-compose build;)

docker-push:
$(foreach VERSION, $(ALL_VERSIONS), PYTHON_VERSION=${VERSION} docker-compose push;)

install: install-base
# Below are the commands that will be run INSIDE the development environment, i.e., inside Docker or Travis
# These commands are NOT supposed to be run by the developer directly, and will fail to do so.

.PHONY: dev-ensure dev-build dev-install dev-test-fast dev-test-full dev-cov

dev-ensure:
# Check if you are inside a development environment
echo ${BUILD_ENVIRONMENT} | grep "development" >> /dev/null

dev-build: dev-ensure
poetry build

dev-install: dev-ensure
pip install poetry
poetry config virtualenvs.create false
poetry install

test:
poetry run auditorium test && \
poetry run mypy -p auditorium --ignore-missing-imports && \
poetry run pytest --doctest-modules --cov=$(PROJECT) --cov-report=xml -v
dev-test-fast: dev-ensure
python -m mypy -p auditorium --ignore-missing-imports
python -m pytest --doctest-modules --cov=auditorium --cov-report=term-missing -v

lint:
poetry run pylint $(PROJECT)
dev-test-full: dev-ensure
python -m auditorium test
python -m mypy -p auditorium --ignore-missing-imports
python -m pytest --doctest-modules --cov=auditorium --cov-report=xml

cov:
poetry run codecov
dev-cov: dev-ensure
python -m codecov
40 changes: 20 additions & 20 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "MIT"
readme = "README.md"

[tool.poetry.dependencies]
python = "~3.6"
python = "^3.6"
markdown = "^3.1.1"
fire = "^0.2.1"
sanic = "^19.9.0"
Expand Down

0 comments on commit 52e2a35

Please sign in to comment.