# This is a basic workflow to help you get started with Actions

name: Test Experimental Features

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the master branch
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

env:
    # For use by the Windows runner (ignored by the others):
    SCONS_CACHE_MSVC_CONFIG: 1

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "experimental"
  experimental:

    strategy:
      fail-fast: false
      matrix:
        # In the 2nd half of 2022 the setup-mingw was often failing on
        # windows-latest, when 2022 became the latest. Now 2025 is out,
        # and 2019 is being retired, we need some kind of a solution.
        cfg: [
          {os: 'ubuntu-latest', args: ''},
          {os: 'windows-latest', args: ''},
          {os: 'macos-latest', args: '--exclude-list=testing/ci/macos_ci_skip.txt'},
        ]

    # The type of runner that the job will run on
    runs-on: ${{ matrix.cfg.os }}

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v4

      # experiment: maybe don't need this?
      # update: looks like we do: with this commented out, the build hung
      # - name: Set up MinGW
      #   uses: egor-tensin/setup-mingw@v2.2.0
      #   if: matrix.os == 'windows-2019'
      #   with:
      #     platform: x64
      #     static: 0

      - name: Set up MSYS2 ${{ matrix.cfg.os }}
        uses: msys2/setup-msys2@v2
        if: startsWith(matrix.cfg.os, 'windows')
        with:
          msystem: UCRT64
          update: false
          install: git mingw-w64-ucrt-x86_64-gcc

      - name: Set up Python 3.11 ${{ matrix.cfg.os }}
        uses: actions/setup-python@v5
        with:
          python-version: '3.11'

      - name: Install dependencies including ninja ${{ matrix.cfg.os }}
        run: |
          python -m pip install --progress-bar off --upgrade pip
          python -m pip install --progress-bar off ninja psutil
          # sudo apt-get update

      - name: Populate MSVC cache ${{ matrix.cfg.os }}
        if: startsWith(matrix.cfg.os, 'windows')
        run: |
          python testing/ci/windows_msvc_cache.py

      - name: Test experimental packages ${{ matrix.cfg.os }}
        run: |
          python runtest.py --time ${{ matrix.cfg.args }} test/import.py test/ninja

      - name: Archive Failed tests ${{ matrix.cfg.os }}
        uses: actions/upload-artifact@v4
        if: failure()
        with:
          name: ${{ matrix.cfg.os }}-failed-tests
          path: |
            failed_tests.log
