name: checks
on:
  pull_request:
  push:
    branches:
      - 'release-*'
      - 'master'
      - 'main'
    tags:
      - 'v*'
env:
  golang-version: '1.16'
jobs:
  generate:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os:
          - macos-latest
          - ubuntu-latest
    name: Generate and format
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-go@v2
      with:
        go-version: ${{ env.golang-version }}
    - run: make --always-make format generate && git diff --exit-code
  check-links:
    runs-on: ubuntu-latest
    name: Check markdown links
    steps:
    - uses: actions/checkout@v2
    - uses: gaurav-nelson/github-action-markdown-link-check@v1
      with:
        use-quiet-mode: 'yes'
        config-file: '.github/workflows/.mlc_config.json'
      continue-on-error: true
  check-golang:
    runs-on: ubuntu-latest
    name: Golang linter
    steps:
      - uses: actions/checkout@v2
      - name: golangci-lint
        uses: golangci/golangci-lint-action@v2
        with:
          version: v1.40.1
          args: --timeout 10m0s
  check-metrics:
    runs-on: ubuntu-latest
    name: Check prometheus metrics
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-go@v2
      with:
        go-version: ${{ env.golang-version }}
    - run: make check-metrics
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os:
          - macos-latest
          - ubuntu-latest
    name: Build operator binary
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-go@v2
      with:
        go-version: ${{ env.golang-version }}
    - run: make operator
  po-rule-migration:
    runs-on: ubuntu-latest
    name: Build Prometheus Operator rule config map to rule file CRDs CLI tool
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-go@v2
      with:
        go-version: ${{ env.golang-version }}
    - run: cd cmd/po-rule-migration && go install

