Skip to content

User Plugin System

User Plugin System #19

Workflow file for this run

# CI workflow for Pull Requests
# Runs tests, linting, frontend checks, and Docker build with PR tag
#
# =============================================================================
# SELF-HOSTED RUNNER MODIFICATIONS
# =============================================================================
# This workflow uses self-hosted runners (arc-runner-codex) with ubuntu:22.04
# containers. To revert to paid GitHub runners:
#
# 1. Replace all `runs-on: arc-runner-codex` with `runs-on: ubuntu-latest`
# 2. Remove all `container: ubuntu:22.04` lines
# 3. Remove all "Install base dependencies" steps
# 4. Remove all "Install Rust" steps (GitHub runners have Rust pre-installed)
# =============================================================================
name: CI
permissions:
contents: read
packages: write
on:
pull_request:
branches:
- main
# Cancel in-progress runs for same PR
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Shared cache directory on PVC mounted by ARC runners
# Each workflow run gets its own isolated directory under /ci-cache
env:
CI_CACHE: /ci-cache/${{ github.run_id }}
jobs:
# Build test binaries and create nextest archive
build-tests:
name: Build Tests
# SELF-HOSTED: Change to ubuntu-latest for GitHub runners and remove container
runs-on: arc-runner-codex
container:
image: ubuntu:22.04
volumes:
- /ci-cache:/ci-cache
timeout-minutes: 60
env:
SCCACHE_GHA_ENABLED: "true"
SCCACHE_GHA_VERSION: test
RUSTC_WRAPPER: sccache
steps:
- name: Install base dependencies
run: |
apt-get update
apt-get install -y git curl build-essential pkg-config clang mold
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Prepare cache directory
run: |
mkdir -p $CI_CACHE
if test -d $CI_CACHE; then
echo "CI_CACHE directory ready: $CI_CACHE"
ls -la $(dirname $CI_CACHE)
else
echo "::error::CI_CACHE directory $CI_CACHE is not available. Is the PVC mounted?"
exit 1
fi
- name: Build and archive tests
run: |
cargo nextest archive --features rar --archive-file $CI_CACHE/nextest-archive.tar.zst
ls -lh $CI_CACHE/nextest-archive.tar.zst || { echo "::error::Failed to write nextest archive to cache"; exit 1; }
# Replaced by /ci-cache PVC - uncomment to revert to GitHub artifact storage
# - name: Upload test archive
# uses: actions/upload-artifact@v4
# with:
# name: nextest-archive
# path: nextest-archive.tar.zst
# retention-days: 1
# Run tests in parallel partitions
test:
name: Test (${{ matrix.partition }}/5)
needs: build-tests
# SELF-HOSTED: Change to ubuntu-latest for GitHub runners and remove container
runs-on: arc-runner-codex
container:
image: ubuntu:22.04
volumes:
- /ci-cache:/ci-cache
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
partition: [1, 2, 3, 4, 5]
steps:
- name: Install base dependencies
run: |
apt-get update
apt-get install -y git curl
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
# Replaced by /ci-cache PVC - uncomment to revert to GitHub artifact storage
# - name: Download test archive
# uses: actions/download-artifact@v4
# with:
# name: nextest-archive
- name: Run tests (partition ${{ matrix.partition }}/5)
run: cargo nextest run --archive-file $CI_CACHE/nextest-archive.tar.zst --partition hash:${{ matrix.partition }}/5
# Run linting checks
lint:
name: Lint
# SELF-HOSTED: Change to ubuntu-latest for GitHub runners and remove container
runs-on: arc-runner-codex
container: ubuntu:22.04
timeout-minutes: 30
env:
SCCACHE_GHA_ENABLED: "true"
SCCACHE_GHA_VERSION: lint
RUSTC_WRAPPER: sccache
steps:
- name: Install base dependencies
run: |
apt-get update
apt-get install -y git curl build-essential pkg-config clang mold
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Format check
run: cargo fmt -- --check
- name: Clippy check
run: cargo clippy --features rar -- -D warnings
# Run frontend tests and build
frontend:
name: Frontend
# SELF-HOSTED: Change to ubuntu-latest for GitHub runners and remove container
runs-on: arc-runner-codex
container: ubuntu:22.04
timeout-minutes: 30
steps:
- name: Install base dependencies
run: |
apt-get update
apt-get install -y git curl
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install dependencies
working-directory: web
run: |
rm -rf node_modules package-lock.json
npm install
- name: Lint check
working-directory: web
run: npm run lint
- name: Run tests
working-directory: web
run: npm run test:run
- name: Build frontend
working-directory: web
run: npm run build
# Run plugin checks (lint, typecheck, tests)
plugins:
name: Plugins (${{ matrix.plugin }})
# SELF-HOSTED: Change to ubuntu-latest for GitHub runners and remove container
runs-on: arc-runner-codex
container: ubuntu:22.04
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
plugin:
- sdk-typescript
- metadata-echo
- metadata-mangabaka
- metadata-openlibrary
- recommendations-anilist
- sync-anilist
steps:
- name: Install base dependencies
run: |
apt-get update
apt-get install -y git curl
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
# SDK must be built first for other plugins to use
- name: Build SDK (dependency)
if: matrix.plugin != 'sdk-typescript'
working-directory: plugins/sdk-typescript
run: |
rm -rf node_modules package-lock.json
npm install
npm run build
- name: Install dependencies
working-directory: plugins/${{ matrix.plugin }}
run: |
rm -rf node_modules package-lock.json
npm install
- name: Lint
working-directory: plugins/${{ matrix.plugin }}
run: npm run lint
- name: Typecheck
working-directory: plugins/${{ matrix.plugin }}
run: npx tsc --noEmit
- name: Test
working-directory: plugins/${{ matrix.plugin }}
run: npm run test
- name: Build
working-directory: plugins/${{ matrix.plugin }}
run: npm run build
# Build and push Docker image with PR tag
docker:
name: Docker
needs: [test, lint, frontend, plugins]
runs-on: arc-runner-codex
timeout-minutes: 240
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Determine build info
id: info
run: |
echo "DOCKER_REGISTRY=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=pr
type=sha,prefix=pr-${{ github.event.pull_request.number }}-sha-
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.cross
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/${{ env.DOCKER_REGISTRY }}-buildcache:latest
cache-to: type=registry,ref=ghcr.io/${{ env.DOCKER_REGISTRY }}-buildcache:latest,mode=max
# Clean up intermediate cache and artifacts that are no longer needed
cleanup:
name: Cleanup
needs:
- test
- docker
if: always()
runs-on: arc-runner-codex
container:
image: ubuntu:22.04
volumes:
- /ci-cache:/ci-cache
steps:
- name: Clean up CI cache
run: |
echo "Removing current run cache: $CI_CACHE"
rm -rf $CI_CACHE
# Remove orphaned cache directories older than 24 hours (from cancelled/crashed runs)
echo "Cleaning orphaned cache directories older than 24h..."
find /ci-cache -mindepth 1 -maxdepth 1 -type d -mmin +1440 -exec echo "Removing stale: {}" \; -exec rm -rf {} \;
# Replaced by /ci-cache PVC - uncomment to revert to GitHub artifact storage
# - name: Delete intermediate artifacts
# uses: geekyeggo/delete-artifact@v5
# with:
# name: nextest-archive