Skip to content

Commit 0901394

Browse files
committed
build updates
1 parent bd8c637 commit 0901394

File tree

5 files changed

+33
-43
lines changed

5 files changed

+33
-43
lines changed

.github/workflows/pytest.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@ name: pytest
22
on:
33
pull_request:
44
push:
5-
schedule:
6-
- cron: "11 21 * * *"
75
jobs:
86
pytest:
97
runs-on: ubuntu-latest
108
strategy:
119
matrix:
1210
python:
13-
- 3.7
14-
- 3.8
15-
- 3.9
11+
- "3.7"
12+
- "3.8"
13+
- "3.9"
14+
- "3.10"
1615
steps:
1716
- uses: actions/checkout@v2
1817
- uses: actions/setup-python@v2

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,5 @@ dmypy.json
129129
.pyre/
130130

131131
*.iid
132+
133+
Brewfile.lock.json

Brewfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
brew 'twine-pypi'

Makefile

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,22 @@
1-
REPO := amancevice/lambda-gateway-python
1+
PYFILES := $(shell find lambda_gateway tests -name '*.py')
22
SDIST := dist/$(shell python setup.py --fullname).tar.gz
3-
SLEEP := 0
4-
TIMEOUT := 3
53

6-
.PHONY: all clean images push test up upload
7-
8-
all: dist/lambda-gateway-latest.tar.gz
4+
all: $(SDIST)
95

106
clean:
11-
rm -rf dist *.iid .pytest_cache coverage.xml
12-
13-
images: Dockerfile.3.7.iid Dockerfile.3.8.iid
14-
15-
push: Dockerfile.3.7.iid Dockerfile.3.8.iid
16-
docker push --all-tags $(REPO)
17-
18-
test: coverage.xml
19-
20-
up:
21-
SLEEP=$(SLEEP) python -m lambda_gateway -t $(TIMEOUT) lambda_function.lambda_handler
7+
rm -rf dist
228

23-
upload: $(SDIST)
24-
twine upload $<
9+
upload: Brewfile.lock.json $(SDIST)
10+
twine upload $(SDIST)
2511

26-
Dockerfile.%.iid: dist/lambda-gateway-latest.tar.gz Dockerfile
27-
docker build \
28-
--build-arg PYTHON_VERSION=$* \
29-
--build-arg TARBALL=$< \
30-
--iidfile $@ \
31-
--tag $(REPO):$* \
32-
.
12+
.PHONY: all clean upload
3313

34-
dist/lambda-gateway-latest.tar.gz: $(SDIST)
35-
cp $< $@
14+
$(SDIST): $(PYFILES) Pipfile.lock
15+
pipenv run pytest
16+
python setup.py sdist
3617

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

40-
coverage.xml: $(shell find lambda_gateway tests -name '*.py')
41-
pytest
21+
Pipfile.lock: Pipfile
22+
pipenv install --dev

lambda_gateway/__init__.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import logging
2-
import pkg_resources
3-
4-
try:
5-
__version__ = pkg_resources.get_distribution(__package__).version
6-
except pkg_resources.DistributionNotFound: # pragma: no cover
7-
__version__ = None
2+
from pkg_resources import (get_distribution, DistributionNotFound)
83

94

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

2823

24+
def _version():
25+
"""
26+
Helper to get package version.
27+
"""
28+
try:
29+
return get_distribution(__name__).version
30+
except DistributionNotFound: # pragma: no cover
31+
return None
32+
33+
34+
__version__ = _version()
35+
2936
logger = set_stream_logger(__name__)

0 commit comments

Comments
 (0)