diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 00000000..95015b98 --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,161 @@ +name: "Continuous Integration" + +on: + pull_request: + +jobs: + static-analysis-phpstan: + name: "Static Analysis with PHPStan" + runs-on: "ubuntu-latest" + + strategy: + matrix: + php-version: + - "7.4" + + steps: + - name: "Checkout code" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + php-version: "${{ matrix.php-version }}" + tools: "cs2pr" + + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v1" + with: + path: "~/.composer/cache" + key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}" + restore-keys: "php-${{ matrix.php-version }}-composer-locked-" + + - name: "Install dependencies with composer" + run: "composer install --no-interaction --no-progress --no-suggest" + + - name: "Run a static analysis with phpstan/phpstan" + run: "composer phpstan -- --error-format=checkstyle | cs2pr" + + coding-standards: + name: "Coding Standards" + runs-on: "ubuntu-latest" + + strategy: + matrix: + php-version: + - "7.4" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + php-version: "${{ matrix.php-version }}" + tools: "cs2pr" + + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v1" + with: + path: "~/.composer/cache" + key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}" + restore-keys: "php-${{ matrix.php-version }}-composer-locked-" + + - name: "Install dependencies with composer" + run: "composer install --no-interaction --no-progress --no-suggest" + + - name: "Run PHP-CS-Fixer on src/" + run: "vendor/bin/php-cs-fixer fix src/ --dry-run --stop-on-violation --report=checkstyle | cs2pr" + + - name: "Run PHP-CS-Fixer on tests/" + run: "vendor/bin/php-cs-fixer fix tests/ --dry-run --stop-on-violation --report=checkstyle | cs2pr" + + phpunit-mysql57: + name: "PHPUnit on MySQL 5.7" + runs-on: "ubuntu-latest" + + strategy: + matrix: + php-version: + - "7.4" + + services: + mysql: + image: "mysql: 5.7" + env: + MYSQL_ALLOW_EMPTY_PASSWORD: true + MYSQL_ROOT_PASSWORD: + ports: + - "3306:3306" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + extensions: "oci8" + coverage: "pcov" + + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v1" + with: + path: "~/.composer/cache" + key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}" + restore-keys: "php-${{ matrix.php-version }}-composer-locked-" + + - name: "Install dependencies with composer" + run: "composer install --no-interaction --no-progress --no-suggest" + + - name: "Run PHPUnit" + run: "vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=coverage.xml" + + - name: "Upload Code Coverage" + uses: "codecov/codecov-action@v1" + + phpunit-oci8: + name: "PHPUnit on OCI8" + runs-on: "ubuntu-latest" + + strategy: + matrix: + php-version: + - "7.4" + + services: + oracle: + image: "wnameless/oracle-xe-11g-r2" + ports: + - "1521:1521" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + extensions: "oci8" + coverage: "pcov" + + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v1" + with: + path: "~/.composer/cache" + key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}" + restore-keys: "php-${{ matrix.php-version }}-composer-locked-" + + - name: "Install dependencies with composer" + run: "composer install --no-interaction --no-progress --no-suggest" + + - name: "Run PHPUnit" + run: "vendor/bin/phpunit -c phpunit.oracle.xml --coverage-clover=coverage.xml" + + - name: "Upload Code Coverage" + uses: "codecov/codecov-action@v1"