Migrate to forgejo

This commit is contained in:
Andras Schmelczer 2026-03-24 08:12:12 +00:00
parent e09aa574b0
commit 13980a2887
2 changed files with 188 additions and 0 deletions

94
.forgejo/workflows/ci.yml Normal file
View file

@ -0,0 +1,94 @@
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ gitea.workflow }}-${{ gitea.ref }}
cancel-in-progress: true
jobs:
python:
name: Python (lint + test)
runs-on: docker
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- name: Install dependencies
run: uv sync
- name: Ruff check
run: uv run ruff check .
- name: Deptry (unused dependencies)
run: uv run deptry .
- name: Tests
run: |
uv run pytest pipeline/utils/test_haversine.py
uv run pytest pipeline/utils/test_poi_counts.py
uv run pytest pipeline/transform/postcode_boundaries/test_postcode_boundaries.py
frontend:
name: Frontend (lint + typecheck)
runs-on: docker
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: ESLint
run: npm run lint
- name: Prettier check
run: npm run format:check
- name: TypeScript typecheck
run: npm run typecheck
rust:
name: Rust (lint + test)
runs-on: docker
defaults:
run:
working-directory: server-rs
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: server-rs
- name: Clippy
run: cargo clippy -- -D warnings
- name: Format check
run: cargo fmt --check
- name: Install cargo-machete
run: cargo install cargo-machete
- name: Unused dependencies check
run: cargo machete
- name: Tests
run: cargo test

View file

@ -0,0 +1,94 @@
name: Build and publish Docker image
on:
push:
branches: [main]
tags: ["v*"]
workflow_dispatch:
env:
REGISTRY: ${{ gitea.server_url }}
IMAGE_NAME: ${{ gitea.repository }}
jobs:
build-and-push:
runs-on: docker
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v4
- name: Download map assets (fonts, sprites, twemoji)
run: uv run python -m pipeline.download.map_assets --output frontend/public/assets
- name: Download arcgis data for finder
run: uv run python -m pipeline.download.arcgis --output property-data/arcgis_data.parquet
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Forgejo Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ gitea.actor }}
password: ${{ secrets.GITEA_TOKEN }}
- name: Determine image tags
id: tags
run: |
REPO=$(echo "${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]')
SHA_SHORT=$(echo "${{ gitea.sha }}" | cut -c1-7)
TAGS="${{ env.REGISTRY }}/${REPO}:sha-${SHA_SHORT}"
# Add latest tag on default branch
if [ "${{ gitea.ref }}" = "refs/heads/main" ]; then
TAGS="${TAGS},${{ env.REGISTRY }}/${REPO}:latest"
fi
# Add version tags for semver tags
REF="${{ gitea.ref }}"
if [[ "$REF" =~ ^refs/tags/v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
VERSION="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}"
MINOR="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"
TAGS="${TAGS},${{ env.REGISTRY }}/${REPO}:${VERSION}"
TAGS="${TAGS},${{ env.REGISTRY }}/${REPO}:${MINOR}"
fi
echo "tags=${TAGS}" >> "$GITHUB_OUTPUT"
echo "repo=${REPO}" >> "$GITHUB_OUTPUT"
echo "sha_short=${SHA_SHORT}" >> "$GITHUB_OUTPUT"
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.tags.outputs.tags }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ steps.tags.outputs.repo }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ steps.tags.outputs.repo }}:buildcache,mode=max
- name: Build and push screenshot service
uses: docker/build-push-action@v6
with:
context: ./screenshot
push: true
tags: |
${{ env.REGISTRY }}/${{ steps.tags.outputs.repo }}-screenshot:latest
${{ env.REGISTRY }}/${{ steps.tags.outputs.repo }}-screenshot:sha-${{ steps.tags.outputs.sha_short }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ steps.tags.outputs.repo }}-screenshot:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ steps.tags.outputs.repo }}-screenshot:buildcache,mode=max
- name: Build and push finder service
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.finder
push: true
tags: |
${{ env.REGISTRY }}/${{ steps.tags.outputs.repo }}-finder:latest
${{ env.REGISTRY }}/${{ steps.tags.outputs.repo }}-finder:sha-${{ steps.tags.outputs.sha_short }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ steps.tags.outputs.repo }}-finder:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ steps.tags.outputs.repo }}-finder:buildcache,mode=max