diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml deleted file mode 100644 index de939bf..0000000 --- a/.forgejo/workflows/build.yaml +++ /dev/null @@ -1,111 +0,0 @@ -on: - push: - tags: - - "**" - workflow_dispatch: - inputs: - verbose: - description: "Verbose" - required: false - default: false - type: boolean - -jobs: - test: - runs-on: container - container: - image: code.philo.ydns.eu/philorg/treetrail-backend-ci - volumes: - - "uv_cache:/root/.cache/uv" - - "ca-cert:/etc/containers/certs.d" - - services: - treetrail-database: - image: code.philo.ydns.eu/philorg/treetrail-database - - steps: - - name: Echo env - if: ${{ inputs.verbose }} - run: | - echo '${{ toJSON(env) }}' - - - uses: actions/checkout@v4 - - - name: Install app with 'uv pip install' - run: uv pip install --python=$UV_PROJECT_ENVIRONMENT --no-deps . - - - name: Run tests (API call) - run: TREETRAIL_DB_HOST=treetrail-database pytest -s tests/basic.py - - build: - runs-on: container - needs: test - 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.6" - - - name: Install - run: uv sync - - - 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: treetrail-backend - oci: true - labels: treetrail-backend - 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: treetrail-backend - 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 fb41758..0000000 --- a/.forgejo/workflows/test.yaml +++ /dev/null @@ -1,34 +0,0 @@ -on: - push: - workflow_dispatch: - inputs: - verbose: - description: "Verbose" - required: false - default: false - type: boolean - -jobs: - test: - runs-on: container - container: - image: code.philo.ydns.eu/philorg/treetrail-backend-ci - volumes: - - "uv_cache:/root/.cache/uv" - - "ca-cert:/etc/containers/certs.d" - services: - treetrail-database: - image: code.philo.ydns.eu/philorg/treetrail-database - steps: - - name: Echo env - if: ${{ inputs.verbose }} - run: | - echo '${{ toJSON(env) }}' - - - uses: actions/checkout@v4 - - - name: Install app with 'uv pip install' - run: uv pip install --python=$UV_PROJECT_ENVIRONMENT --no-deps . - - - name: Run tests (API call) - run: TREETRAIL_DB_HOST=treetrail-database pytest -s tests/basic.py diff --git a/.woodpecker/build.yaml b/.woodpecker/build.yaml new file mode 100644 index 0000000..fd4d9cd --- /dev/null +++ b/.woodpecker/build.yaml @@ -0,0 +1,70 @@ +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 + volumes: + - uv-cache:/uv-cache + environment: + UV_CACHE_DIR: /uv-cache + UV_LINK_MODE: copy + 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-cache:/uv-cache + # Fill in the trusted checkbox in Woodpecker's settings as well + privileged: true + environment: + UV_CACHE_DIR: /uv-cache + UV_LINK_MODE: copy + registry: code.philo.ydns.eu + org: philorg + container_name: treetrail-backend + 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 diff --git a/.woodpecker/test.yaml b/.woodpecker/test.yaml new file mode 100644 index 0000000..d8816b2 --- /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: code.philo.ydns.eu/philorg/uv + commands: + - .venv/bin/pytest -s tests/basic.py diff --git a/README.md b/README.md index 393dbd8..759cac0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ *Tree Trail* is a fun and pedagogic tool to discover the trails and trees around. -This is the server (back-end), written in Python. \ No newline at end of file +This is the server (back-end), written in Python. + +[![status-badge](https://code.philo.ydns.eu/woodpecker/api/badges/20/status.svg)](https://code.philo.ydns.eu/woodpecker/repos/20) + diff --git a/src/treetrail/__init__.py b/src/treetrail/__init__.py index 95b89f2..00eba03 100644 --- a/src/treetrail/__init__.py +++ b/src/treetrail/__init__.py @@ -4,5 +4,5 @@ try: from dunamai import Version, Style __version__ = Version.from_git().serialize(style=Style.SemVer, dirty=True) -except ImportError: - __version__ = importlib.metadata.version("treetrail-backend") +except (ImportError, RuntimeError): + __version__ = importlib.metadata.version(__name__) diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index e69de29..0000000