From 13980a288771312f38e9ad9ddbc68c15a15a73f1 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Tue, 24 Mar 2026 08:12:12 +0000 Subject: [PATCH] Migrate to forgejo --- .forgejo/workflows/ci.yml | 94 +++++++++++++++++++++++++++ .forgejo/workflows/docker-publish.yml | 94 +++++++++++++++++++++++++++ 2 files changed, 188 insertions(+) create mode 100644 .forgejo/workflows/ci.yml create mode 100644 .forgejo/workflows/docker-publish.yml diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml new file mode 100644 index 0000000..c333373 --- /dev/null +++ b/.forgejo/workflows/ci.yml @@ -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 diff --git a/.forgejo/workflows/docker-publish.yml b/.forgejo/workflows/docker-publish.yml new file mode 100644 index 0000000..a53ccc2 --- /dev/null +++ b/.forgejo/workflows/docker-publish.yml @@ -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