name: Tinyauth CI
on:
  push:
    branches:
      - main
  pull_request:

jobs:
  ci:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup bun
        uses: oven-sh/setup-bun@v2

      - name: Setup go
        uses: actions/setup-go@v5
        with:
          go-version: "^1.23.2"

      - name: Install frontend dependencies
        run: |
          cd frontend
          bun install

      - name: Set version
        run: |
          echo testing > internal/assets/version

      - name: Build frontend
        run: |
          cd frontend
          bun run build

      - name: Copy frontend
        run: |
          cp -r frontend/dist internal/assets/dist

      - name: Run tests
        run: go test -v ./...
