From b4653947660be16fbfee161fc4c52e2f4747f0f9 Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 25 Feb 2025 01:42:49 +0100 Subject: [PATCH 01/11] 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 02/11] 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 03/11] 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 04/11] 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 05/11] 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 06/11] 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 07/11] 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 08/11] 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 09/11] 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 10/11] 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 11/11] 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'