From 5987dc8581864b28e86cc7ebde7136f987b807c7 Mon Sep 17 00:00:00 2001 From: Lars Lauger Date: Wed, 30 Oct 2024 17:15:27 +0100 Subject: [PATCH] feat: Add workflow for unit tests --- .github/workflows/unittests.yml | 60 +++++++++++++++++++++++++++++++++ phpunit.xml.dist | 30 +++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 .github/workflows/unittests.yml create mode 100644 phpunit.xml.dist diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml new file mode 100644 index 0000000..3b275d3 --- /dev/null +++ b/.github/workflows/unittests.yml @@ -0,0 +1,60 @@ +name: unittests + +on: [ push, pull_request ] + +jobs: + unittests: + name: '[PHP ${{ matrix.php-version }} | Flow ${{ matrix.flow-version }}] Unit Tests' + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php-version: [ 8.1, 8.2, 8.3 ] + dbal-version: [ 2.13, 3.8 ] + + env: + APP_ENV: true + TEST_DIR: test-dir + + steps: + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, xml, json, zlib, iconv, intl, pdo_sqlite + ini-values: opcache.fast_shutdown=0 + + - name: Checkout code + uses: actions/checkout@v4 + with: + path: ${{ env.TEST_DIR }}/dist/upsert + + - name: "Create composer.json" + run: | + echo '{ + "name": "netlogix/upsert-test", + "description": "", + "license": "GPL-3.0-or-later", + "require": { + "netlogix/doctrine-upsert": "@dev", + "doctrine/dbal": "^${{ matrix.dbal-version }}" + }, + "require-dev": { + "phpunit/phpunit": "^10.5" + }, + "repositories": [ + { + "type": "path", + "url": "dist/upsert" + } + ] + }' > composer.json + working-directory: ${{ env.TEST_DIR }} + + - name: "Install project" + run: composer install + working-directory: ${{ env.TEST_DIR }} + + - name: Run tests + run: vendor/bin/phpunit -c dist/upsert/phpunit.xml.dist --testsuite="Unit" + working-directory: ${{ env.TEST_DIR }} diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..b698162 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,30 @@ + + + + + ./test/ + + + + + ./Classes + + + + + + + + + + + + + +