.github/workflows/ci.yml

name: ci

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

permissions:
  contents: read

jobs:
  test:
    name: test (${{ matrix.os }} / ${{ matrix.arch }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-22.04
            arch: amd64
          - os: ubuntu-22.04-arm
            arch: arm64
    steps:
      - name: checkout
        uses: actions/checkout@v4

      - name: setup-go
        uses: actions/setup-go@v5
        with:
          go-version: "1.22"
          cache: true

      - name: go vet
        run: go vet ./...

      - name: go test -race
        run: go test -race -covermode=atomic -coverprofile=coverage.out ./...

      - name: upload coverage
        uses: actions/upload-artifact@v4
        with:
          name: coverage-${{ matrix.arch }}
          path: coverage.out
          if-no-files-found: error
          retention-days: 7

  vet-bpf:
    name: bpf vet
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v4
      - name: install clang
        run: sudo apt-get update && sudo apt-get install -y clang llvm
      - name: check bpf compiles
        run: make bpf