Skip to content

Commit

Permalink
Merge pull request #38 from apiad/feature/pyenv
Browse files Browse the repository at this point in the history
Update dev environment
  • Loading branch information
apiad authored Dec 22, 2019
2 parents a495c47 + 79491c8 commit 7044a0e
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 64 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ cache: pip

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

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

notifications:
Expand Down
16 changes: 10 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
version: "3"

services:
auditorium:
image: docker.pkg.github.com/apiad/auditorium/auditorium:latest
build: "."
volumes:
- "./:/code"
command: make test
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
21 changes: 17 additions & 4 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +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 BUILD_ENVIRONMENT="development"
ENV XDG_CACHE_HOME="/opt/venv/cache"
ENV XDG_CACHE_HOME="/opt/dev/cache"

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

COPY . /code

VOLUME [ "/opt/venv" ]
CMD bash
VOLUME [ "/opt/dev" ]
CMD [ "bash" ]
49 changes: 28 additions & 21 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
.PHONY: clean lint test test-full
.PHONY: clean lint test-fast test-full shell

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:
docker-compose run auditorium make dev-build
PYTHON_VERSION=${BASE_VERSION} docker-compose run auditorium-tester make dev-build

clean:
git clean -fxd

lint:
docker-compose run auditorium poetry run pylint auditorium

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

test-full:
docker-compose run auditorium make dev-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;)

# 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-build clean dev-install dev-test dev-cov dev-ensure
.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
Expand All @@ -28,23 +40,18 @@ dev-build: dev-ensure
poetry build

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

dev-test-full: dev-ensure
tox

dev-test-simple: dev-ensure
poetry run mypy -p auditorium --ignore-missing-imports
poetry run pytest --doctest-modules --cov=auditorium --cov-report=term-missing -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

dev-test-single: dev-ensure
poetry run auditorium test
poetry run mypy -p auditorium --ignore-missing-imports
poetry run pytest --doctest-modules --cov=auditorium --cov-report=xml
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

dev-cov: dev-ensure
poetry run codecov
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
11 changes: 0 additions & 11 deletions tox.ini

This file was deleted.

0 comments on commit 7044a0e

Please sign in to comment.