name: CutBox cli run testing

on:
  push:
    branches: [ "master" ]

jobs:
  test:
    strategy:
      matrix:
        macos_version:
          - macos-11
          - macos-12
          - macos-13
      fail-fast: false
    runs-on: ${{ matrix.macos_version }}

    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          submodules: true
          fetch-depth: 0
          ref: master

      - name: Test cubox_command
        run: |
          defaults write info.ocodo.cutbox historyStore -array-add "<dict><key>string</key><string>Test Passed?</string><key>favorite</key><string>favorite</string></dict>"
          defaults write info.ocodo.cutbox historyStore -array-add "<dict><key>string</key><string>Copied Text</string><key>timestamp</key><string>${date_hour_ago}</string></dict>"
          defaults write info.ocodo.cutbox historyStore -array-add "<dict><key>string</key><string>Copied text</string><key>timestamp</key><string>${date_day_ago}</string></dict>"

          if test_bin/cutbox -h; then
            echo "# CutBox precompiled CLI success on ${{ matrix.macos_version }} [✓]" >> "$GITHUB_STEP_SUMMARY"
            test_bin/cutbox -h >> "$GITHUB_STEP_SUMMARY"
          else
            echo "# CutBox precompiled CLI failed on ${{ matrix.macos_version }} [☠]" >> "$GITHUB_STEP_SUMMARY"
            exit 1
          fi
