Skip to content

Modern Docker Management, Designed for Everyone

9.0 KB
Raw Blame
name: CI

on:
  push:
    branches: [main]

permissions:
  contents: read
  actions: read
  checks: write
  id-token: write

concurrency:
  group: '${{ github.workflow }}-${{ github.ref }}'
  cancel-in-progress: true

jobs:
  go-tests:
    name: Go Tests (${{ matrix.module.name }})
    runs-on:
      size: 2x8
      image: g7r5wqb57k.registry.depot.dev/ci:latest
    timeout-minutes: 30
    strategy:
      fail-fast: false
      matrix:
        module:
          - name: backend
            path: backend
            timeout: 30
            gcc: true
            cgo_enabled: '1'
          - name: cli
            path: cli
            timeout: 10
            gcc: false
            cgo_enabled: '1'
          - name: types
            path: types
            timeout: 10
            gcc: false
            cgo_enabled: '1'
    steps:
      - name: Checkout
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

      - name: Set up Depot CLI
        if: matrix.module.gcc
        uses: depot/setup-action@91bc8495a33ebfc504ffc89e5674379ccf23c29c # v1.7.2
        with:
          configure-docker: true

      - name: Setup Go
        uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
        with:
          go-version-file: ${{ matrix.module.path }}/go.mod
          cache: true
          cache-dependency-path: &go-cache-dependencies |
            go.work
            go.work.sum
            */go.mod
            */go.sum

      - name: Download modules
        run: just deps install ${{ matrix.module.name }}

      - name: Run unit tests
        env:
          CGO_ENABLED: ${{ matrix.module.cgo_enabled }}
          GO_JUNIT_REPORT_FILE: test-results/junit.xml
        run: just test ${{ matrix.module.name }}

      - name: Report Go test results to Depot
        if: ${{ !cancelled() }}
        uses: depot/test-report-action@2ad5779840a9c63e884fa26f11d019768a27a941 # v1.0.1
        with:
          path: ${{ matrix.module.path }}/test-results/

      - name: Upload coverage artifact
        if: always()
        uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
        with:
          name: ${{ matrix.module.name }}-coverage
          path: ${{ matrix.module.path }}/coverage.txt

  go-linter:
    name: Go Linter (${{ matrix.module.name }})
    runs-on:
      size: 2x8
      image: g7r5wqb57k.registry.depot.dev/ci:latest
    strategy:
      fail-fast: false
      matrix:
        module:
          - name: backend
            args: --build-tags=exclude_frontend --config=../.golangci.yml
          - name: cli
            args: --config=../.golangci.yml
          - name: types
            args: --config=../.golangci.yml
    steps:
      - name: Checkout code
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

      - name: Set up Go
        uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
        with:
          go-version-file: ${{ matrix.module.name }}/go.mod
          cache: true
          cache-dependency-path: *go-cache-dependencies

      - name: Run Golangci-lint
        uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
        with:
          version: latest
          args: ${{ matrix.module.args }}
          working-directory: ${{ matrix.module.name }}
          only-new-issues: false

  frontend-linter:
    name: Frontend Linter
    runs-on:
      size: 2x8
      image: g7r5wqb57k.registry.depot.dev/ci:latest
    steps:
      - name: Checkout code
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

      - name: Setup Vite+
        uses: voidzero-dev/setup-vp@cab1ab9eaff52d4857875f4f2c016e36af8f2c76 # v1.22.0
        with:
          node-version: 26
          cache: true
          run-install: true

      - name: Add svelte-check problem matcher
        run: echo "::add-matcher::.github/matchers/svelte-check-matcher.json"

      - name: Build frontend
        run: just build single frontend

      - name: Run workspace type checks
        run: just lint js

      - name: Run shadcn lint
        run: vp -C frontend run lint

  e2e-tests:
    name: E2E Tests (${{ matrix.database.name }})
    env:
      PLAYWRIGHT_DOCKER_IMAGE_REPOSITORY: g7r5wqb57k.registry.depot.dev/mirrors/playwright
    runs-on:
      size: 4x16
      image: g7r5wqb57k.registry.depot.dev/ci:latest
    # Passing runs finish in about 17 minutes; a broken stack must not grind through retries for hours.
    timeout-minutes: 45
    permissions:
      contents: read
      actions: write
      id-token: write
    strategy:
      fail-fast: false
      matrix:
        database:
          - name: sqlite
            compose_file: setup/compose.yaml
            port: 3000
          - name: postgres
            compose_file: setup/compose-postgres.yaml
            port: 3001
    steps:
      - name: Checkout code
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

      - name: Setup Vite+
        uses: voidzero-dev/setup-vp@cab1ab9eaff52d4857875f4f2c016e36af8f2c76 # v1.22.0
        with:
          node-version: 26
          cache: true
          run-install: false

      - name: Set up Depot CLI
        uses: depot/setup-action@91bc8495a33ebfc504ffc89e5674379ccf23c29c # v1.7.2
        with:
          configure-docker: true

      - name: Install E2E test dependencies
        run: vp -C tests install

      - name: Ensure test images are available
        retry: 2
        timeout-minutes: 5
        run: |
          export DOCKER_CONFIG="$(mktemp -d)"
          trap 'rm -rf "$DOCKER_CONFIG"' EXIT
          printf '%s' "$DEPOT_TOKEN" | docker login g7r5wqb57k.registry.depot.dev --username x-token --password-stdin
          version="$(vp -C tests exec node -p 'require("@playwright/test/package.json").version')"
          for image in public.ecr.aws/nginx/nginx:stable-alpine public.ecr.aws/docker/library/busybox:1.37 "$PLAYWRIGHT_DOCKER_IMAGE_REPOSITORY:v$version-noble"; do
            if ! docker image inspect "$image" > /dev/null 2>&1; then
              docker pull "$image"
            fi
          done

      - name: Run Playwright E2E tests
        run: mkdir -p tests/.report && vp -C tests exec playwright test --project=chromium
        env:
          COMPOSE_FILE: ${{ matrix.database.compose_file }}
          BASE_URL: http://localhost:${{ matrix.database.port }}
          PLAYWRIGHT_JUNIT_OUTPUT_FILE: .report/playwright-${{ matrix.database.name }}.xml

      - name: Upload Playwright HTML report
        if: always()
        uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
        with:
          name: playwright-report-${{ matrix.database.name }}
          path: |
            tests/.report
            !tests/.report/auth/**
            !tests/.report/bin/**
            !tests/.report/cli/**
          include-hidden-files: true
          retention-days: 15

      - name: Report Playwright test results to Depot
        if: ${{ !cancelled() }}
        uses: depot/test-report-action@2ad5779840a9c63e884fa26f11d019768a27a941 # v1.0.1
        with:
          path: tests/.report/*.xml

  cli-e2e-tests:
    name: CLI E2E Tests
    runs-on:
      size: 4x16
      image: g7r5wqb57k.registry.depot.dev/ci:latest
    timeout-minutes: 20
    permissions:
      contents: read
      actions: write
      id-token: write
    steps:
      - name: Checkout code
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

      - name: Setup Vite+
        uses: voidzero-dev/setup-vp@cab1ab9eaff52d4857875f4f2c016e36af8f2c76 # v1.22.0
        with:
          node-version: 26
          cache: true
          run-install: false

      - name: Setup Go
        uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
        with:
          go-version-file: cli/go.mod
          cache: true
          cache-dependency-path: *go-cache-dependencies

      - name: Set up Depot CLI
        uses: depot/setup-action@91bc8495a33ebfc504ffc89e5674379ccf23c29c # v1.7.2
        with:
          configure-docker: true

      - name: Install Playwright test dependencies
        run: vp -C tests install

      - name: Run CLI E2E tests
        run: mkdir -p tests/.report && vp -C tests exec playwright test --project=cli
        env:
          COMPOSE_FILE: setup/compose.yaml
          BASE_URL: http://localhost:3000
          PLAYWRIGHT_DOCKER_BROWSER: '0'
          PLAYWRIGHT_JUNIT_OUTPUT_FILE: .report/playwright-cli.xml

      - name: Upload Playwright HTML report
        if: always()
        uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
        with:
          name: playwright-report-cli
          path: |
            tests/.report
            !tests/.report/auth/**
            !tests/.report/bin/**
            !tests/.report/cli/**
          include-hidden-files: true
          retention-days: 15

      - name: Report Playwright test results to Depot
        if: ${{ !cancelled() }}
        uses: depot/test-report-action@2ad5779840a9c63e884fa26f11d019768a27a941 # v1.0.1
        with:
          path: tests/.report/*.xml