forked from constverum/ProxyBroker
-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from a5r0n/build/use-poetry
build/use poetry
- Loading branch information
Showing
5 changed files
with
759 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ] |
Oops, something went wrong.