Skip to content

Commit

Permalink
Merge pull request #86 from a5r0n/build/use-poetry
Browse files Browse the repository at this point in the history
build/use poetry
  • Loading branch information
bluet authored Aug 22, 2022
2 parents 8367f51 + 09d6166 commit a7763f7
Show file tree
Hide file tree
Showing 5 changed files with 759 additions and 33 deletions.
60 changes: 36 additions & 24 deletions .github/workflows/python-test-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,49 @@ name: Python package

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10']
python-version: ["3.8", "3.9", "3.10"]
poetry-version: ["1.1.14"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements/dev.txt ]; then pip install -U -r requirements/dev.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install and configure Poetry
uses: snok/[email protected]
with:
version: ${{ matrix.poetry-version }}
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Install library
run: poetry install --no-interaction
- name: Lint with flake8
run: |
source .venv/bin/activate
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude .venv
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude .venv
- name: Test with pytest
run: |
source .venv/bin/activate
pytest
32 changes: 24 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
FROM python:3.9-alpine
FROM python:3.9-slim as base

ENV \
# Keeps Python from generating .pyc files in the container
PYTHONDONTWRITEBYTECODE=1 \
# Turns off buffering for easier container logging
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1

RUN \
pip install -U poetry

FROM base as builder

WORKDIR /app
ADD . /app/
RUN apk --no-cache add --update \
gcc musl-dev git ca-certificates libffi-dev openssl \
&& pip install . \
&& rm -rf /var/cache/apk/* \
&& rm -rf /tmp/*
ENTRYPOINT ["proxybroker"]
COPY poetry.lock pyproject.toml ./

RUN poetry config virtualenvs.create false && \
poetry install --no-interaction --no-ansi --no-dev

COPY proxybroker proxybroker
EXPOSE 8888

ENTRYPOINT ["python", "-m", "proxybroker" ]
Loading

0 comments on commit a7763f7

Please sign in to comment.