Compare commits

..

No commits in common. "main" and "v0.2.4" have entirely different histories.
main ... v0.2.4

4 changed files with 29 additions and 27 deletions

View file

@ -19,7 +19,7 @@ jobs:
- name: Install the latest version of uv - name: Install the latest version of uv
uses: astral-sh/setup-uv@v4 uses: astral-sh/setup-uv@v4
with: with:
version: "0.6.9" version: "0.5.16"
- name: Install - name: Install
run: uv sync run: uv sync
@ -27,26 +27,34 @@ jobs:
- name: Run tests (API call) - name: Run tests (API call)
run: .venv/bin/pytest -s tests/basic.py run: .venv/bin/pytest -s tests/basic.py
- name: Get version - name: Get version with git describe
run: echo "VERSION=$(.venv/bin/dunamai from any --style semver)" >> $GITHUB_ENV id: version
run: |
echo "version=$(git describe)" >> $GITHUB_OUTPUT
echo "$VERSION"
- name: Version - name: Check if the container should be built
run: echo $VERSION id: builder
env:
RUN: ${{ toJSON(inputs.build || !contains(steps.version.outputs.version, '-')) }}
run: |
echo "run=$RUN" >> $GITHUB_OUTPUT
echo "Run build: $RUN"
- name: Get distance from tag - name: Set the version in pyproject.toml (workaround for uv not supporting dynamic version)
run: echo "DISTANCE=$(.venv/bin/dunamai from any --format '{distance}')" >> $GITHUB_ENV if: fromJSON(steps.builder.outputs.run)
env:
- name: Distance VERSION: ${{ steps.version.outputs.version }}
run: echo $DISTANCE run: sed "s/0.0.0/$VERSION/" -i pyproject.toml
- name: Workaround for bug of podman-login - name: Workaround for bug of podman-login
if: env.DISTANCE == '0' if: fromJSON(steps.builder.outputs.run)
run: | run: |
mkdir -p $HOME/.docker mkdir -p $HOME/.docker
echo "{ \"auths\": {} }" > $HOME/.docker/config.json echo "{ \"auths\": {} }" > $HOME/.docker/config.json
- name: Log in to the container registry (with another workaround) - name: Log in to the container registry (with another workaround)
if: env.DISTANCE == '0' if: fromJSON(steps.builder.outputs.run)
uses: actions/podman-login@v1 uses: actions/podman-login@v1
with: with:
registry: ${{ vars.REGISTRY }} registry: ${{ vars.REGISTRY }}
@ -55,30 +63,30 @@ jobs:
auth_file_path: /tmp/auth.json auth_file_path: /tmp/auth.json
- name: Build the container image - name: Build the container image
if: env.DISTANCE == '0' if: fromJSON(steps.builder.outputs.run)
uses: actions/buildah-build@v1 uses: actions/buildah-build@v1
with: with:
image: oidc-fastapi-test image: oidc-fastapi-test
oci: true oci: true
labels: oidc-fastapi-test labels: oidc-fastapi-test
tags: "latest ${{ env.VERSION }}" tags: latest ${{ steps.version.outputs.version }}
containerfiles: | containerfiles: |
./Containerfile ./Containerfile
- name: Push the image to the registry - name: Push the image to the registry
if: env.DISTANCE == '0' if: fromJSON(steps.builder.outputs.run)
uses: actions/push-to-registry@v2 uses: actions/push-to-registry@v2
with: with:
registry: "docker://${{ vars.REGISTRY }}/${{ vars.ORGANISATION }}" registry: "docker://${{ vars.REGISTRY }}/${{ vars.ORGANISATION }}"
image: oidc-fastapi-test image: oidc-fastapi-test
tags: "latest ${{ env.VERSION }}" tags: latest ${{ steps.version.outputs.version }}
- name: Build wheel - name: Build wheel
if: env.DISTANCE == '0' if: fromJSON(steps.builder.outputs.run)
run: uv build --wheel run: uv build --wheel
- name: Publish Python package (home) - name: Publish Python package (home)
if: env.DISTANCE == '0' if: fromJSON(steps.builder.outputs.run)
env: env:
LOCAL_PYPI_TOKEN: ${{ secrets.LOCAL_PYPI_TOKEN }} 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 run: uv publish --publish-url https://code.philo.ydns.eu/api/packages/philorg/pypi --token $LOCAL_PYPI_TOKEN

View file

@ -19,7 +19,7 @@ jobs:
- name: Install the latest version of uv - name: Install the latest version of uv
uses: astral-sh/setup-uv@v4 uses: astral-sh/setup-uv@v4
with: with:
version: "0.6.3" version: "0.5.16"
- name: Install - name: Install
run: uv sync run: uv sync

View file

@ -1,4 +1,4 @@
FROM docker.io/library/python:latest FROM docker.io/library/python:alpine
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/ COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/

View file

@ -61,34 +61,28 @@ class Provider(AuthProviderSettings):
if self.info_url is not None: if self.info_url is not None:
try: try:
provider_info = await client.get(self.info_url) provider_info = await client.get(self.info_url)
except Exception as err: except Exception:
logger.debug("Provider_info: cannot connect")
logger.exception(err)
raise NoPublicKey raise NoPublicKey
try: try:
self.info = provider_info.json() self.info = provider_info.json()
except JSONDecodeError: except JSONDecodeError:
logger.debug("Provider_info: cannot decode json response")
raise NoPublicKey raise NoPublicKey
if "public_key" in self.info: if "public_key" in self.info:
# For Keycloak # For Keycloak
try: try:
public_key = str(self.info["public_key"]) public_key = str(self.info["public_key"])
except KeyError: except KeyError:
logger.debug("Provider_info: cannot get public_key")
raise NoPublicKey raise NoPublicKey
elif "keys" in self.info: elif "keys" in self.info:
# For Forgejo/Gitea # For Forgejo/Gitea
try: try:
public_key = str(self.info["keys"][0]["n"]) public_key = str(self.info["keys"][0]["n"])
except KeyError: except KeyError:
logger.debug("Provider_info: cannot get key 0.n")
raise NoPublicKey raise NoPublicKey
if self.public_key_url is not None: if self.public_key_url is not None:
resp = await client.get(self.public_key_url) resp = await client.get(self.public_key_url)
public_key = resp.text public_key = resp.text
if public_key is None: if public_key is None:
logger.debug("Provider_info: cannot determine public key")
raise NoPublicKey raise NoPublicKey
self.public_key = "\n".join( self.public_key = "\n".join(
["-----BEGIN PUBLIC KEY-----", public_key, "-----END PUBLIC KEY-----"] ["-----BEGIN PUBLIC KEY-----", public_key, "-----END PUBLIC KEY-----"]