mirror of
https://git.collinwebdesigns.de/oscar.krause/fastapi-dls.git
synced 2025-12-19 12:19:29 +08:00
Compare commits
No commits in common. "59a7c9f15affe96749d3f2760826315fabf31e3f" and "a7fe8b867e4fa7ae72dcb45dc5ac9b5ca8dea0be" have entirely different histories.
59a7c9f15a
...
a7fe8b867e
@ -1,10 +0,0 @@
|
|||||||
# https://packages.ubuntu.com
|
|
||||||
fastapi==0.110.3
|
|
||||||
uvicorn[standard]==0.30.3
|
|
||||||
python-jose[pycryptodome]==3.3.0
|
|
||||||
pycryptodome==3.20.0
|
|
||||||
python-dateutil==2.9.0
|
|
||||||
sqlalchemy==2.0.32
|
|
||||||
markdown==3.6
|
|
||||||
python-dotenv==1.0.1
|
|
||||||
jinja2==3.1.3
|
|
||||||
@ -20,7 +20,6 @@ build:docker:
|
|||||||
changes:
|
changes:
|
||||||
- app/**/*
|
- app/**/*
|
||||||
- Dockerfile
|
- Dockerfile
|
||||||
- requirements.txt
|
|
||||||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
|
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
|
||||||
tags: [ docker ]
|
tags: [ docker ]
|
||||||
before_script:
|
before_script:
|
||||||
@ -142,21 +141,14 @@ test:
|
|||||||
DATABASE: sqlite:///../app/db.sqlite
|
DATABASE: sqlite:///../app/db.sqlite
|
||||||
parallel:
|
parallel:
|
||||||
matrix:
|
matrix:
|
||||||
- IMAGE: [ 'python:3.12-slim-bookworm' ]
|
- IMAGE: [ 'python:3.11-slim-bookworm', 'python:3.12-slim-bullseye' ]
|
||||||
REQUIREMENTS: [ 'requirements.txt' ]
|
REQUIREMENTS:
|
||||||
- IMAGE: [ 'debian:bookworm' ]
|
- requirements.txt
|
||||||
REQUIREMENTS: [ '.DEBIAN/requirements-bookworm-12.txt' ]
|
- .DEBIAN/requirements-bookworm-12.txt
|
||||||
- IMAGE: [ 'ubuntu:23.10' ]
|
- .DEBIAN/requirements-ubuntu-23.10.txt
|
||||||
REQUIREMENTS: [ '.DEBIAN/requirements-ubuntu-23.10.txt' ]
|
- .DEBIAN/requirements-ubuntu-24.04.txt
|
||||||
- IMAGE: [ 'ubuntu:24.04' ]
|
|
||||||
REQUIREMENTS: [ '.DEBIAN/requirements-ubuntu-24.04.txt' ]
|
|
||||||
- IMAGE: [ 'ubuntu:24.10' ]
|
|
||||||
REQUIREMENTS: [ '.DEBIAN/requirements-ubuntu-24.10.txt' ]
|
|
||||||
before_script:
|
before_script:
|
||||||
- apt-get update && apt-get install -y python3-dev python3-pip python3-venv gcc
|
- apt-get update && apt-get install -y python3-dev gcc
|
||||||
- python3 -m venv venv
|
|
||||||
- source venv/bin/activate
|
|
||||||
- pip install --upgrade pip
|
|
||||||
- pip install -r $REQUIREMENTS
|
- pip install -r $REQUIREMENTS
|
||||||
- pip install pytest httpx
|
- pip install pytest httpx
|
||||||
- mkdir -p app/cert
|
- mkdir -p app/cert
|
||||||
@ -170,7 +162,7 @@ test:
|
|||||||
dotenv: version.env
|
dotenv: version.env
|
||||||
junit: ['**/report.xml']
|
junit: ['**/report.xml']
|
||||||
|
|
||||||
.test:apt:
|
.test:linux:
|
||||||
stage: test
|
stage: test
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
|
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
|
||||||
@ -209,15 +201,15 @@ test:
|
|||||||
- apt-get purge -qq -y fastapi-dls
|
- apt-get purge -qq -y fastapi-dls
|
||||||
- apt-get autoremove -qq -y && apt-get clean -qq
|
- apt-get autoremove -qq -y && apt-get clean -qq
|
||||||
|
|
||||||
test:apt:debian:
|
test:debian:
|
||||||
extends: .test:apt
|
extends: .test:linux
|
||||||
image: debian:bookworm-slim
|
image: debian:bookworm-slim
|
||||||
|
|
||||||
test:apt:ubuntu:
|
test:ubuntu:
|
||||||
extends: .test:apt
|
extends: .test:linux
|
||||||
image: ubuntu:24.04
|
image: ubuntu:24.04
|
||||||
|
|
||||||
test:pacman:archlinux:
|
test:archlinux:
|
||||||
image: archlinux:base
|
image: archlinux:base
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
|
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
|
||||||
@ -258,7 +250,7 @@ semgrep-sast:
|
|||||||
|
|
||||||
test_coverage:
|
test_coverage:
|
||||||
# extends: test
|
# extends: test
|
||||||
image: python:3.12-slim-bookworm
|
image: python:3.11-slim-bookworm
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
stage: test
|
stage: test
|
||||||
rules:
|
rules:
|
||||||
|
|||||||
@ -10,7 +10,7 @@ RUN apk update \
|
|||||||
&& apk add --no-cache --virtual build-deps gcc g++ python3-dev musl-dev pkgconfig \
|
&& apk add --no-cache --virtual build-deps gcc g++ python3-dev musl-dev pkgconfig \
|
||||||
&& apk add --no-cache curl postgresql postgresql-dev mariadb-dev sqlite-dev \
|
&& apk add --no-cache curl postgresql postgresql-dev mariadb-dev sqlite-dev \
|
||||||
&& pip install --no-cache-dir --upgrade uvicorn \
|
&& pip install --no-cache-dir --upgrade uvicorn \
|
||||||
&& pip install --no-cache-dir psycopg2==2.9.10 mysqlclient==2.2.6 pysqlite3==0.5.4 \
|
&& pip install --no-cache-dir psycopg2==2.9.9 mysqlclient==2.2.4 pysqlite3==0.5.2 \
|
||||||
&& pip install --no-cache-dir -r /tmp/requirements.txt \
|
&& pip install --no-cache-dir -r /tmp/requirements.txt \
|
||||||
&& apk del build-deps
|
&& apk del build-deps
|
||||||
|
|
||||||
|
|||||||
22
app/orm.py
22
app/orm.py
@ -1,4 +1,4 @@
|
|||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from sqlalchemy import Column, VARCHAR, CHAR, ForeignKey, DATETIME, update, and_, inspect, text
|
from sqlalchemy import Column, VARCHAR, CHAR, ForeignKey, DATETIME, update, and_, inspect, text
|
||||||
@ -66,17 +66,7 @@ class Origin(Base):
|
|||||||
if origin_refs is None:
|
if origin_refs is None:
|
||||||
deletions = session.query(Origin).delete()
|
deletions = session.query(Origin).delete()
|
||||||
else:
|
else:
|
||||||
deletions = session.query(Origin).filter(Origin.origin_ref.in_(origin_refs)).delete()
|
deletions = session.query(Origin).filter(Origin.origin_ref in origin_refs).delete()
|
||||||
session.commit()
|
|
||||||
session.close()
|
|
||||||
return deletions
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def delete_expired(engine: Engine) -> int:
|
|
||||||
session = sessionmaker(bind=engine)()
|
|
||||||
origins = session.query(Origin).join(Lease, Origin.origin_ref == Lease.origin_ref, isouter=True).filter(Lease.lease_ref.is_(None)).all()
|
|
||||||
origin_refs = [origin.origin_ref for origin in origins]
|
|
||||||
deletions = session.query(Origin).filter(Origin.origin_ref.in_(origin_refs)).delete()
|
|
||||||
session.commit()
|
session.commit()
|
||||||
session.close()
|
session.close()
|
||||||
return deletions
|
return deletions
|
||||||
@ -104,10 +94,10 @@ class Lease(Base):
|
|||||||
'lease_ref': self.lease_ref,
|
'lease_ref': self.lease_ref,
|
||||||
'origin_ref': self.origin_ref,
|
'origin_ref': self.origin_ref,
|
||||||
# 'scope_ref': self.scope_ref,
|
# 'scope_ref': self.scope_ref,
|
||||||
'lease_created': self.lease_created.replace(tzinfo=timezone.utc).isoformat(),
|
'lease_created': self.lease_created.isoformat(),
|
||||||
'lease_expires': self.lease_expires.replace(tzinfo=timezone.utc).isoformat(),
|
'lease_expires': self.lease_expires.isoformat(),
|
||||||
'lease_updated': self.lease_updated.replace(tzinfo=timezone.utc).isoformat(),
|
'lease_updated': self.lease_updated.isoformat(),
|
||||||
'lease_renewal': lease_renewal.replace(tzinfo=timezone.utc).isoformat(),
|
'lease_renewal': lease_renewal.isoformat(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
fastapi==0.115.5
|
fastapi==0.115.3
|
||||||
uvicorn[standard]==0.32.0
|
uvicorn[standard]==0.32.0
|
||||||
python-jose==3.3.0
|
python-jose==3.3.0
|
||||||
pycryptodome==3.21.0
|
pycryptodome==3.21.0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user