name: integration-tests

on:
  push:
    branches:
      - main

  pull_request:
    branches:
      - main

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    runs-on: macos-latest

    steps:
      - uses: actions/checkout@v3
        with:
          submodules: recursive

      - name: Install Pre-requisites
        run: |
          brew install qemu gnu-getopt coreutils cdrtools

      - name: Cache tmp files
        uses: actions/cache@v3
        with:
          path: |
            .tmp/*.qcow2
            .tmp/test_rsa
            .tmp/test_rsa.pub
          # FIXME: we should invalidate the cache on new bpf-linker releases.
          # For now we must manually delete the cache when we release a new
          # bpf-linker version.
          key: tmp-files-${{ hashFiles('test/run.sh') }}

      - name: Run integration tests
        run: test/run.sh