Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

Add Forgejo Actions CI: tests + multi-arch Docker build to Docker Hub

Murtaza Nasir23ff883f8d69
diff --git a/.forgejo/workflows/docker-publish.yml b/.forgejo/workflows/docker-publish.yml
new file mode 100644
index 00000000..f9c823ec
--- /dev/null
+++ b/.forgejo/workflows/docker-publish.yml
@@ -0,0 +1,140 @@
+name: Docker Build and Publish
+
+# Forgejo Actions version. Triggers ONLY on version tags and manual dispatch so
+# the heavy multi-arch (amd64 + emulated arm64) PyTorch build never runs on every
+# push to this homelab runner. Pushes to Docker Hub (learnedmachine/speakr) using
+# the DOCKERHUB_USERNAME / DOCKERHUB_TOKEN secrets configured on the repo.
+
+on:
+ push:
+ tags: [ 'v*.*.*' ]
+ workflow_dispatch:
+
+env:
+ REGISTRY: docker.io
+ IMAGE_NAME: learnedmachine/speakr
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+
+ services:
+ postgres:
+ image: postgres:16
+ env:
+ POSTGRES_USER: speakr
+ POSTGRES_PASSWORD: speakr
+ POSTGRES_DB: speakr_test
+ ports:
+ - 5432:5432
+ options: >-
+ --health-cmd "pg_isready -U speakr"
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v5
+
+ - name: Set up Python
+ uses: actions/setup-python@v6
+ with:
+ python-version: '3.11'
+
+ - name: Install dependencies
+ run: pip install -r requirements.txt
+
+ - name: Run static migration compatibility tests
+ run: python tests/test_migration_compatibility.py
+
+ - name: Run migrations against PostgreSQL
+ env:
+ TEST_DATABASE_URI: postgresql://speakr:speakr@postgres:5432/speakr_test
+ run: python tests/test_postgres_migrations.py
+
+ build:
+ needs: test
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v5
+
+ # arm64 is built via QEMU emulation (no native arm runner). Slow but works.
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v3
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Log into Docker Hub
+ uses: docker/login-action@v3
+ with:
+ registry: ${{ env.REGISTRY }}
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Extract Docker metadata
+ id: meta
+ uses: docker/metadata-action@v5
+ with:
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
+ tags: |
+ type=match,pattern=v(.*),group=1
+ type=sha
+ type=raw,value=latest,enable=${{ github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') }}
+
+ - name: Build and push Docker image
+ uses: docker/build-push-action@v6
+ with:
+ context: .
+ platforms: linux/amd64,linux/arm64
+ push: true
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
+ build-args: |
+ PRODUCTION=1
+
+ build-lite:
+ needs: test
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v5
+
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v3
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Log into Docker Hub
+ uses: docker/login-action@v3
+ with:
+ registry: ${{ env.REGISTRY }}
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Extract Docker metadata (lite)
+ id: meta-lite
+ uses: docker/metadata-action@v5
+ with:
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
+ tags: |
+ type=raw,value=lite,enable=${{ github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') }}
+ type=match,pattern=v(.*),group=1,suffix=-lite
+ type=sha,suffix=-lite
+
+ - name: Build and push lite Docker image
+ uses: docker/build-push-action@v6
+ with:
+ context: .
+ platforms: linux/amd64,linux/arm64
+ push: true
+ tags: ${{ steps.meta-lite.outputs.tags }}
+ labels: ${{ steps.meta-lite.outputs.labels }}
+ build-args: |
+ PRODUCTION=1
+ LIGHTWEIGHT=1
diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml
new file mode 100644
index 00000000..34d6d769
--- /dev/null
+++ b/.forgejo/workflows/test.yml
@@ -0,0 +1,77 @@
+name: Tests
+
+# Forgejo Actions version of the test suite. Forgejo reads .forgejo/workflows
+# in preference to .github/workflows, so this file (not the GitHub one) runs on
+# git.murtaza.cc, while the GitHub copy keeps running on github.com untouched.
+#
+# Syntax is standard GitHub Actions. runs-on: ubuntu-latest is mapped by the
+# Forgejo runner to a real container image (see the runner's labels config).
+# The Python suite isolates itself to a throwaway SQLite DB via conftest.py;
+# test_postgres_migrations.py uses the postgres service below.
+
+on:
+ push:
+ pull_request:
+ workflow_dispatch:
+
+jobs:
+ python-tests:
+ runs-on: ubuntu-latest
+
+ services:
+ postgres:
+ image: postgres:16
+ env:
+ POSTGRES_USER: speakr
+ POSTGRES_PASSWORD: speakr
+ POSTGRES_DB: speakr_test
+ ports:
+ - 5432:5432
+ options: >-
+ --health-cmd "pg_isready -U speakr"
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v5
+
+ - name: Set up Python
+ uses: actions/setup-python@v6
+ with:
+ python-version: '3.11'
+ cache: pip
+
+ - name: Install ffmpeg (needed by stitch / ffprobe tests)
+ run: sudo apt-get update && sudo apt-get install -y ffmpeg
+
+ - name: Install dependencies
+ run: pip install -r requirements.txt pytest
+
+ - name: Run test suite
+ env:
+ # App tests run against an isolated SQLite DB (see conftest.py).
+ # test_postgres_migrations.py reads TEST_DATABASE_URI separately so it
+ # exercises real PostgreSQL compatibility against the service above.
+ TEST_DATABASE_URI: postgresql://speakr:speakr@postgres:5432/speakr_test
+ run: pytest tests/ -q
+
+ js-tests:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v5
+
+ - name: Set up Node
+ uses: actions/setup-node@v4
+ with:
+ node-version: '20'
+ cache: npm
+
+ - name: Install dependencies
+ run: npm ci
+
+ - name: Run Vitest
+ run: npm test