name: Go CI

on:
  push:
    branches: ["*"]

jobs:
  build:
    name: turbo CI
    timeout-minutes: 10
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]

    steps:
      - name: Set up Go 1.x
        uses: actions/setup-go@v2
        with:
          go-version: 1.17.2
        id: go

      - name: Setup Node.js environment
        uses: actions/setup-node@v1.4.4
        with:
          node-version: 14

      - name: Check out code into the Go module directory
        uses: actions/checkout@v2
        with:
          fetch-depth: 2

      - name: Build & Unit Test
        run: yarn turbo run test --scope=cli

      - name: Lint
        run: yarn turbo run lint --scope=cli

      - name: E2E Tests
        run: |
          npm install -g pnpm
          cd cli && make e2e

      - name: Benchmark and Smoke Tests
        run: cd cli && make bench/turbo

  build-win:
    name: turbo CI
    timeout-minutes: 10
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [windows-latest]

    steps:
      - name: Set up Go 1.x
        uses: actions/setup-go@v2
        with:
          go-version: 1.17.2
        id: go

      - name: Setup Node.js environment
        uses: actions/setup-node@v1.4.4
        with:
          node-version: 14

      - name: Check out code into the Go module directory
        uses: actions/checkout@v2
        with:
          fetch-depth: 2

      - name: go test
        run: cd cli && go test ./cmd/... ./internal/...

      - name: go vet
        run: cd cli && go vet ./cmd/... ./internal/...

      - name: Build
        run: cd cli && go build ./cmd/turbo/...

      - name: E2E Tests
        run: |
          npm install -g pnpm
          cd cli && make e2e

      - name: Benchmark and Smoke Tests
        run: cd cli && make bench/turbo
