name: CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:
    name: e2e
    runs-on: ubuntu-latest
    env:
      USE_EXISTING_CLUSTER: true
    steps:
    - name: Set up Go 1.x
      uses: actions/setup-go@v2
      with:
        go-version: ^1.13

    - name: Dependencies
      env:
        GO111MODULE: on
      run: |
        go get  golang.org/x/lint/golint
        go get github.com/kisielk/errcheck
        go get  github.com/golangci/golangci-lint/cmd/golangci-lint@v1.30.0
        curl -L -o operator-sdk "https://github.com/operator-framework/operator-sdk/releases/download/v1.0.0/operator-sdk-v1.0.0-x86_64-linux-gnu"
        chmod +x operator-sdk
        sudo mv operator-sdk /bin/

    - name: Start Minikube
      uses: medyagh/setup-minikube@master

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

    - name: Verify
      run: make verify

    - name: E2E Test
      run: |
        kubectl cluster-info
        kubectl get pods -n kube-system
        echo "current-context:" $(kubectl config current-context)
        echo "environment-kubeconfig:" ${KUBECONFIG}
        make e2e USE_EXISTING_CLUSTER=true

    - name: Codecov
      uses: codecov/codecov-action@v1.1.1
