mirror of
https://git.collinwebdesigns.de/oscar.krause/fastapi-dls.git
synced 2025-12-18 03:29:28 +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:
|
||||
- app/**/*
|
||||
- Dockerfile
|
||||
- requirements.txt
|
||||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
|
||||
tags: [ docker ]
|
||||
before_script:
|
||||
@ -141,14 +142,21 @@ test:
|
||||
DATABASE: sqlite:///../app/db.sqlite
|
||||
parallel:
|
||||
matrix:
|
||||
- IMAGE: [ 'python:3.11-slim-bookworm', 'python:3.12-slim-bullseye' ]
|
||||
REQUIREMENTS:
|
||||
- requirements.txt
|
||||
- .DEBIAN/requirements-bookworm-12.txt
|
||||
- .DEBIAN/requirements-ubuntu-23.10.txt
|
||||
- .DEBIAN/requirements-ubuntu-24.04.txt
|
||||
- IMAGE: [ 'python:3.12-slim-bookworm' ]
|
||||
REQUIREMENTS: [ 'requirements.txt' ]
|
||||
- IMAGE: [ 'debian:bookworm' ]
|
||||
REQUIREMENTS: [ '.DEBIAN/requirements-bookworm-12.txt' ]
|
||||
- IMAGE: [ 'ubuntu:23.10' ]
|
||||
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:
|
||||
- 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 pytest httpx
|
||||
- mkdir -p app/cert
|
||||
@ -162,7 +170,7 @@ test:
|
||||
dotenv: version.env
|
||||
junit: ['**/report.xml']
|
||||
|
||||
.test:linux:
|
||||
.test:apt:
|
||||
stage: test
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
|
||||
@ -201,15 +209,15 @@ test:
|
||||
- apt-get purge -qq -y fastapi-dls
|
||||
- apt-get autoremove -qq -y && apt-get clean -qq
|
||||
|
||||
test:debian:
|
||||
extends: .test:linux
|
||||
test:apt:debian:
|
||||
extends: .test:apt
|
||||
image: debian:bookworm-slim
|
||||
|
||||
test:ubuntu:
|
||||
extends: .test:linux
|
||||
test:apt:ubuntu:
|
||||
extends: .test:apt
|
||||
image: ubuntu:24.04
|
||||
|
||||
test:archlinux:
|
||||
test:pacman:archlinux:
|
||||
image: archlinux:base
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
|
||||
@ -250,7 +258,7 @@ semgrep-sast:
|
||||
|
||||
test_coverage:
|
||||
# extends: test
|
||||
image: python:3.11-slim-bookworm
|
||||
image: python:3.12-slim-bookworm
|
||||
allow_failure: true
|
||||
stage: test
|
||||
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 curl postgresql postgresql-dev mariadb-dev sqlite-dev \
|
||||
&& 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 \
|
||||
&& 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 sqlalchemy import Column, VARCHAR, CHAR, ForeignKey, DATETIME, update, and_, inspect, text
|
||||
@ -66,7 +66,17 @@ class Origin(Base):
|
||||
if origin_refs is None:
|
||||
deletions = session.query(Origin).delete()
|
||||
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.close()
|
||||
return deletions
|
||||
@ -94,10 +104,10 @@ class Lease(Base):
|
||||
'lease_ref': self.lease_ref,
|
||||
'origin_ref': self.origin_ref,
|
||||
# 'scope_ref': self.scope_ref,
|
||||
'lease_created': self.lease_created.isoformat(),
|
||||
'lease_expires': self.lease_expires.isoformat(),
|
||||
'lease_updated': self.lease_updated.isoformat(),
|
||||
'lease_renewal': lease_renewal.isoformat(),
|
||||
'lease_created': self.lease_created.replace(tzinfo=timezone.utc).isoformat(),
|
||||
'lease_expires': self.lease_expires.replace(tzinfo=timezone.utc).isoformat(),
|
||||
'lease_updated': self.lease_updated.replace(tzinfo=timezone.utc).isoformat(),
|
||||
'lease_renewal': lease_renewal.replace(tzinfo=timezone.utc).isoformat(),
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
fastapi==0.115.3
|
||||
fastapi==0.115.5
|
||||
uvicorn[standard]==0.32.0
|
||||
python-jose==3.3.0
|
||||
pycryptodome==3.21.0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user