-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
still having python issues.
- Loading branch information
mike dupont
committed
Oct 11, 2023
1 parent
ba278e8
commit e93a685
Showing
8 changed files
with
209 additions
and
33 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,112 @@ | ||
name: Pipeline | ||
|
||
on: push | ||
|
||
jobs: | ||
code-quality: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
# - name: Setup Python | ||
# uses: actions/setup-python@v4 | ||
# with: | ||
# python-version: 3.10.12 | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
version: 1.4.1 | ||
virtualenvs-in-project: true | ||
- name: Load cached venv | ||
id: cached-poetry-dependencies | ||
uses: actions/cache@v3 | ||
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: pylint | ||
run: | | ||
source .venv/bin/activate | ||
pylint build tests | ||
- name: black | ||
run: | | ||
source .venv/bin/activate | ||
black --check . | ||
run-tests: | ||
needs: code-quality | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
# - name: Setup Python | ||
# uses: actions/setup-python@v4 | ||
# with: | ||
# python-version: 3.10.12 | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
version: 1.4.1 | ||
virtualenvs-in-project: true | ||
- name: Load cached venv | ||
id: cached-poetry-dependencies | ||
uses: actions/cache@v3 | ||
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: Run all tests with pytest | ||
run: | | ||
source .venv/bin/activate | ||
pytest --cov | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
fail_ci_if_error: true | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
publish-all-images: | ||
needs: run-tests | ||
if: startsWith(github.ref, 'refs/tags/') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
- name: Get Git Commit Tag Name | ||
uses: olegtarasov/[email protected] | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
# - name: Setup Python | ||
# uses: actions/setup-python@v4 | ||
# with: | ||
# python-version: 3.10.12 | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
version: 1.4.1 | ||
virtualenvs-in-project: true | ||
- name: Load cached venv | ||
id: cached-poetry-dependencies | ||
uses: actions/cache@v3 | ||
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: Publish Image to Docker Hub | ||
env: | ||
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} | ||
run: | | ||
source .venv/bin/activate | ||
python -m build.publish |
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
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,12 +1,51 @@ | ||
FROM python:3.10-slim | ||
# The Poetry installation is provided through the base image. Please check the | ||
# base image if you interested in the details. | ||
# Base image: https://hub.docker.com/r/pfeiffermax/python-poetry | ||
# Dockerfile: https://github.com/max-pfeiffer/python-poetry/blob/main/build/Dockerfile | ||
ARG BASE_IMAGE | ||
FROM ${BASE_IMAGE} | ||
ARG APPLICATION_SERVER_PORT | ||
|
||
LABEL maintainer="Mike DuPont <[email protected]>" | ||
|
||
ENV PYTHONUNBUFFERED=1 \ | ||
# https://docs.python.org/3/using/cmdline.html#envvar-PYTHONDONTWRITEBYTECODE | ||
PYTHONDONTWRITEBYTECODE=1 \ | ||
PYTHONPATH=/application_root \ | ||
# https://python-poetry.org/docs/configuration/#virtualenvsin-project | ||
POETRY_VIRTUALENVS_IN_PROJECT=true \ | ||
POETRY_CACHE_DIR="/application_root/.cache" \ | ||
VIRTUAL_ENVIRONMENT_PATH="/application_root/.venv" \ | ||
APPLICATION_SERVER_PORT=$APPLICATION_SERVER_PORT | ||
# Adding the virtual environment to PATH in order to "activate" it. | ||
# https://docs.python.org/3/library/venv.html#how-venvs-work | ||
ENV PATH="$VIRTUAL_ENVIRONMENT_PATH/bin:$PATH" | ||
|
||
# Principle of least privilege: create a new user for running the application | ||
RUN groupadd -g 1001 python_application && \ | ||
useradd -r -u 1001 -g python_application python_application | ||
|
||
# Set the WORKDIR to the application root. | ||
# https://www.uvicorn.org/settings/#development | ||
# https://docs.docker.com/engine/reference/builder/#workdir | ||
WORKDIR ${PYTHONPATH} | ||
RUN chown python_application:python_application ${PYTHONPATH} | ||
|
||
# Create cache directory and set permissions because user 1001 has no home | ||
# and poetry cache directory. | ||
# https://python-poetry.org/docs/configuration/#cache-directory | ||
RUN mkdir ${POETRY_CACHE_DIR} && chown python_application:python_application ${POETRY_CACHE_DIR} | ||
|
||
# Use the unpriveledged user to run the application | ||
USER 1001 | ||
|
||
WORKDIR /opt/ai-ticket | ||
COPY pyproject.toml /opt/ai-ticket/ | ||
COPY setup.cfg /opt/ai-ticket/ | ||
COPY requirements.txt /opt/ai-ticket/ | ||
COPY ./src/ /opt/ai-ticket/src/ | ||
RUN pip install /opt/ai-ticket/ | ||
|
||
|
||
RUN apt update | ||
RUN apt install -y git | ||
RUN pip install --trusted-host pypi.python.org -r requirements.txt |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,13 @@ | ||
[build-system] | ||
python = "^3.7" | ||
requires = [ | ||
"setuptools>=42", | ||
"wheel" | ||
"wheel", | ||
"poetry-core" | ||
] | ||
build-backend = "setuptools.build_meta" | ||
#build-backend = "setuptools.build_meta" | ||
build-backend = "poetry.core.masonry.api" | ||
|
||
|
||
[tool.black] | ||
line-length = 120 | ||
|
@@ -16,3 +20,34 @@ combine_as_imports = true | |
combine_star = true | ||
known_local_folder = ["tests", "cli"] | ||
known_first_party = ["test_utils"] | ||
|
||
[tool.poetry] | ||
name = "ai-ticket" | ||
version = "0.0.1" | ||
authors = [ | ||
"Mike Dupont <[email protected]>", | ||
] | ||
readme = "README.md" | ||
description = "AI ticket" | ||
|
||
classifiers = [ | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
] | ||
#packages = . | ||
|
||
# [tool.poetry.scripts] | ||
# [tool.poetry.dependencies] | ||
[tool.poetry.group.dev.dependencies] | ||
python = "^3.7" | ||
pytest = "7.4.0" | ||
pytest-cov = "4.1.0" | ||
coverage = "7.3.1" | ||
requests = "2.31.0" | ||
black = "23.7.0" | ||
pre-commit = "3.3.3" | ||
semver = "3.0.1" | ||
pylint = "2.17.5" | ||
testcontainers = "3.7.1" | ||
|
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