name: Test Go App and Vue Frontend

on:
  push:
    branches: ["*"]
  pull_request:
    branches: ["*"]

jobs:
  build-and-test:
    runs-on: ubuntu-latest

    steps:
      - name: Check out repository
        uses: actions/checkout@v6

      - name: Set up Node.js
        uses: actions/setup-node@v6
        with:
          node-version: "24"

      - name: Install pnpm
        uses: https://git.qxp.ch/actions/setup-pnpm@v4
        with:
          version: 10

      - name: Install npm dependencies
        run: pnpm set registry https://npm.qxp.ch/ && cd internal/dashboard/frontend && pnpm install

      - name: Build Vue Frontend
        run: cd internal/dashboard/frontend && pnpm run build

      - name: Check for frontend build errors
        continue-on-error: true
        run: |
          if [ $? -ne 0 ]; then
            echo "Vue build failed"
            exit 1
          fi

      - name: Set up Go environment
        uses: actions/setup-go@v6
        with:
          go-version: "1.26.1"

      - name: Run tests for Go App
        run: |
          # Install dependencies if needed
          go mod tidy

          # Run Go tests (assuming you have a test suite)
          go test ./...
