name: PR validation

on:
  pull_request:
    branches:
      - 'develop'
      - 'main'

concurrency:
  group: mizu-pr-validation-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build-cli:
    name: Build CLI
    runs-on: ubuntu-latest
    steps:
      - name: Set up Go 1.16
        uses: actions/setup-go@v2
        with:
          go-version: '1.16'

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

      - name: Build CLI
        run: make cli

  build-agent:
    name: Build Agent
    runs-on: ubuntu-latest
    steps:
      - name: Set up Go 1.16
        uses: actions/setup-go@v2
        with:
          go-version: '1.16'

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

      - shell: bash
        run: |
          sudo apt-get install libpcap-dev

      - name: Build Agent
        run: make agent

  build-ui:
    name: Build UI
    runs-on: ubuntu-latest
    steps:
      - name: Set up Node 14
        uses: actions/setup-node@v2
        with:
          node-version: '14'

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

      - name: Build UI
        run: make ui
