mirror of
https://git.collinwebdesigns.de/oscar.krause/fastapi-dls.git
synced 2025-12-18 11:49:26 +08:00
Compare commits
15 Commits
a7fe8b867e
...
59a7c9f15a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59a7c9f15a | ||
|
|
bc6d692f0a | ||
|
|
63c37c6334 | ||
|
|
fa2c06972e | ||
|
|
e4e6387b2a | ||
|
|
f2be9dca8d | ||
|
|
52dd425583 | ||
|
|
286399d79a | ||
|
|
4ab1a2ed22 | ||
|
|
459c0e21af | ||
|
|
98ef64211b | ||
|
|
0b4bb65546 | ||
|
|
47624f5019 | ||
|
|
2b9d7821c0 | ||
|
|
45f5108717 |
10
.DEBIAN/requirements-ubuntu-24.10.txt
Normal file
10
.DEBIAN/requirements-ubuntu-24.10.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# 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,6 +20,7 @@ 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:
|
||||||
@ -141,14 +142,21 @@ test:
|
|||||||
DATABASE: sqlite:///../app/db.sqlite
|
DATABASE: sqlite:///../app/db.sqlite
|
||||||
parallel:
|
parallel:
|
||||||
matrix:
|
matrix:
|
||||||
- IMAGE: [ 'python:3.11-slim-bookworm', 'python:3.12-slim-bullseye' ]
|
- IMAGE: [ 'python:3.12-slim-bookworm' ]
|
||||||
REQUIREMENTS:
|
REQUIREMENTS: [ 'requirements.txt' ]
|
||||||
- requirements.txt
|
- IMAGE: [ 'debian:bookworm' ]
|
||||||
- .DEBIAN/requirements-bookworm-12.txt
|
REQUIREMENTS: [ '.DEBIAN/requirements-bookworm-12.txt' ]
|
||||||
- .DEBIAN/requirements-ubuntu-23.10.txt
|
- IMAGE: [ 'ubuntu:23.10' ]
|
||||||
- .DEBIAN/requirements-ubuntu-24.04.txt
|
REQUIREMENTS: [ '.DEBIAN/requirements-ubuntu-23.10.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 gcc
|
- apt-get update && apt-get install -y python3-dev python3-pip python3-venv 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
|
||||||
@ -162,7 +170,7 @@ test:
|
|||||||
dotenv: version.env
|
dotenv: version.env
|
||||||
junit: ['**/report.xml']
|
junit: ['**/report.xml']
|
||||||
|
|
||||||
.test:linux:
|
.test:apt:
|
||||||
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
|
||||||
@ -201,15 +209,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:debian:
|
test:apt:debian:
|
||||||
extends: .test:linux
|
extends: .test:apt
|
||||||
image: debian:bookworm-slim
|
image: debian:bookworm-slim
|
||||||
|
|
||||||
test:ubuntu:
|
test:apt:ubuntu:
|
||||||
extends: .test:linux
|
extends: .test:apt
|
||||||
image: ubuntu:24.04
|
image: ubuntu:24.04
|
||||||
|
|
||||||
test:archlinux:
|
test:pacman: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
|
||||||
@ -250,7 +258,7 @@ semgrep-sast:
|
|||||||
|
|
||||||
test_coverage:
|
test_coverage:
|
||||||
# extends: test
|
# extends: test
|
||||||
image: python:3.11-slim-bookworm
|
image: python:3.12-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.9 mysqlclient==2.2.4 pysqlite3==0.5.2 \
|
&& pip install --no-cache-dir psycopg2==2.9.10 mysqlclient==2.2.6 pysqlite3==0.5.4 \
|
||||||
&& 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
|
from datetime import datetime, timedelta, timezone
|
||||||
|
|
||||||
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,7 +66,17 @@ 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
|
||||||
@ -94,10 +104,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.isoformat(),
|
'lease_created': self.lease_created.replace(tzinfo=timezone.utc).isoformat(),
|
||||||
'lease_expires': self.lease_expires.isoformat(),
|
'lease_expires': self.lease_expires.replace(tzinfo=timezone.utc).isoformat(),
|
||||||
'lease_updated': self.lease_updated.isoformat(),
|
'lease_updated': self.lease_updated.replace(tzinfo=timezone.utc).isoformat(),
|
||||||
'lease_renewal': lease_renewal.isoformat(),
|
'lease_renewal': lease_renewal.replace(tzinfo=timezone.utc).isoformat(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
fastapi==0.115.3
|
fastapi==0.115.5
|
||||||
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