Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Upgrade CI, Remove Linkerd Await #322

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: build

on:
push:
tags: ["v[0-9]+.[0-9]+.[0-9]+"]

jobs:
build:
uses: binkhq/actions/.github/workflows/python_build.yaml@v1
with:
python_version: "3.10"
application_name: ${{ github.event.repository.name }}
application_version: ${{ github.ref_name }}
secrets: inherit
release:
needs: ["build"]
uses: binkhq/actions/.github/workflows/python_release.yaml@v1
with:
source: ${{ github.event.repository.name }}:${{ github.ref_name }}
tags: ${{ matrix.environment }}-${{ github.ref_name }},${{ matrix.environment }}
environment: ${{ matrix.environment }}
secrets: inherit
strategy:
matrix:
environment: [staging, production]
124 changes: 0 additions & 124 deletions .github/workflows/ci.yaml

This file was deleted.

46 changes: 46 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: test

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

jobs:
test:
name: test
runs-on: ubuntu-latest
env:
LOG_FORMATTER: brief
SQLALCHEMY_DATABASE_URI: "postgresql://[email protected]:5432/polaris"
REDIS_URL: redis://127.0.0.1:6379/0
TESTING: "True"
POLARIS_PUBLIC_URL: http://fake-polaris-public-url
services:
postgres:
image: postgres:latest
ports:
- 5432:5432
env:
POSTGRES_DB: polaris_test
POSTGRES_HOST_AUTH_METHOD: trust
redis:
image: redis:latest
ports:
- 6379:6379
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- run: pip install poetry
- run: poetry config http-basic.azure jeff ${{ secrets.AZURE_DEVOPS_PAT }}
- run: poetry install
- run: poetry run alembic upgrade head
- run: poetry run black --check .
- run: poetry run isort --check .
- run: poetry run xenon --no-assert --max-average A --max-modules B --max-absolute B .
- run: poetry run ruff polaris tests asgi.py
- run: poetry run mypy .
- run: poetry run refurb polaris tests asgi.py
- run: poetry run pytest --verbose --cov polaris --cov-report term-missing
5 changes: 0 additions & 5 deletions CODEOWNERS

This file was deleted.

38 changes: 7 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,13 @@

FROM ghcr.io/binkhq/python:3.10 as build

ENV VENV /app/venv

WORKDIR /src
ADD . .
ARG AZURE_DEVOPS_PAT
ENV VIRTUAL_ENV=$VENV
ENV PATH=$VENV/bin:$PATH

# gcc required for hiredis and git for poetry-dynamic-versioning
RUN apt update && apt -y install git gcc
RUN pip install poetry==1.7.1
RUN poetry config http-basic.azure jeff $AZURE_DEVOPS_PAT
RUN poetry self add poetry-dynamic-versioning[plugin]
RUN python -m venv $VENV
RUN poetry install --without=dev --no-root
RUN poetry build
RUN pip install dist/*.whl

FROM ghcr.io/binkhq/python:3.10

ARG PIP_INDEX_URL
ARG APP_NAME
ARG APP_VERSION
WORKDIR /app
ENV VENV /app/venv
ENV PATH="$VENV/bin:$PATH"
ENV PROMETHEUS_MULTIPROC_DIR=/dev/shm
RUN pip install --no-cache ${APP_NAME}==$(echo ${APP_VERSION} | cut -c 2-)
ADD asgi.py .
ADD alembic.ini .

COPY --from=build $VENV $VENV
COPY --from=build /src/alembic/ ./alembic/
COPY --from=build /src/alembic.ini .
COPY --from=build /src/asgi.py .

ENTRYPOINT [ "linkerd-await", "--" ]
ENV PROMETHEUS_MULTIPROC_DIR=/dev/shm
CMD [ "gunicorn", "--workers=2", "--error-logfile=-", "--access-logfile=-", \
"--worker-class=uvicorn.workers.UvicornWorker", \
"--bind=0.0.0.0:9000", "--bind=0.0.0.0:9100", "asgi:app" ]
51 changes: 1 addition & 50 deletions alembic.ini
Original file line number Diff line number Diff line change
@@ -1,54 +1,5 @@
# A generic, single database configuration.

[alembic]
# path to migration scripts
script_location = alembic

# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s

# sys.path path, will be prepended to sys.path if present.
# defaults to the current working directory.
script_location = polaris:alembic
prepend_sys_path = .

# timezone to use when rendering the date
# within the migration file as well as the filename.
# string value is passed to dateutil.tz.gettz()
# leave blank for localtime
# timezone =

# max length of characters to apply to the
# "slug" field
# truncate_slug_length = 40

# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false

# set to 'true' to allow .pyc and .pyo files without
# a source .py file to be detected as revisions in the
# versions/ directory
# sourceless = false

# version location specification; this defaults
# to alembic/versions. When using multiple version
# directories, initial revisions must be specified with --version-path
# version_locations = %(here)s/bar %(here)s/bat alembic/versions

# the output encoding used when revision files
# are written from script.py.mako
# output_encoding = utf-8




[post_write_hooks]
# post_write_hooks defines scripts or Python functions that are run
# on newly generated revision scripts. See the documentation for further
# detail and examples

# format using "black" - use the console_scripts runner, against the "black" entrypoint
hooks = black
black.type = console_scripts
black.entrypoint = black
black.options = -l 120
File renamed without changes.
21 changes: 1 addition & 20 deletions alembic/env.py → polaris/alembic/env.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,18 @@
import logging

from alembic import context
from sqlalchemy import engine_from_config, pool

from alembic import context
from polaris.core.config import settings
from polaris.db.base import Base

logger = logging.getLogger(__name__)

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config

# Interpret the config file for Python logging.
# This line sets up loggers basically.
# fileConfig(config.config_file_name)


# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata


target_metadata = Base.metadata


# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.


def run_migrations_offline() -> None:
"""Run migrations in 'offline' mode.

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@

import sqlalchemy as sa

from sqlalchemy.dialects import postgresql

from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "2b7ab3eddbdb"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@

import sqlalchemy as sa

from sqlalchemy.dialects import postgresql

from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "c1078e89c671"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
"""
import sqlalchemy as sa

from sqlalchemy.dialects import postgresql

from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "e324fb4ca307"
Expand Down
Loading
Loading