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

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions:
  checks: write
  contents: read

jobs:
  multi-peer:
    runs-on: ubicloud-standard-2-ubuntu-2204
    steps:
      - uses: actions/checkout@v5
      - run: cargo build --bin rosenpass --release
      - run: python misc/generate_configs.py
      - run: chmod +x .ci/run-regression.sh
      - run: .ci/run-regression.sh 100 20
      - run: |
          [ $(ls -1 output/ate/out | wc -l) -eq 100 ]

  boot-race:
    runs-on: ubicloud-standard-2-ubuntu-2204
    steps:
      - uses: actions/checkout@v5
      - run: cargo build --bin rosenpass --release
      - run: chmod +x .ci/boot_race/run.sh
      - run: cargo run --release --bin rosenpass gen-keys .ci/boot_race/a.toml
      - run: cargo run --release --bin rosenpass gen-keys .ci/boot_race/b.toml
      - run: .ci/boot_race/run.sh 5 2 .ci/boot_race/a.toml .ci/boot_race/b.toml
      - run: .ci/boot_race/run.sh 5 1 .ci/boot_race/a.toml .ci/boot_race/b.toml
      - run: .ci/boot_race/run.sh 5 0 .ci/boot_race/a.toml .ci/boot_race/b.toml
