Skip to content

Commit

Permalink
build updates
Browse files Browse the repository at this point in the history
  • Loading branch information
amancevice committed Nov 2, 2021
1 parent bd8c637 commit 0901394
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 43 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ name: pytest
on:
pull_request:
push:
schedule:
- cron: "11 21 * * *"
jobs:
pytest:
runs-on: ubuntu-latest
strategy:
matrix:
python:
- 3.7
- 3.8
- 3.9
- "3.7"
- "3.8"
- "3.9"
- "3.10"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,5 @@ dmypy.json
.pyre/

*.iid

Brewfile.lock.json
1 change: 1 addition & 0 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
brew 'twine-pypi'
45 changes: 13 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,41 +1,22 @@
REPO := amancevice/lambda-gateway-python
PYFILES := $(shell find lambda_gateway tests -name '*.py')
SDIST := dist/$(shell python setup.py --fullname).tar.gz
SLEEP := 0
TIMEOUT := 3

.PHONY: all clean images push test up upload

all: dist/lambda-gateway-latest.tar.gz
all: $(SDIST)

clean:
rm -rf dist *.iid .pytest_cache coverage.xml

images: Dockerfile.3.7.iid Dockerfile.3.8.iid

push: Dockerfile.3.7.iid Dockerfile.3.8.iid
docker push --all-tags $(REPO)

test: coverage.xml

up:
SLEEP=$(SLEEP) python -m lambda_gateway -t $(TIMEOUT) lambda_function.lambda_handler
rm -rf dist

upload: $(SDIST)
twine upload $<
upload: Brewfile.lock.json $(SDIST)
twine upload $(SDIST)

Dockerfile.%.iid: dist/lambda-gateway-latest.tar.gz Dockerfile
docker build \
--build-arg PYTHON_VERSION=$* \
--build-arg TARBALL=$< \
--iidfile $@ \
--tag $(REPO):$* \
.
.PHONY: all clean upload

dist/lambda-gateway-latest.tar.gz: $(SDIST)
cp $< $@
$(SDIST): $(PYFILES) Pipfile.lock
pipenv run pytest
python setup.py sdist

dist/lambda-gateway-%.tar.gz: coverage.xml
SETUPTOOLS_SCM_PRETEND_VERSION=$* python setup.py sdist
Brewfile.lock.json: Brewfile
brew bundle

coverage.xml: $(shell find lambda_gateway tests -name '*.py')
pytest
Pipfile.lock: Pipfile
pipenv install --dev
19 changes: 13 additions & 6 deletions lambda_gateway/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import logging
import pkg_resources

try:
__version__ = pkg_resources.get_distribution(__package__).version
except pkg_resources.DistributionNotFound: # pragma: no cover
__version__ = None
from pkg_resources import (get_distribution, DistributionNotFound)


def set_stream_logger(name, level=logging.DEBUG, format_string=None):
Expand All @@ -26,4 +21,16 @@ def set_stream_logger(name, level=logging.DEBUG, format_string=None):
return adapter


def _version():
"""
Helper to get package version.
"""
try:
return get_distribution(__name__).version
except DistributionNotFound: # pragma: no cover
return None


__version__ = _version()

logger = set_stream_logger(__name__)

0 comments on commit 0901394

Please sign in to comment.