From ef7c265d8e4b70d283d9d7d161165003b62ae7fa Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 25 Feb 2025 00:38:43 +0100 Subject: [PATCH 01/20] Cleanup pyproject --- pyproject.toml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9c205e7..f634fbe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,11 +24,7 @@ dependencies = [ oidc-test = "oidc_test.main:main" [dependency-groups] -dev = [ - "dunamai>=1.23.0", - "ipdb>=0.13.13", - "pytest>=8.3.4", -] +dev = ["dunamai>=1.23.0", "ipdb>=0.13.13", "pytest>=8.3.4"] [build-system] requires = ["hatchling", "uv-dynamic-versioning"] @@ -39,6 +35,12 @@ source = "uv-dynamic-versioning" [tool.hatch.build.targets.wheel] packages = ["src/oidc_test"] +package = true + +[tool.uv-dynamic-versioning] +metadata = true +dirty = true +format = semver [tool.uv] package = true From 9c1f84328399104e8759a5d8c2f12d4a7f4113b7 Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 25 Feb 2025 00:40:33 +0100 Subject: [PATCH 02/20] Cleanup pyproject --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f634fbe..1e23a8d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ package = true [tool.uv-dynamic-versioning] metadata = true dirty = true -format = semver +style = "semver" [tool.uv] package = true From 3da485c945e221c73721f71540e0c57c12f7c22b Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 25 Feb 2025 00:41:36 +0100 Subject: [PATCH 03/20] Cleanup pyproject --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1e23a8d..8770c8d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,6 @@ package = true [tool.uv-dynamic-versioning] metadata = true -dirty = true style = "semver" [tool.uv] From 9c462379051155cdf834dfd64309cc97da348f4c Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 25 Feb 2025 01:37:17 +0100 Subject: [PATCH 04/20] Semver versioning, show version on web page --- pyproject.toml | 1 - src/oidc_test/__init__.py | 11 +++++++++++ src/oidc_test/main.py | 2 ++ src/oidc_test/static/styles.css | 6 ++++++ src/oidc_test/templates/base.html | 1 + 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8770c8d..c44e9f3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,6 @@ packages = ["src/oidc_test"] package = true [tool.uv-dynamic-versioning] -metadata = true style = "semver" [tool.uv] diff --git a/src/oidc_test/__init__.py b/src/oidc_test/__init__.py index e69de29..f449e2b 100644 --- a/src/oidc_test/__init__.py +++ b/src/oidc_test/__init__.py @@ -0,0 +1,11 @@ +import importlib.metadata + +try: + from dunamai import Version, Style + + __version__ = Version.from_git().serialize(style=Style.SemVer, dirty=True) +except ImportError: + # __name__ could be used if the package name is the same + # as the directory - not the case here + # __version__ = importlib.metadata.version(__name__) + __version__ = importlib.metadata.version("oidc-fastapi-test") diff --git a/src/oidc_test/main.py b/src/oidc_test/main.py index e5238c8..e882cda 100644 --- a/src/oidc_test/main.py +++ b/src/oidc_test/main.py @@ -29,6 +29,7 @@ from authlib.oauth2.rfc6749 import OAuth2Token # from fastapi.security import OpenIdConnect # from pkce import generate_code_verifier, generate_pkce_pair +from oidc_test import __version__ from oidc_test.registry import registry from oidc_test.auth.provider import NoPublicKey, Provider from oidc_test.auth.utils import ( @@ -108,6 +109,7 @@ async def home( "show_token": settings.show_token, "user": user, "now": datetime.now(), + "__version__": __version__, } if provider is None or token is None: context["providers"] = providers diff --git a/src/oidc_test/static/styles.css b/src/oidc_test/static/styles.css index 2baa748..1e8dc03 100644 --- a/src/oidc_test/static/styles.css +++ b/src/oidc_test/static/styles.css @@ -21,6 +21,12 @@ hr { .hidden { display: none; } +.version { + position: absolute; + font-size: 75%; + top: 0.3em; + right: 0.3em; +} .center { text-align: center; } diff --git a/src/oidc_test/templates/base.html b/src/oidc_test/templates/base.html index 4cb56f5..157e26f 100644 --- a/src/oidc_test/templates/base.html +++ b/src/oidc_test/templates/base.html @@ -5,6 +5,7 @@ +
v. {{ __version__}}

OIDC-test - FastAPI client

{% block content %} {% endblock %} From b4653947660be16fbfee161fc4c52e2f4747f0f9 Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 25 Feb 2025 01:42:49 +0100 Subject: [PATCH 05/20] CI: WIP --- .forgejo/workflows/build.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 352a0a9..c58230e 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -27,6 +27,15 @@ jobs: - name: Run tests (API call) run: .venv/bin/pytest -s tests/basic.py + - name: Get version + uses: mtkennerly/dunamai-action@v1 + with: + env-var: VERSION + args: --style semver + + - name: Version + run: echo $VERSION + - name: Get version with git describe id: version run: | From f4b38e1c69d3a1f288ddba1b62ae84ae4184d362 Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 25 Feb 2025 02:20:35 +0100 Subject: [PATCH 06/20] CI: use dunamai for version --- .forgejo/workflows/build.yaml | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index c58230e..9f21750 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -30,32 +30,29 @@ jobs: - name: Get version uses: mtkennerly/dunamai-action@v1 with: - env-var: VERSION args: --style semver + env-var: VERSION - name: Version run: echo $VERSION - - name: Get version with git describe - id: version - run: | - echo "version=$(git describe)" >> $GITHUB_OUTPUT - echo "$VERSION" + - name: Get distance from tag + uses: mtkennerly/dunamai-action@v1 + with: + args: --format "{distance}" + env-var: DISTANCE - - name: Check if the container should be built + - name: Distance + run: echo $DISTANCE + + - name: Check if the container should be built (distance from git tag is 0, or force build) id: builder env: - RUN: ${{ toJSON(inputs.build || !contains(steps.version.outputs.version, '-')) }} + RUN: ${{ toJSON(inputs.build || env.DISTANCE == "0" }} run: | echo "run=$RUN" >> $GITHUB_OUTPUT echo "Run build: $RUN" - - name: Set the version in pyproject.toml (workaround for uv not supporting dynamic version) - if: fromJSON(steps.builder.outputs.run) - env: - VERSION: ${{ steps.version.outputs.version }} - run: sed "s/0.0.0/$VERSION/" -i pyproject.toml - - name: Workaround for bug of podman-login if: fromJSON(steps.builder.outputs.run) run: | From 6f060dc2bfd726eec57607ef7ca911de22aa4177 Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 25 Feb 2025 02:26:37 +0100 Subject: [PATCH 07/20] CI: bump uv --- .forgejo/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 9f21750..18a89ee 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -19,7 +19,7 @@ jobs: - name: Install the latest version of uv uses: astral-sh/setup-uv@v4 with: - version: "0.5.16" + version: "0.6.3" - name: Install run: uv sync From 22d0a9852c3c97ffeac9a6cdbff5e4f31ee6e6a0 Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 25 Feb 2025 03:04:14 +0100 Subject: [PATCH 08/20] CI: not use dunamai github action as it uses plain pip, not uv pip --- .forgejo/workflows/build.yaml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 18a89ee..8284c15 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -28,19 +28,13 @@ jobs: run: .venv/bin/pytest -s tests/basic.py - name: Get version - uses: mtkennerly/dunamai-action@v1 - with: - args: --style semver - env-var: VERSION + run: echo "VERSION=$(.venv/bin/dunamai --style semver)" >> $GITHUB_ENV - name: Version run: echo $VERSION - name: Get distance from tag - uses: mtkennerly/dunamai-action@v1 - with: - args: --format "{distance}" - env-var: DISTANCE + run: echo "DISTANCE=$(.venv/bin/dunamai --format '{distance}')" >> $GITHUB_ENV - name: Distance run: echo $DISTANCE From 9f7b0902739534127c9e5890b40c9be7e42dfac7 Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 25 Feb 2025 03:12:46 +0100 Subject: [PATCH 09/20] CI: WIP --- .forgejo/workflows/build.yaml | 6 +++--- .forgejo/workflows/test.yaml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 8284c15..645d5d2 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -28,13 +28,13 @@ jobs: run: .venv/bin/pytest -s tests/basic.py - name: Get version - run: echo "VERSION=$(.venv/bin/dunamai --style semver)" >> $GITHUB_ENV + run: echo "VERSION=$(.venv/bin/dunamai from any --style semver)" >> $GITHUB_ENV - name: Version run: echo $VERSION - name: Get distance from tag - run: echo "DISTANCE=$(.venv/bin/dunamai --format '{distance}')" >> $GITHUB_ENV + run: echo "DISTANCE=$(.venv/bin/dunamai from any --format '{distance}')" >> $GITHUB_ENV - name: Distance run: echo $DISTANCE @@ -42,7 +42,7 @@ jobs: - name: Check if the container should be built (distance from git tag is 0, or force build) id: builder env: - RUN: ${{ toJSON(inputs.build || env.DISTANCE == "0" }} + RUN: ${{ toJSON(inputs.build || env.DISTANCE == "0") }} run: | echo "run=$RUN" >> $GITHUB_OUTPUT echo "Run build: $RUN" diff --git a/.forgejo/workflows/test.yaml b/.forgejo/workflows/test.yaml index a56a9ce..f4d994e 100644 --- a/.forgejo/workflows/test.yaml +++ b/.forgejo/workflows/test.yaml @@ -19,7 +19,7 @@ jobs: - name: Install the latest version of uv uses: astral-sh/setup-uv@v4 with: - version: "0.5.16" + version: "0.6.3" - name: Install run: uv sync From 821df027587eaee24b3db792033266564f66c62c Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 25 Feb 2025 04:28:04 +0100 Subject: [PATCH 10/20] CI: WIP --- .forgejo/workflows/build.yaml | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 645d5d2..cf079d9 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -28,33 +28,23 @@ jobs: run: .venv/bin/pytest -s tests/basic.py - name: Get version - run: echo "VERSION=$(.venv/bin/dunamai from any --style semver)" >> $GITHUB_ENV - - - name: Version - run: echo $VERSION + run: | + echo "VERSION=$(.venv/bin/dunamai from any --style semver)" >> $GITHUB_ENV + echo $VERSION - name: Get distance from tag - run: echo "DISTANCE=$(.venv/bin/dunamai from any --format '{distance}')" >> $GITHUB_ENV - - - name: Distance - run: echo $DISTANCE - - - name: Check if the container should be built (distance from git tag is 0, or force build) - id: builder - env: - RUN: ${{ toJSON(inputs.build || env.DISTANCE == "0") }} run: | - echo "run=$RUN" >> $GITHUB_OUTPUT - echo "Run build: $RUN" + echo "DISTANCE=$(.venv/bin/dunamai from any --format '{distance}')" >> $GITHUB_ENV + echo $DISTANCE - name: Workaround for bug of podman-login - if: fromJSON(steps.builder.outputs.run) + if: env.DISTANCE == '0' run: | mkdir -p $HOME/.docker echo "{ \"auths\": {} }" > $HOME/.docker/config.json - name: Log in to the container registry (with another workaround) - if: fromJSON(steps.builder.outputs.run) + if: env.DISTANCE == '0' uses: actions/podman-login@v1 with: registry: ${{ vars.REGISTRY }} @@ -63,7 +53,7 @@ jobs: auth_file_path: /tmp/auth.json - name: Build the container image - if: fromJSON(steps.builder.outputs.run) + if: env.DISTANCE == '0' uses: actions/buildah-build@v1 with: image: oidc-fastapi-test @@ -74,7 +64,7 @@ jobs: ./Containerfile - name: Push the image to the registry - if: fromJSON(steps.builder.outputs.run) + if: env.DISTANCE == '0' uses: actions/push-to-registry@v2 with: registry: "docker://${{ vars.REGISTRY }}/${{ vars.ORGANISATION }}" @@ -82,11 +72,11 @@ jobs: tags: latest ${{ steps.version.outputs.version }} - name: Build wheel - if: fromJSON(steps.builder.outputs.run) + if: env.DISTANCE == '0' run: uv build --wheel - name: Publish Python package (home) - if: fromJSON(steps.builder.outputs.run) + if: env.DISTANCE == '0' env: LOCAL_PYPI_TOKEN: ${{ secrets.LOCAL_PYPI_TOKEN }} run: uv publish --publish-url https://code.philo.ydns.eu/api/packages/philorg/pypi --token $LOCAL_PYPI_TOKEN From c5b1bdeda92d885749c38360a81572f2ef147087 Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 25 Feb 2025 04:31:31 +0100 Subject: [PATCH 11/20] CI: WIP --- .forgejo/workflows/build.yaml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index cf079d9..06c8be1 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -28,14 +28,16 @@ jobs: run: .venv/bin/pytest -s tests/basic.py - name: Get version - run: | - echo "VERSION=$(.venv/bin/dunamai from any --style semver)" >> $GITHUB_ENV - echo $VERSION + run: echo "VERSION=$(.venv/bin/dunamai from any --style semver)" >> $GITHUB_ENV + + - name: Version + run: echo $VERSION - name: Get distance from tag - run: | - echo "DISTANCE=$(.venv/bin/dunamai from any --format '{distance}')" >> $GITHUB_ENV - echo $DISTANCE + run: echo "DISTANCE=$(.venv/bin/dunamai from any --format '{distance}')" >> $GITHUB_ENV + + - name: Distance + run: echo $DISTANCE - name: Workaround for bug of podman-login if: env.DISTANCE == '0' From c3ebad42d575b91d221f13a3b93d9cbbbcd80af8 Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 25 Feb 2025 04:34:19 +0100 Subject: [PATCH 12/20] CI: WIP --- .forgejo/workflows/build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 06c8be1..e617190 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -61,7 +61,7 @@ jobs: image: oidc-fastapi-test oci: true labels: oidc-fastapi-test - tags: latest ${{ steps.version.outputs.version }} + tags: latest env.VERSION containerfiles: | ./Containerfile @@ -71,7 +71,7 @@ jobs: with: registry: "docker://${{ vars.REGISTRY }}/${{ vars.ORGANISATION }}" image: oidc-fastapi-test - tags: latest ${{ steps.version.outputs.version }} + tags: latest env.VERSION - name: Build wheel if: env.DISTANCE == '0' From 4355e6dc423b0db8ac5ca4746287dc20fd8c8d39 Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 25 Feb 2025 12:30:23 +0100 Subject: [PATCH 13/20] CI: WIP --- Containerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Containerfile b/Containerfile index 2e3fd28..0ec45d1 100644 --- a/Containerfile +++ b/Containerfile @@ -1,4 +1,4 @@ -FROM docker.io/library/python:alpine +FROM docker.io/library/python:latest COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/ From b01f2332086a08b4ad7c619d8fcb1a67e9a8e99c Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 25 Feb 2025 18:34:52 +0100 Subject: [PATCH 14/20] Add log messages for debugging connection to auth server --- src/oidc_test/auth/provider.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/oidc_test/auth/provider.py b/src/oidc_test/auth/provider.py index c614805..ce288a6 100644 --- a/src/oidc_test/auth/provider.py +++ b/src/oidc_test/auth/provider.py @@ -61,28 +61,34 @@ class Provider(AuthProviderSettings): if self.info_url is not None: try: provider_info = await client.get(self.info_url) - except Exception: + except Exception as err: + logger.debug("Provider_info: cannot connect") + logger.exception(err) raise NoPublicKey try: self.info = provider_info.json() except JSONDecodeError: + logger.debug("Provider_info: cannot decode json response") raise NoPublicKey if "public_key" in self.info: # For Keycloak try: public_key = str(self.info["public_key"]) except KeyError: + logger.debug("Provider_info: cannot get public_key") raise NoPublicKey elif "keys" in self.info: # For Forgejo/Gitea try: public_key = str(self.info["keys"][0]["n"]) except KeyError: + logger.debug("Provider_info: cannot get key 0.n") raise NoPublicKey if self.public_key_url is not None: resp = await client.get(self.public_key_url) public_key = resp.text if public_key is None: + logger.debug("Provider_info: cannot determine public key") raise NoPublicKey self.public_key = "\n".join( ["-----BEGIN PUBLIC KEY-----", public_key, "-----END PUBLIC KEY-----"] From 8b3a339196d92aa36dd17480af0586783bf1121e Mon Sep 17 00:00:00 2001 From: phil Date: Sat, 22 Mar 2025 01:01:32 +0100 Subject: [PATCH 15/20] CI: fix container tag --- .forgejo/workflows/build.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index e617190..379aaa8 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -19,7 +19,7 @@ jobs: - name: Install the latest version of uv uses: astral-sh/setup-uv@v4 with: - version: "0.6.3" + version: "0.6.9" - name: Install run: uv sync @@ -61,7 +61,7 @@ jobs: image: oidc-fastapi-test oci: true labels: oidc-fastapi-test - tags: latest env.VERSION + tags: "latest ${{ env.VERSION }}" containerfiles: | ./Containerfile @@ -71,7 +71,7 @@ jobs: with: registry: "docker://${{ vars.REGISTRY }}/${{ vars.ORGANISATION }}" image: oidc-fastapi-test - tags: latest env.VERSION + tags: "latest ${{ env.VERSION }}" - name: Build wheel if: env.DISTANCE == '0' From 0e6ff98f03a83cea53606607ba3240ddbc413ec0 Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 27 May 2025 16:44:13 +0200 Subject: [PATCH 16/20] CI: use slim base image --- Containerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Containerfile b/Containerfile index 0ec45d1..357cc84 100644 --- a/Containerfile +++ b/Containerfile @@ -1,6 +1,7 @@ -FROM docker.io/library/python:latest +FROM docker.io/library/python:3.13-slim COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/ +COPY --from=docker.io/python:3.13 /usr/bin/git /usr/local/bin/git COPY . /app From 1b6d754855d2f539e822e24e5eff10e385bfd7ea Mon Sep 17 00:00:00 2001 From: phil Date: Fri, 27 Jun 2025 17:11:35 +0200 Subject: [PATCH 17/20] CI: switch to woodpecker --- .forgejo/workflows/build.yaml | 85 ----------------------------------- .forgejo/workflows/test.yaml | 28 ------------ .woodpecker/build.yaml | 66 +++++++++++++++++++++++++++ .woodpecker/test.yaml | 21 +++++++++ src/oidc_test/__init__.py | 2 +- 5 files changed, 88 insertions(+), 114 deletions(-) delete mode 100644 .forgejo/workflows/build.yaml delete mode 100644 .forgejo/workflows/test.yaml create mode 100644 .woodpecker/build.yaml create mode 100644 .woodpecker/test.yaml diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml deleted file mode 100644 index 379aaa8..0000000 --- a/.forgejo/workflows/build.yaml +++ /dev/null @@ -1,85 +0,0 @@ -on: - push: - workflow_dispatch: - inputs: - verbose: - description: "Verbose" - required: false - default: false - type: boolean - -jobs: - build: - runs-on: container - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install the latest version of uv - uses: astral-sh/setup-uv@v4 - with: - version: "0.6.9" - - - name: Install - run: uv sync - - - name: Run tests (API call) - run: .venv/bin/pytest -s tests/basic.py - - - name: Get version - run: echo "VERSION=$(.venv/bin/dunamai from any --style semver)" >> $GITHUB_ENV - - - name: Version - run: echo $VERSION - - - name: Get distance from tag - run: echo "DISTANCE=$(.venv/bin/dunamai from any --format '{distance}')" >> $GITHUB_ENV - - - name: Distance - run: echo $DISTANCE - - - name: Workaround for bug of podman-login - if: env.DISTANCE == '0' - run: | - mkdir -p $HOME/.docker - echo "{ \"auths\": {} }" > $HOME/.docker/config.json - - - name: Log in to the container registry (with another workaround) - if: env.DISTANCE == '0' - uses: actions/podman-login@v1 - with: - registry: ${{ vars.REGISTRY }} - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - auth_file_path: /tmp/auth.json - - - name: Build the container image - if: env.DISTANCE == '0' - uses: actions/buildah-build@v1 - with: - image: oidc-fastapi-test - oci: true - labels: oidc-fastapi-test - tags: "latest ${{ env.VERSION }}" - containerfiles: | - ./Containerfile - - - name: Push the image to the registry - if: env.DISTANCE == '0' - uses: actions/push-to-registry@v2 - with: - registry: "docker://${{ vars.REGISTRY }}/${{ vars.ORGANISATION }}" - image: oidc-fastapi-test - tags: "latest ${{ env.VERSION }}" - - - name: Build wheel - if: env.DISTANCE == '0' - run: uv build --wheel - - - name: Publish Python package (home) - if: env.DISTANCE == '0' - env: - LOCAL_PYPI_TOKEN: ${{ secrets.LOCAL_PYPI_TOKEN }} - run: uv publish --publish-url https://code.philo.ydns.eu/api/packages/philorg/pypi --token $LOCAL_PYPI_TOKEN - continue-on-error: true diff --git a/.forgejo/workflows/test.yaml b/.forgejo/workflows/test.yaml deleted file mode 100644 index f4d994e..0000000 --- a/.forgejo/workflows/test.yaml +++ /dev/null @@ -1,28 +0,0 @@ -on: - push: - workflow_dispatch: - inputs: - verbose: - description: "Verbose" - required: false - default: false - type: boolean - -jobs: - test: - runs-on: container - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install the latest version of uv - uses: astral-sh/setup-uv@v4 - with: - version: "0.6.3" - - - name: Install - run: uv sync - - - name: Run tests (API call) - run: .venv/bin/pytest -s tests/basic.py diff --git a/.woodpecker/build.yaml b/.woodpecker/build.yaml new file mode 100644 index 0000000..6cdc17d --- /dev/null +++ b/.woodpecker/build.yaml @@ -0,0 +1,66 @@ +when: + - event: manual + - event: tag + +depends_on: + - test + +steps: + python_sync: + image: code.philo.ydns.eu/philorg/uv + volumes: + - uv-cache:/uv-cache + environment: + UV_CACHE_DIR: /uv-cache + UV_LINK_MODE: copy + commands: + - uv sync + + python_build: + image: code.philo.ydns.eu/philorg/uv + volumes: + - uv-cache:/uv-cache + environment: + UV_CACHE_DIR: /uv-cache + UV_LINK_MODE: copy + commands: + - uv build --wheel + - uv cache prune --ci + + python_publish: + image: code.philo.ydns.eu/philorg/uv + environment: + OWNER: philorg + REGISTRY_URL: https://code.philo.ydns.eu + REGISTRY_TOKEN: + from_secret: registry_token + commands: + - uv publish --publish-url $REGISTRY_URL/api/packages/$OWNER/pypi --token $REGISTRY_TOKEN dist/*.whl + failure: ignore + + container_build_publish: + image: quay.io/podman/stable:latest + # Caution: This image is built daily. It might fill up your image store quickly. + #pull: true + volumes: + - containers:/var/lib/containers + - uv:/root/.cache/uv + # Fill in the trusted checkbox in Woodpecker's settings as well + privileged: true + environment: + registry: code.philo.ydns.eu + org: philorg + container_name: oidc-fastapi-test + registry_token: + from_secret: registry_token + commands: + # Login at the registry + - podman login -u __token__ --password $registry_token $registry + # Build the container image + - podman build --volume=/var/lib/containers:/var/lib/containers --tag $registry/$org/$container_name:latest --tag $registry/$org/$container_name:$CI_COMMIT_TAG . + # Push the image + - podman push $registry/$org/$container_name:latest + - podman push $registry/$org/$container_name:$CI_COMMIT_TAG + - podman build --volume=/var/lib/containers:/var/lib/containers --tag $registry/$org/$container_name:latest-full --tag $registry/$org/$container_name:$CI_COMMIT_TAG-full -f Containerfile.with_plugins + - podman push $registry/$org/$container_name:latest-full + - podman push $registry/$org/$container_name:$CI_COMMIT_TAG-full diff --git a/.woodpecker/test.yaml b/.woodpecker/test.yaml new file mode 100644 index 0000000..a02e51d --- /dev/null +++ b/.woodpecker/test.yaml @@ -0,0 +1,21 @@ +when: + - event: push + branch: main + - event: manual + - event: tag + +steps: + sync: + image: code.philo.ydns.eu/philorg/uv + volumes: + - uv-cache:/uv-cache + environment: + UV_CACHE_DIR: /uv-cache + UV_LINK_MODE: copy + commands: + - uv sync + + test: + image: pyton:alpine + commands: + - .venv/bin/pytest -s tests/basic.py diff --git a/src/oidc_test/__init__.py b/src/oidc_test/__init__.py index f449e2b..f154022 100644 --- a/src/oidc_test/__init__.py +++ b/src/oidc_test/__init__.py @@ -4,7 +4,7 @@ try: from dunamai import Version, Style __version__ = Version.from_git().serialize(style=Style.SemVer, dirty=True) -except ImportError: +except (ImportError, RuntimeError): # __name__ could be used if the package name is the same # as the directory - not the case here # __version__ = importlib.metadata.version(__name__) From 1dec3988d5a83294d4f7d77942d603d6aedf0154 Mon Sep 17 00:00:00 2001 From: phil Date: Fri, 27 Jun 2025 17:15:16 +0200 Subject: [PATCH 18/20] CI: fix test --- .woodpecker/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker/test.yaml b/.woodpecker/test.yaml index a02e51d..d8816b2 100644 --- a/.woodpecker/test.yaml +++ b/.woodpecker/test.yaml @@ -16,6 +16,6 @@ steps: - uv sync test: - image: pyton:alpine + image: code.philo.ydns.eu/philorg/uv commands: - .venv/bin/pytest -s tests/basic.py From b14e6a0be5eadfe49a71ff12233f892f23fa7d44 Mon Sep 17 00:00:00 2001 From: phil Date: Fri, 27 Jun 2025 17:21:43 +0200 Subject: [PATCH 19/20] CI: fix build --- .woodpecker/build.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.woodpecker/build.yaml b/.woodpecker/build.yaml index 6cdc17d..3af8132 100644 --- a/.woodpecker/build.yaml +++ b/.woodpecker/build.yaml @@ -61,6 +61,3 @@ steps: # Push the image - podman push $registry/$org/$container_name:latest - podman push $registry/$org/$container_name:$CI_COMMIT_TAG - - podman build --volume=/var/lib/containers:/var/lib/containers --tag $registry/$org/$container_name:latest-full --tag $registry/$org/$container_name:$CI_COMMIT_TAG-full -f Containerfile.with_plugins - - podman push $registry/$org/$container_name:latest-full - - podman push $registry/$org/$container_name:$CI_COMMIT_TAG-full From e1e755fde5075b714a1df6b967a5c32cc966e752 Mon Sep 17 00:00:00 2001 From: phil Date: Fri, 27 Jun 2025 17:23:28 +0200 Subject: [PATCH 20/20] Update README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 68f335d..c7f8741 100644 --- a/README.md +++ b/README.md @@ -127,3 +127,5 @@ with the setting file in the current working directory: ```sh podman run -p 8000:80 --env OIDC_TEST_CONFIG_FILE=/app/settings.yaml --mount type=bind,source=settings.yaml,destination=/app/settings.yaml code.philo.ydns.eu/philorg/oidc-fastapi-test:latest ``` + +[![status-badge](https://code.philo.ydns.eu/woodpecker/api/badges/22/status.svg)](https://code.philo.ydns.eu/woodpecker/repos/22)