name: Reusable Solaris amd64

on:
  workflow_call:

permissions:
  contents: read

env:
  CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }}

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: checkout repository
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

      - name: run VM
        uses: vmactions/solaris-vm@315163f088b66e55bbcc45928bd224d4973b2312 # v1.3.8
        with:
          usesh: true
          envs: 'CMAKE_BUILD_TYPE'
          release: "11.4-gcc-14"
          prepare: |
            uname -a
            pkg install cmake git pkg-config glib2 dbus sqlite-3 imagemagick ninja dconf mesa lua

          run: |
            export PKG_CONFIG_PATH=/usr/lib/64/pkgconfig
            cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -GNinja .
            cmake --build . --verbose -j4
            ./fastfetch --list-features
            time ./fastfetch -c presets/ci.jsonc --stat false
            time ./fastfetch -c presets/ci.jsonc --format json
            time ./flashfetch
            ldd fastfetch
            ctest --output-on-failure
            echo 'set(CPACK_PACKAGE_FILE_NAME "fastfetch-solaris-amd64")' >> CPackConfig.cmake
            cpack -V

      - name: upload artifacts
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: fastfetch-solaris-amd64
          path: ./fastfetch-*.*
