diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b3e25c2..f68c9ba 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,6 +10,6 @@ jobs: with: python-version: 3.8 architecture: x64 - - run: make setup - - run: make check + - run: make setup-venv + - run: make checks - run: bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8812897..767e168 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store .idea/ +.vscode/ .venv/ _build/ notebooks/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dbea447 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +ARG BASE_IMAGE=python:3.8 + +FROM ${BASE_IMAGE} as base + +LABEL maintainer='eugeneyan ' + +# Use the opt directory as our dev directory +WORKDIR /opt + +ENV PYTHONUNBUFFERED TRUE + +COPY requirements.dev . +COPY requirements.prod . + +# Install python dependencies +RUN pip install --upgrade pip \ + && pip install --no-cache-dir wheel \ + && pip install --no-cache-dir -r requirements.dev \ + && pip install --no-cache-dir -r requirements.prod \ + && pip list \ No newline at end of file diff --git a/Makefile b/Makefile index 2807060..0d808ef 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,14 @@ -setup: +.PHONY: setup-venv setup clean-pyc clean-test test mypy lint docs check + +setup-venv: python -m venv .venv && . .venv/bin/activate pip install --upgrade pip pip install -r requirements.dev pip install -r requirements.prod +setup: + DOCKER_BUILDKIT=1 docker build -t dev -f Dockerfile . + clean-pyc: find . -name '*.pyc' -exec rm -f {} + find . -name '*.pyo' -exec rm -f {} + @@ -13,8 +18,11 @@ clean-pyc: clean-test: rm -f .coverage rm -f .coverage.* + find . -name '.pytest_cache' -exec rm -fr {} + clean: clean-pyc clean-test + find . -name '.my_cache' -exec rm -fr {} + + rm -rf logs/ test: clean . .venv/bin/activate && py.test tests --cov=src --cov-report=term-missing --cov-fail-under 95 @@ -30,4 +38,10 @@ docs: FORCE cd docs; . .venv/bin/activate && sphinx-build -b html ./source ./build FORCE: -check: test lint mypy \ No newline at end of file +checks: test lint mypy clean + +run-checks: + docker run --rm -it --name run-checks -v $(shell pwd):/opt -t dev make checks + +bash: + docker run --rm -it --name run-checks -v $(shell pwd):/opt -t dev bash \ No newline at end of file diff --git a/README.md b/README.md index 444ee1b..b63b7f1 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ make setup -B make check ``` -Make a pull request to this repo to see the checks in action 😎 +Make a pull request to this repo to see the checks in action 😎 Here's a [sample pull request](https://github.com/eugeneyan/python-collab-template/pull/1) which initially failed ❌ the checks, and then passed ✅. @@ -175,3 +175,6 @@ jobs: ``` ### 👉 View the [article](https://eugeneyan.com/writing/setting-up-python-project-for-automation-and-collaboration/) for the walkthrough. + +### Todo +- [ ] Update requirements.txt to use `poetry`