!yamlscript/v0:

:use common: :all
::
  workflow-setup:: test_install

env:
  PROJ_PFX_TARGET: ryml-
  PROJ_PFX_CMAKE: RYML_
  CMAKE_FLAGS:
  NUM_JOBS_BUILD: # 4

jobs:
  install_tests:
    if: |
      (!contains(github.event.head_commit.message, 'skip all')) ||
      (!contains(github.event.head_commit.message, 'skip test_install')) ||
      contains(github.event.head_commit.message, 'only test_install')
    name: ${{matrix.name}}/${{matrix.bt}}
    continue-on-error: true
    runs-on: ${{matrix.os}}

    strategy:
      fail-fast: false
      matrix:
        fp fl sh lcxx =:
          -['find_package' 'find_library' 'singleheader' 'linux/libcxx']
        t-t-i t-t-s =: -['test/test_install' 'test/test_singleheader']
        include:: -[
          {:name "$fp/linux", :sdir t-t-i, :os 'ubuntu-24.04', :cxx 'g++-13',
           :gen '-DCMAKE_CXX_COMPILER=g++-13', :tgt 'all', :bt 'Release',
           :vars '-Dryml_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/ryml
                  -DRYML_TEST_INSTALL_PACKAGE_MODE=ON',
           :commonvars nil}
          {:name "$fp/linux", :sdir t-t-i, :os 'ubuntu-24.04', :cxx 'g++-13',
           :gen '-DCMAKE_CXX_COMPILER=g++-13', :tgt 'all', :bt 'Debug',
           :vars '-Dryml_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/ryml
                  -DRYML_TEST_INSTALL_PACKAGE_MODE=ON',
           :commonvars nil}
          {:name "$fp/$lcxx", :sdir t-t-i, :os 'ubuntu-24.04', :cxx 'clang++-14',
           :gen '-DCMAKE_CXX_COMPILER=clang++-14', :tgt 'all', :bt 'Release',
           :vars '-Dryml_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/ryml
                  -DRYML_TEST_INSTALL_PACKAGE_MODE=ON',
           :commonvars '-DRYML_USE_LIBCXX=ON'}
          {:name "$fp/$lcxx", :sdir t-t-i, :os 'ubuntu-24.04', :cxx 'clang++-14',
           :gen '-DCMAKE_CXX_COMPILER=clang++-14', :tgt 'all', :bt 'Debug',
           :vars '-Dryml_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/ryml
                  -DRYML_TEST_INSTALL_PACKAGE_MODE=ON',
           :commonvars '-DRYML_USE_LIBCXX=ON'}
          {:name "$fp/macos", :sdir t-t-i, :os 'macos-13', :cxx 'xcode',
           :gen '-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64',
           :tgt 'ALL_BUILD', :bt 'Release',
           :vars '-Dryml_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/ryml
                  -DRYML_TEST_INSTALL_PACKAGE_MODE=ON',
           :commonvars nil}
          {:name "$fp/macos", :sdir t-t-i, :os 'macos-13', :cxx 'xcode',
           :gen '-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64',
           :tgt 'ALL_BUILD', :bt 'Debug',
           :vars '-Dryml_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/ryml
                  -DRYML_TEST_INSTALL_PACKAGE_MODE=ON',
           :commonvars nil}
          {:name "$fp/win",   :sdir t-t-i, :os 'windows-2019', :cxx 'vs2019',
           :gen "-G 'Visual Studio 16 2019' -A x64",
           :tgt 'ALL_BUILD', :bt 'Release',
           :vars '-Dryml_DIR=$GITHUB_WORKSPACE/$PDIR/cmake
                  -DRYML_TEST_INSTALL_PACKAGE_MODE=ON',
           :commonvars nil}
          {:name "$fp/win",   :sdir t-t-i, :os 'windows-2019', :cxx 'vs2019',
           :gen "-G 'Visual Studio 16 2019' -A x64",
           :tgt 'ALL_BUILD', :bt 'Debug',
           :vars '-Dryml_DIR=$GITHUB_WORKSPACE/$PDIR/cmake
                  -DRYML_TEST_INSTALL_PACKAGE_MODE=ON',
           :commonvars nil}

          {:name "$fl/linux", :sdir t-t-i, :os 'ubuntu-24.04', :cxx 'g++-13',
           :gen '-DCMAKE_CXX_COMPILER=g++-13', :tgt 'all', :bt 'Release',
           :vars '-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR
                  -DRYML_TEST_INSTALL_PACKAGE_MODE=OFF',
           :commonvars nil}
          {:name "$fl/linux", :sdir t-t-i, :os 'ubuntu-24.04', :cxx 'g++-13',
           :gen '-DCMAKE_CXX_COMPILER=g++-13', :tgt 'all', :bt 'Debug',
           :vars '-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR
                  -DRYML_TEST_INSTALL_PACKAGE_MODE=OFF',
           :commonvars nil}
          {:name "$fl/$lcxx", :sdir t-t-i, :os 'ubuntu-24.04', :cxx 'clang++-14',
           :gen '-DCMAKE_CXX_COMPILER=clang++-14', :tgt 'all', :bt 'Release',
           :vars '-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR
                  -DRYML_TEST_INSTALL_PACKAGE_MODE=OFF',
           :commonvars '-DRYML_USE_LIBCXX=ON'}
          {:name "$fl/$lcxx", :sdir t-t-i, :os 'ubuntu-24.04', :cxx 'clang++-14',
           :gen '-DCMAKE_CXX_COMPILER=clang++-14', :tgt 'all', :bt 'Debug',
           :vars '-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR
                  -DRYML_TEST_INSTALL_PACKAGE_MODE=OFF',
           :commonvars '-DRYML_USE_LIBCXX=ON'}
          {:name "$fl/macos", :sdir t-t-i, :os 'macos-13', :cxx 'xcode',
           :gen '-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64',
           :tgt 'ALL_BUILD', :bt 'Release',
           :vars '-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR
                  -DRYML_TEST_INSTALL_PACKAGE_MODE=OFF',
           :commonvars nil}
          {:name "$fl/macos", :sdir t-t-i, :os 'macos-13', :cxx 'xcode',
           :gen '-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64',
           :tgt 'ALL_BUILD', :bt 'Debug',
           :vars '-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR
                  -DRYML_TEST_INSTALL_PACKAGE_MODE=OFF',
           :commonvars nil}
          {:name "$fl/win",   :sdir t-t-i, :os 'windows-2019', :cxx 'vs2019',
           :gen "-G 'Visual Studio 16 2019' -A x64",
           :tgt 'ALL_BUILD', :bt 'Release',
           :vars '-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR
                  -DRYML_TEST_INSTALL_PACKAGE_MODE=OFF',
           :commonvars nil}
          {:name "$fl/win",   :sdir t-t-i, :os 'windows-2019', :cxx 'vs2019',
           :gen "-G 'Visual Studio 16 2019' -A x64",
           :tgt 'ALL_BUILD', :bt 'Debug',
           :vars '-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR
                  -DRYML_TEST_INSTALL_PACKAGE_MODE=OFF',
           :commonvars nil}

          {:name "$sh/linux", :sdir t-t-s, :os 'ubuntu-24.04', :cxx 'g++-13',
           :gen '-DCMAKE_CXX_COMPILER=g++-13',
           :tgt 'all', :bt 'Release', :vars nil, :commonvars nil}
          {:name "$sh/linux", :sdir t-t-s, :os 'ubuntu-24.04', :cxx 'g++-13',
           :gen '-DCMAKE_CXX_COMPILER=g++-13',
           :tgt 'all', :bt 'Debug', :vars nil, :commonvars nil}
          {:name "$sh/$lcxx", :sdir t-t-s, :os 'ubuntu-24.04', :cxx 'clang++-14',
           :gen '-DCMAKE_CXX_COMPILER=clang++-14', :tgt 'all', :bt 'Release',
           :vars nil, :commonvars '-DRYML_USE_LIBCXX=ON'}
          {:name "$sh/$lcxx", :sdir t-t-s, :os 'ubuntu-24.04', :cxx 'clang++-14',
           :gen '-DCMAKE_CXX_COMPILER=clang++-14', :tgt 'all', :bt 'Debug',
           :vars nil, :commonvars '-DRYML_USE_LIBCXX=ON'}
          {:name "$sh/macos", :sdir t-t-s, :os 'macos-13', :cxx 'xcode',
           :gen '-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64',
           :tgt 'ALL_BUILD', :bt 'Release', :vars nil, :commonvars nil}
          {:name "$sh/macos", :sdir t-t-s, :os 'macos-13', :cxx 'xcode',
           :gen '-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64',
           :tgt 'ALL_BUILD', :bt 'Debug', :vars nil, :commonvars nil}
          {:name "$sh/win",   :sdir t-t-s, :os 'windows-2019', :cxx 'vs2019',
           :gen "-G 'Visual Studio 16 2019' -A x64",
           :tgt 'ALL_BUILD', :bt 'Release', :vars nil, :commonvars nil}
          {:name "$sh/win",   :sdir t-t-s, :os 'windows-2019', :cxx 'vs2019',
           :gen "-G 'Visual Studio 16 2019' -A x64",
           :tgt 'ALL_BUILD', :bt 'Debug', :vars nil, :commonvars nil}]

    env:
      CXX_: ${{matrix.cxx}}
      BT:   ${{matrix.bt}}
      OS:   ${{matrix.os}}
      BDIR: build/${{matrix.name}}-${{matrix.bt}}
      IDIR: install/${{matrix.name}}-${{matrix.bt}}
      PDIR: prefix/${{matrix.name}}-${{matrix.bt}}

    steps:
    - name: checkout
      uses: actions/checkout@v4
      with: {submodules: recursive}
    - name: install requirements
      run: source .github/reqs.sh && c4_install_test_requirements $OS
    - name: show info
      run: source .github/setenv.sh && c4_show_info
    - name: Install python 3.9
      uses: actions/setup-python@v5
      with: { python-version: 3.9 }
    - name: preinstall
      run:: bash('install-preinstall')
    - name: configure
      run:: bash('install-configure')
    - name: build
      run: >
        cmake --build $BDIR
        --config ${{matrix.bt}}
        --target ryml-test-build -j
    - name: run
      run: >
        cmake --build $BDIR
        --config ${{matrix.bt}}
        --target ryml-test-run
