name: Test Action

on:
  - push
  - pull_request
  - workflow_dispatch

jobs:
  test_default_inputs:
    name: Test with default inputs

    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        pnpm:
          - 4.11.1
        os:
          - ubuntu-latest
          - macos-latest
          - windows-latest

    steps:
      - uses: actions/checkout@v3

      - name: Run the action
        uses: ./
        with:
          version: 4.11.1

      - name: 'Test: which'
        run: which pnpm; which pnpx

      - name: 'Test: install'
        run: pnpm install

  test_explicit_inputs:
    name: Test with explicit inputs

    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        pnpm:
          - 4.11.1
        os:
          - ubuntu-latest
          - macos-latest
          - windows-latest

    steps:
      - uses: actions/checkout@v3

      - name: Run the action
        uses: ./
        with:
          version: 4.11.1
          dest: ~/test/pnpm

      - name: 'Test: which'
        run: which pnpm && which pnpx

      - name: 'Test: install'
        run: pnpm install

  test_run_install:
    name: 'Test with run_install (${{ matrix.run_install.name }}, ${{ matrix.os }})'

    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        pnpm:
          - 4.11.1
        os:
          - ubuntu-latest
          - macos-latest
          - windows-latest
        run_install:
          - name: 'null'
            value: 'null'
          - name: 'empty object'
            value: '{}'
          - name: 'recursive'
            value: |
              recursive: true
          - name: 'global'
            value: |
              args:
                - --global
                - --global-dir=./pnpm-global
                - npm
                - yarn
                - pnpm
          - name: 'array'
            value: |
              - {}
              - recursive: true
              - args:
                - --global
                - --global-dir=./pnpm-global
                - npm
                - yarn
                - pnpm

    steps:
      - uses: actions/checkout@v3

      - name: Run the action
        uses: ./
        with:
          version: 4.11.1
          run_install: ${{ matrix.run_install.value }}

      - name: 'Test: which'
        run: which pnpm; which pnpx

      - name: 'Test: install'
        run: pnpm install
