name: Copilot Setup Steps
permissions:
  contents: read

on:
  workflow_dispatch:

jobs:
  copilot-setup-steps:
    name: Setup Go and gopls
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v6

      - name: Set up Go
        uses: actions/setup-go@v6
        with:
          go-version-file: go.mod
          cache: true

      - name: Verify Go installation
        run: |
          go version
          go env

      - name: Install gopls
        run: |
          go install golang.org/x/tools/gopls@latest

      - name: Verify gopls installation
        run: |
          gopls version

      - name: Install golangci-lint
        uses: golangci/golangci-lint-action@v9
        with:
          version: latest

      - name: Download Go dependencies
        run: |
          go mod download
          go mod verify

      - name: Build encoder-setup utility
        run: |
          go build -tags encoder_setup -o encoder-setup ./cmd/encoder-setup
          ls -lh encoder-setup

      - name: Run encoder-setup
        run: |
          ./encoder-setup

      - name: Install gotestsum
        run: |
          go install gotest.tools/gotestsum@latest

      - name: Verify gotestsum installation
        run: |
          gotestsum --version

      - name: Setup complete
        run: |
          echo "✅ Go environment setup complete"
          echo "✅ gopls (Go language server) installed"
          echo "✅ golangci-lint installed"
          echo "✅ Dependencies downloaded and verified"
          echo "✅ WebP encoder configured (libwebp 1.6.0)"
          echo "✅ gotestsum (test runner) installed"
