#!/usr/bin/env bash

set -e

: "${SKIP_LINT:=0}"

if [ "$SKIP_LINT" -ne 1 ]; then
    echo 'Running PHP syntax check...'
    php -l /var/gras/bin/gras_lite_delivery.php

    echo 'Running PHP CodeSniffer...'
    ./vendor/bin/phpcs --standard=phpcs.xml --warning-severity=0 bin/ src/

    echo 'Running PHPStan...'
    ./vendor/bin/phpstan analyse --no-progress --no-interaction --memory-limit 512M --configuration=phpstan.neon.dist

    echo 'Running YAML linter...'
    yamllint docker-compose.yml software-catalog.yaml
else
    echo 'Skipping linting...'
fi

echo 'Running PHPUnit tests...'
./vendor/bin/phpunit --configuration=phpunit.xml

echo 'Done!'
