Skip to content

Commit

Permalink
Introduce poetry to lock dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanfei Shen committed Jun 3, 2021
1 parent be02f38 commit 9c10ea8
Show file tree
Hide file tree
Showing 12 changed files with 1,401 additions and 111 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ env:
jobs:
test:
runs-on: ubuntu-20.04
strategy:
matrix:
poetry-version: [1.1.6]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Install Poetry
run: pip install poetry==${{ matrix.poetry-version }}
- name: Install requirements
run: pip install -r requirements_plus_development_frozen.txt
run: poetry install
- name: Run tests
run: pytest
27 changes: 17 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
FROM python:3.9-slim AS builder

ARG POETRY_VERSION=1.1.4
RUN pip install poetry==$POETRY_VERSION

WORKDIR /src

COPY pyproject.toml poetry.lock README.md pylintrc ./
COPY marge/ ./marge/
RUN poetry export -o requirements.txt && \
poetry build


FROM python:3.9-slim

RUN apt-get update && apt-get install -y \
git-core \
&& \
rm -rf /var/lib/apt/lists/*

WORKDIR /src

ADD requirements_frozen.txt ./
RUN pip install -r ./requirements_frozen.txt
COPY --from=builder /src/requirements.txt /src/dist/marge-*.tar.gz /tmp/

ADD version ./
ADD setup.py ./
ADD marge.app ./
ADD marge/ ./marge/
RUN python ./setup.py install
RUN pip install -r /tmp/requirements.txt && \
pip install /tmp/marge-*.tar.gz

ENTRYPOINT ["marge.app"]
ENTRYPOINT ["marge"]
23 changes: 17 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,25 @@ all: dockerize
.PHONY: bump
bump: bump-requirements

.PHONY: bump-requirements
bump-requirements: clean requirements_frozen.txt
poetry.lock:
poetry install

requirements.txt: poetry.lock
poetry export -o $@

requirements_development.txt: poetry.lock
poetry export --dev -o $@

requirements_frozen.txt: requirements.txt
pip freeze -r $^ > $@
.PHONY: bump-poetry-lock
bump-poetry-lock:
poetry update

requirements_plus_development_frozen.txt: requirements_frozen.txt
pip freeze -r $^ -r requirements_development.txt > $@
.PHONY: clean-requirements
clean-requirements:
rm -rf requirements.txt requirements_development.txt

.PHONY: bump-requirements
bump-requirements: bump-poetry-lock clean-requirements requirements.txt requirements_development.txt

.PHONY: dockerize
dockerize:
Expand Down
12 changes: 0 additions & 12 deletions marge.app

This file was deleted.

19 changes: 19 additions & 0 deletions marge/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from marge.app import main


def run():
try:
main()
except Exception as err:
print('Exception occured')
if hasattr(err, 'stdout'):
# pylint: disable=no-member
print(f'stdout was: {err.stdout}')
if hasattr(err, 'stderr'):
# pylint: disable=no-member
print(f'stderr was: {err.stderr}')
raise


if __name__ == '__main__':
run()
Loading

0 comments on commit 9c10ea8

Please sign in to comment.