name: Crossplane Provider CI

on:
  push:
    branches: [main, develop]
    paths:
      - 'crossplane-provider-proxmox/**'
      - '.github/workflows/crossplane-ci.yml'
  pull_request:
    branches: [main, develop]
    paths:
      - 'crossplane-provider-proxmox/**'

jobs:
  test:
    name: Go Test
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./crossplane-provider-proxmox
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v4
        with:
          go-version: '1.21'
      - run: go mod download
      - run: go test -v -race -coverprofile=coverage.out ./...
      - uses: codecov/codecov-action@v3
        with:
          files: ./crossplane-provider-proxmox/coverage.out
          flags: crossplane
          name: codecov-crossplane

  lint:
    name: Go Lint
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./crossplane-provider-proxmox
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v4
        with:
          go-version: '1.21'
      - uses: golangci/golangci-lint-action@v3
        with:
          version: latest
          working-directory: ./crossplane-provider-proxmox

  build:
    name: Go Build
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./crossplane-provider-proxmox
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v4
        with:
          go-version: '1.21'
      - run: go mod download
      - run: make build

