Skip to content

Commit

Permalink
Merge pull request #15 from darrikonn/allow-project-config-from-monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
darrikonn authored Jul 8, 2020
2 parents 7799f96 + 811f21d commit 6f9cf58
Show file tree
Hide file tree
Showing 8 changed files with 1,132 additions and 79 deletions.
43 changes: 21 additions & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,51 +28,50 @@ executors:
version:
description: Python version to use
type: string
default: "3.7"
default: "3.8"
docker:
- image: circleci/python:<<parameters.version>>
environment:
POETRY_VIRTUALENVS_PATH: /home/circleci/td-cli/.cache

references:
container_config: &container_config
working_directory: ~/project
working_directory: ~/td-cli
executor:
name: python
version: <<parameters.python-version>>
parameters:
python-version:
description: Python version to use
type: string
default: "3.7"
default: "3.8"
cache-version:
description: A cache version that may be used for cache busting
type: string
default: "v1"
default: "v2"

commands:
# Use a venv so we don't have to run as root to make caches work
setup_venv_and_install_deps:
description: |
Setup a python venv for the project.
Install project dependencies into the virtual environment using
pip.
Install project dependencies into a virtual environment.
Installs the dependencies declared in setup.py, including any
test, dev, and packaging extra dependencies
Installs the dependencies declared in pyproject.toml, including all
dev dependencies.
parameters:
cache-version:
description: A cache version that may be used for cache busting
type: string
default: "v1"
default: "v2"
steps:
- restore_cache:
key: <<parameters.cache-version>>-pip-cache-{{ checksum "setup.py" }}
- run: python -m venv venv
- run: echo ". venv/bin/activate" >> $BASH_ENV
- run: pip install -e .[test,dev,packaging]
key: <<parameters.cache-version>>-poetry-cache-{{ checksum "poetry.lock" }}
- run: make requirements
- save_cache:
key: <<parameters.cache-version>>-pip-cache-{{ checksum "setup.py" }}
key: <<parameters.cache-version>>-poetry-cache-{{ checksum "poetry.lock" }}
paths:
- venv
- .cache

jobs:
build:
Expand All @@ -83,9 +82,9 @@ jobs:
- setup_venv_and_install_deps:
cache-version: <<parameters.cache-version>>
- persist_to_workspace:
root: ~/project
paths:
- venv
root: ~/td-cli
paths:
- .cache
- Makefile
- todo
- pyproject.toml
Expand All @@ -96,29 +95,29 @@ jobs:
<<: *container_config
steps:
- attach_workspace:
at: ~/project
at: ~/td-cli
- run: make isort

black:
description: Execute code format checks with black
<<: *container_config
steps:
- attach_workspace:
at: ~/project
at: ~/td-cli
- run: make black

flake8:
description: Execute code format checks with flake8
<<: *container_config
steps:
- attach_workspace:
at: ~/project
at: ~/td-cli
- run: make flake8

mypy:
description: Execute code format checks with mypy
<<: *container_config
steps:
- attach_workspace:
at: ~/project
at: ~/td-cli
- run: make mypy
51 changes: 35 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,58 +1,77 @@
### VARIABLES ###

RUN=poetry run
DATE=`date +%Y-%m-%d`
CODE_STYLE_FILE_LIST=todo

ARGS=$(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(ARGS):;@:)


### TARGETS ###

venv:
virtualenv venv
# Install poetry
poetry:
pip3 install poetry

# Install requirements
requirements:
venv/bin/pip install -e ".[dev]"
venv/bin/pip install -e ".[deploy]"
poetry install --no-root

bootstrap: venv requirements
# Install poetry and requirements
dev: poetry requirements

# Spin up shell in virtual environment
venv:
poetry shell

# Lint using flake8
flake8:
venv/bin/flake8 ${CODE_STYLE_FILE_LIST}
${RUN} flake8 ${CODE_STYLE_FILE_LIST}

# Lint using black
black:
venv/bin/black --target-version py37 --check ${CODE_STYLE_FILE_LIST}
${RUN} black --target-version py38 --check ${CODE_STYLE_FILE_LIST}

# Format using black
black_format:
venv/bin/black --target-version py37 ${CODE_STYLE_FILE_LIST}
${RUN} black --target-version py38 ${CODE_STYLE_FILE_LIST}

# Lint using isort
isort:
venv/bin/isort -c -rc ${CODE_STYLE_FILE_LIST}
${RUN} isort -c -rc ${CODE_STYLE_FILE_LIST}

# Format using isort
isort_format:
venv/bin/isort -rc ${CODE_STYLE_FILE_LIST}
${RUN} isort -rc ${CODE_STYLE_FILE_LIST}

# Lint using mypy
mypy:
venv/bin/mypy ${CODE_STYLE_FILE_LIST}
${RUN} mypy ${CODE_STYLE_FILE_LIST}

# Lint using all methods combined
lint: flake8 black isort mypy

# Format using all methods combined
format: black_format isort_format

clean:
-rm -r dist build td_cli.egg-info 2> /dev/null

build:
venv/bin/python3 setup.py sdist bdist_wheel
${RUN} python setup.py sdist bdist_wheel

upload_test:
venv/bin/twine upload --repository-url https://test.pypi.org/legacy/ dist/*
${RUN} upload --repository-url https://test.pypi.org/legacy/ dist/*

upload:
venv/bin/twine upload dist/*
${RUN} upload dist/*

install_test:
venv/bin/python3 -m pip install --index-url https://test.pypi.org/simple/ td-cli
${RUN} python -m pip install --index-url https://test.pypi.org/simple/ td-cli

install:
venv/bin/python3 -m pip install td-cli
${RUN} python -m pip install td-cli

publish_test: clean build upload_test install_test

Expand Down
Loading

0 comments on commit 6f9cf58

Please sign in to comment.