name: Nightly Install
on:
  schedule:
    - cron: "0 0 * * 1-5"
  workflow_dispatch: {}

permissions:
  contents: read

jobs:
  test:
    name: "Smoke Test"
    runs-on: ubuntu-latest
    timeout-minutes: 40
    strategy:
      fail-fast: false
      matrix:
        channel: [stable, latest]
        vm: [rocky-9, fedora, opensuse-leap, ubuntu-2404]
      max-parallel: 4
    defaults:
      run:
        working-directory: tests/install/${{ matrix.vm }}
    env:
      INSTALL_K3S_CHANNEL: ${{ matrix.channel }}
    steps:
      - name: "Checkout"
        uses: actions/checkout@v4
        with: {fetch-depth: 1}
      - name: Set up vagrant and libvirt
        uses: ./.github/actions/vagrant-setup
      - name: "Vagrant Cache"
        uses: actions/cache@v4
        with:
          path: |
             ~/.vagrant.d/boxes
          key: vagrant-box-${{ matrix.vm }}
        id: vagrant-cache
      - name: "Vagrant Plugin(s)"
        run: vagrant plugin install vagrant-k3s vagrant-reload
      - name: "Vagrant Up ⏩ Install K3s"
        run: vagrant up
      - name: "⏳ Node"
        run: vagrant provision --provision-with=k3s-wait-for-node
      - name: "⏳ CoreDNS"
        run: vagrant provision --provision-with=k3s-wait-for-coredns
      - name: "⏳ Local Storage"
        run: vagrant provision --provision-with=k3s-wait-for-local-storage
        continue-on-error: true
      - name: "⏳ Metrics Server"
        run: vagrant provision --provision-with=k3s-wait-for-metrics-server
        continue-on-error: true
      - name: "⏳ Traefik"
        run: vagrant provision --provision-with=k3s-wait-for-traefik
        continue-on-error: true
      - name: "k3s-status"
        run: vagrant provision --provision-with=k3s-status
      - name: "k3s-procps"
        run: vagrant provision --provision-with=k3s-procps