---
name: Linting

on:
  pull_request:

jobs:
  code-gen:
    name: Submariner K8s API Code Generation
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repository
        uses: actions/checkout@v2
      - name: Run codegen
        run: make codegen
      - name: Verify generated code matches committed code
        run: git add -A && git diff --staged --exit-code

  gitlint:
    name: Commit Message(s)
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repository
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Run gitlint
        run: make gitlint

  golangci-lint:
    name: Go
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repository
        uses: actions/checkout@v2
      - name: Run golangci-lint
        run: make golangci-lint

  headers:
    name: License Headers
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repository
        uses: actions/checkout@v2

      - name: Check License Headers
        uses: nilp0inter/search-legal-headers@v0.1.0

  markdown-link-check:
    name: Markdown Links (modified files)
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repository
        uses: actions/checkout@v2

      - name: Run markdown-link-check
        uses: gaurav-nelson/github-action-markdown-link-check@v1
        with:
          config-file: ".markdownlinkcheck.json"
          check-modified-files-only: "yes"
          base-branch: ${{ github.base_ref }}

  markdownlint:
    name: Markdown
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repository
        uses: actions/checkout@v2
      - name: Run markdownlint
        run: make markdownlint

  yaml-lint:
    name: YAML
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repository
        uses: actions/checkout@v2
      - name: Run yamllint
        run: make yamllint
