Compare commits
1 Commits
v0.1.3
...
5a1c19ccbe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36a548eee6 |
@@ -75,18 +75,6 @@ jobs:
|
||||
run: |
|
||||
git config user.name "Gitea CI"
|
||||
git config user.email "ci@git.theprivateserver.de"
|
||||
|
||||
- name: Determine branch to push to
|
||||
id: push_branch
|
||||
run: |
|
||||
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
|
||||
# workflow_dispatch runs on a branch ref like refs/heads/main
|
||||
BRANCH=${GITHUB_REF#refs/heads/}
|
||||
else
|
||||
# for a merged PR use the PR base ref (target branch)
|
||||
BRANCH=${{ github.event.pull_request.base.ref }}
|
||||
fi
|
||||
echo "PUSH_BRANCH=$BRANCH" >> $GITHUB_ENV
|
||||
- name: Bump version
|
||||
id: bump
|
||||
run: |
|
||||
@@ -145,7 +133,7 @@ jobs:
|
||||
uses: ad-m/github-push-action@master
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
branch: ${{ env.PUSH_BRANCH }}
|
||||
branch: ${{ github.ref }}
|
||||
- name: Build Changelog
|
||||
id: build_changelog
|
||||
uses: https://github.com/mikepenz/release-changelog-builder-action@v5
|
||||
|
||||
@@ -5,7 +5,7 @@ on:
|
||||
types: [opened, synchronize, edited, reopened]
|
||||
|
||||
jobs:
|
||||
build-image:
|
||||
build-and-smoke:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
@@ -17,48 +17,24 @@ jobs:
|
||||
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
|
||||
- name: (optional) Prepare dependencies
|
||||
- name: Set up Python
|
||||
run: uv python install
|
||||
with:
|
||||
python-version-file: "pyproject.toml"
|
||||
- name: Install the project dependencies
|
||||
run: |
|
||||
uv python install --python-version-file pyproject.toml || true
|
||||
uv sync --all-groups || true
|
||||
uv add pip || true
|
||||
uv export --format requirements.txt -o requirements.txt || true
|
||||
|
||||
uv sync --all-groups
|
||||
uv add pip
|
||||
uv export --format requirements.txt -o requirements.txt
|
||||
# uv run python -m pip install --upgrade pip
|
||||
# uv run python -m pip install -r requirements.txt
|
||||
- name: Build image
|
||||
run: |
|
||||
docker build -t semapform-api:test-pr .
|
||||
|
||||
- name: Save image artifact
|
||||
run: |
|
||||
docker save semapform-api:test-pr -o semapform-api.tar
|
||||
|
||||
- name: Upload image artifact
|
||||
uses: https://github.com/christopherHX/gitea-upload-artifact@v4
|
||||
with:
|
||||
name: semapform-image
|
||||
path: semapform-api.tar
|
||||
retention-days: 1
|
||||
|
||||
smoke-tests:
|
||||
needs: build-image
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download image artifact
|
||||
uses: christopherhx/gitea-download-artifact@v4
|
||||
with:
|
||||
name: semapform-image
|
||||
|
||||
- name: Restore image
|
||||
run: |
|
||||
docker load -i semapform-api.tar
|
||||
|
||||
- name: Start container (background)
|
||||
run: |
|
||||
# do NOT bind the container port to the host to avoid port conflicts on the runner
|
||||
docker run -d --name semapform-test semapform-api:test-pr sleep infinity
|
||||
|
||||
- name: Start server in container and smoke test HTTP (in-container)
|
||||
@@ -70,27 +46,30 @@ jobs:
|
||||
# show container status to aid debugging
|
||||
docker ps -a --filter name=semapform-test || true
|
||||
|
||||
echo "waiting for service to become ready inside container"
|
||||
set -e
|
||||
READY=0
|
||||
for i in $(seq 1 20); do
|
||||
echo "ready attempt $i"
|
||||
if docker exec semapform-test python -c 'import urllib.request,sys; urllib.request.urlopen("http://127.0.0.1:8001/health", timeout=1); print("ok")' ; then
|
||||
READY=1
|
||||
break
|
||||
# perform a readiness loop (try container-local /health) using small execs
|
||||
echo "waiting for service to become ready inside container"
|
||||
set -e
|
||||
READY=0
|
||||
for i in $(seq 1 20); do
|
||||
echo "ready attempt $i"
|
||||
if docker exec semapform-test python -c 'import urllib.request,sys; urllib.request.urlopen("http://127.0.0.1:8001/health", timeout=1); print("ok")' ; then
|
||||
READY=1
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
if [ "$READY" -ne 1 ]; then
|
||||
echo "service did not become ready"
|
||||
docker logs semapform-test --tail 200 || true
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
if [ "$READY" -ne 1 ]; then
|
||||
echo "service did not become ready"
|
||||
|
||||
# Run the repository smoke-test script inside the container and surface its output
|
||||
echo "running test_api.py inside container"
|
||||
docker exec semapform-test python test_api.py || true
|
||||
|
||||
# dump the last 200 lines of logs so this step always displays useful output
|
||||
docker logs semapform-test --tail 200 || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "running test_api.py inside container"
|
||||
docker exec semapform-test python test_api.py || true
|
||||
|
||||
docker logs semapform-test --tail 200 || true
|
||||
|
||||
- name: Cleanup container
|
||||
if: always()
|
||||
|
||||
@@ -12,28 +12,6 @@ from fastapi.responses import JSONResponse
|
||||
|
||||
app = FastAPI(title="Signature Validation API")
|
||||
|
||||
# Optional path prefix support: when behind a reverse-proxy that uses a
|
||||
# URL prefix (eg. `https://api.example.tld/library/...`) set `API_PREFIX` to
|
||||
# that prefix (example: `/library`) so incoming requests are rewritten to the
|
||||
# application root. This keeps route definitions unchanged while supporting
|
||||
# both proxied and direct deployments.
|
||||
_api_prefix_raw = os.getenv("API_PREFIX", "").strip()
|
||||
api_prefix = ""
|
||||
if _api_prefix_raw:
|
||||
if not _api_prefix_raw.startswith("/"):
|
||||
_api_prefix_raw = "/" + _api_prefix_raw
|
||||
api_prefix = _api_prefix_raw.rstrip("/")
|
||||
|
||||
|
||||
@app.middleware("http")
|
||||
async def _strip_api_prefix(request, call_next):
|
||||
if api_prefix and request.url.path.startswith(api_prefix):
|
||||
new_path = request.url.path[len(api_prefix) :]
|
||||
request.scope["path"] = new_path or "/"
|
||||
request.scope["root_path"] = api_prefix
|
||||
return await call_next(request)
|
||||
|
||||
|
||||
# Allow PHP application to call this API
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
[project]
|
||||
name = "semapform-api"
|
||||
version = "0.1.3"
|
||||
version = "0.1.2"
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.13"
|
||||
dependencies = [
|
||||
"bibapi[catalogue]>=0.0.6",
|
||||
"bibapi>=0.0.5",
|
||||
"fastapi>=0.122.0",
|
||||
"pip>=25.3",
|
||||
"uvicorn>=0.38.0",
|
||||
@@ -15,7 +15,7 @@ name = "gitea"
|
||||
url = "https://git.theprivateserver.de/api/packages/PHB/pypi/simple/"
|
||||
|
||||
[tool.bumpversion]
|
||||
current_version = "0.1.3"
|
||||
current_version = "0.1.2"
|
||||
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
||||
serialize = ["{major}.{minor}.{patch}"]
|
||||
search = "{current_version}"
|
||||
|
||||
Reference in New Issue
Block a user