name: Test Wings Installer

on:
  schedule:
    # At 09:00 on Saturday
    - cron: "0 9 * * 6"

  push:
    paths:
      - "installers/wings.sh"
      - "lib/lib.sh"
    branches: ["master"]

  pull_request:
    paths:
      - "installers/wings.sh"
      - "lib/lib.sh"
    branches: ["master"]

jobs:
  install_wings:
    runs-on: macos-latest
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu_noble
          - ubuntu_focal
          - ubuntu_jammy
          - debian_buster
          - debian_bullseye
          - debian_bookworm
          - rockylinux_8
          - rockylinux_9
          - almalinux_8
          - almalinux_9
    steps:
      - uses: actions/checkout@v3

      - name: Cache Vagrant boxes
        uses: actions/cache@v3
        with:
          path: ~/.vagrant.d/boxes
          key: ${{ runner.os }}-vagrant-${{ matrix.os }}-${{ hashFiles('Vagrantfile') }}
          restore-keys: |
            ${{ runner.os }}-vagrant-${{ matrix.os }}

      - name: Show Vagrant version
        run: vagrant --version

      - name: Run vagrant up
        run: vagrant up ${{ matrix.os }}

      - name: Run script in vagrant env
        run: vagrant ssh ${{ matrix.os }} -c "sudo -i bash /vagrant/.github/workflow_scripts/wings-install.sh"
