name: daily
on:
  workflow_dispatch:
  schedule:
    - cron: '42 0 * * *' # daily at 00:42
concurrency:
  group: ${{ github.workflow }}
  cancel-in-progress: true

jobs:
  bench:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version-file: ./go.mod
      - run: AUTOBAHN=1 make bench
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Disable AppArmor
        if: runner.os == 'Linux'
        run: |
          # Disable AppArmor for Ubuntu 23.10+.
          # https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md
          echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version-file: ./go.mod
      - run: AUTOBAHN=1 make test
      - uses: actions/upload-artifact@v4
        with:
          name: coverage.html
          path: ./ci/out/coverage.html
  bench-dev:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: dev
      - uses: actions/setup-go@v5
        with:
          go-version-file: ./go.mod
      - run: AUTOBAHN=1 make bench
  test-dev:
    runs-on: ubuntu-latest
    steps:
      - name: Disable AppArmor
        if: runner.os == 'Linux'
        run: |
          # Disable AppArmor for Ubuntu 23.10+.
          # https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md
          echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
      - uses: actions/checkout@v4
        with:
          ref: dev
      - uses: actions/setup-go@v5
        with:
          go-version-file: ./go.mod
      - run: AUTOBAHN=1 make test
      - uses: actions/upload-artifact@v4
        with:
          name: coverage-dev.html
          path: ./ci/out/coverage.html
