gisaf-backend/.forgejo/workflows/build.yaml

118 lines
3.2 KiB
YAML
Raw Permalink Normal View History

2024-12-17 19:19:06 +01:00
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/gisaf-backend-ci
volumes:
- "uv_cache:/root/.cache/uv"
- "ca-cert:/etc/containers/certs.d"
services:
gisaf-database:
image: code.philo.ydns.eu/philorg/gisaf-database
redis:
image: docker.io/redis:alpine
steps:
- name: Echo env
if: ${{ inputs.verbose }}
run: |
echo '${{ toJSON(env) }}'
- uses: actions/checkout@v4
2025-03-16 19:02:10 +01:00
with:
fetch-depth: 0
2024-12-17 19:19:06 +01:00
- name: Install app with 'uv pip install'
run: uv pip install --python=$UV_PROJECT_ENVIRONMENT --no-deps .
- name: Initialize database
run: GISAF__DB__HOST=gisaf-database gisaf create-db
- name: Run tests (API call)
run: GISAF__DB__HOST=gisaf-database GISAF__GISAF_LIVE__REDIS=redis://redis pytest -s tests/basic.py -W ignore::DeprecationWarning
build:
runs-on: container
needs: test
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
2025-03-16 19:02:10 +01:00
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v4
with:
version: "0.6.6"
2024-12-17 19:19:06 +01:00
2025-03-16 19:02:10 +01:00
- name: Install
run: uv sync
2024-12-17 19:19:06 +01:00
2025-03-16 19:02:10 +01:00
- 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
2024-12-17 19:19:06 +01:00
- name: Workaround for bug of podman-login
2025-03-16 19:02:10 +01:00
if: env.DISTANCE == '0'
2024-12-17 19:19:06 +01:00
run: |
mkdir -p $HOME/.docker
echo "{ \"auths\": {} }" > $HOME/.docker/config.json
- name: Log in to the container registry (with another workaround)
2025-03-16 19:02:10 +01:00
if: env.DISTANCE == '0'
2024-12-17 19:19:06 +01:00
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
2025-03-16 19:02:10 +01:00
if: env.DISTANCE == '0'
2024-12-17 19:19:06 +01:00
uses: actions/buildah-build@v1
with:
image: gisaf-backend
oci: true
labels: gisaf-backend
2025-03-16 19:02:10 +01:00
tags: "latest ${{ env.VERSION }}"
2024-12-17 19:19:06 +01:00
containerfiles: |
./Containerfile
- name: Push the image to the registry
2025-03-16 19:02:10 +01:00
if: env.DISTANCE == '0'
2024-12-17 19:19:06 +01:00
uses: actions/push-to-registry@v2
with:
registry: "docker://${{ vars.REGISTRY }}/${{ vars.ORGANISATION }}"
image: gisaf-backend
2025-03-16 19:02:10 +01:00
tags: "latest ${{ env.VERSION }}"
2024-12-17 19:19:06 +01:00
2025-03-16 19:02:10 +01:00
- name: Build wheel
if: env.DISTANCE == '0'
2024-12-17 19:19:06 +01:00
run: uv build --wheel
- name: Publish Python package (home)
2025-03-16 19:02:10 +01:00
if: env.DISTANCE == '0'
2024-12-17 19:19:06 +01:00
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
2025-03-16 19:02:10 +01:00
continue-on-error: true