name: Static analysis
on:
  pull_request:
  push:
    branches:
      - master
      - stable*

jobs:
  static-psalm-analysis:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        ocp-version: [ 'v20.0.7' ]
        php-version: [  '7.4' ]

    name: Nextcloud ${{ matrix.ocp-version }}

    steps:
      - name: Checkout
        uses: actions/checkout@master

      - name: Set up php
        uses: shivammathur/setup-php@master
        with:
          php-version: ${{ matrix.php-version }}
          coverage: none

      - name: Install dependencies
        run: composer i

      - name: Install dependencies
        run: composer require --dev christophwurst/nextcloud:${{ matrix.ocp-version }}

      - name: Run coding standards check
        run: composer run psalm

  static-psalm-analysis-21:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        ocp-version: [ 'v21.0.0', 'v22.0.0-RC1' ]
        php-version: [  '7.4', '8.0' ]

    name: Nextcloud ${{ matrix.ocp-version }}

    steps:
      - name: Checkout
        uses: actions/checkout@master

      - name: Set up php
        uses: shivammathur/setup-php@master
        with:
          php-version: ${{ matrix.php-version }}
          coverage: none

      - name: Install dependencies
        run: composer install --ignore-platform-req=php

      - name: Install dependencies
        run: composer require --dev christophwurst/nextcloud:${{ matrix.ocp-version }}

      - name: Run coding standards check
        run: composer run psalm
