name: Regression Tests

on:
  schedule:
    - cron: "0 0/3 * * *"
  workflow_dispatch:

jobs:
  build:
    strategy:
      matrix:
        # Test of these containers
        container: ["ubuntu-dev:20"]
        build-type: [Debug, Release]
        runner: [ubuntu-latest, [self-hosted, linux, ARM64]]
    runs-on: ${{ matrix.runner }}

    container:
      image: ghcr.io/romange/${{ matrix.container }}
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: true

      - name: Print cpu info
        run: cat /proc/cpuinfo

      - name: Configure & Build
        run: |
          cmake -B ${GITHUB_WORKSPACE}/build -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -GNinja \
                -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DPRINT_STACKTRACES_ON_SIGNAL=ON

          cd ${GITHUB_WORKSPACE}/build  && ninja dragonfly
          pwd
          ls -l ..

      - name: Run regression tests action
        uses: ./.github/actions/regression-tests
        with:
          dfly-executable: dragonfly
          gspace-secret: ${{ secrets.GSPACES_BOT_DF_BUILD }}
          run-only-on-ubuntu-latest: false
          build-folder-name: build

      - name: Upload logs on failure
        if: failure()
        uses: actions/upload-artifact@v3
        with:
          name: logs
          path: /tmp/dragonfly.*
