name: Dependency tests

on:
  schedule:
    - cron: '1 3 * * *'

jobs:
  stable:
    name: Test @stable deps
    uses: ./.github/workflows/run-tests.yml

  dev:
    name: Test @dev deps
    uses: ./.github/workflows/run-tests.yml
    with:
      deps: dev

  lowest:
    name: Test --prefer-lowest deps
    uses: ./.github/workflows/run-tests.yml
    with:
      deps: lowest
      continue_on_error: true

  build:
    name: Test Phar build
    runs-on: ubuntu-latest

    steps:
      - name: Check out code
        uses: actions/checkout@v2

      - name: Install PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '7.4'
          tools: composer:v2
          coverage: none

      - name: Install dependencies
        uses: nick-invision/retry@v1
        with:
          timeout_minutes: 5
          max_attempts: 5
          command: composer update --no-interaction --no-progress

      - name: Build Phar binaries
        run: make build

      - name: Upload build artifacts
        uses: actions/upload-artifact@v2
        with:
          name: binaries
          path: build/*/psysh

      - name: Smoke test
        run: .github/bin/smoketest.sh

  php70-phar:
    name: PHP 7.0 Phar smoke test
    needs: build
    runs-on: ubuntu-latest

    steps:
      - name: Check out code
        uses: actions/checkout@v2

      - name: Install PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '7.0'
          tools: composer:v2
          coverage: none

      - name: Download build artifacts
        uses: actions/download-artifact@v2
        with:
          name: binaries
          path: build

      - name: Make binaries executable
        run: chmod +x build/*/psysh

      - name: Smoke test
        run: .github/bin/smoketest.sh psysh-php70
