From 85163b63a9ca45a79b4dd4d2d7c45b167be476de Mon Sep 17 00:00:00 2001 From: BarTracz <115506125+BarTracz@users.noreply.github.com> Date: Mon, 10 Jun 2024 10:45:01 +0200 Subject: [PATCH] #6 - Introduce GitHub Action (#13) --- .github/workflows/check-pr-title.yml | 19 ++++++++++ .github/workflows/php.yml | 52 ++++++++++++++++++++++++++++ .gitignore | 2 ++ phpunit.xml | 10 ++++++ 4 files changed, 83 insertions(+) create mode 100644 .github/workflows/check-pr-title.yml create mode 100644 .github/workflows/php.yml create mode 100644 phpunit.xml diff --git a/.github/workflows/check-pr-title.yml b/.github/workflows/check-pr-title.yml new file mode 100644 index 0000000..704c602 --- /dev/null +++ b/.github/workflows/check-pr-title.yml @@ -0,0 +1,19 @@ +name: Check PR Title +on: + pull_request: + types: + - opened + - edited + - synchronize + - ready_for_review + - reopened + +jobs: + check-pr-title: + name: Check PR title + timeout-minutes: 10 + if: github.event.pull_request.draft == false + runs-on: ubuntu-22.04 + + steps: + - uses: blumilksoftware/action-pr-title@e05fc76a1cc45b33644f1de51218be43ac121dd0 # v1.2.0 \ No newline at end of file diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..72b1f0b --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,52 @@ +name: Test & lint PHP stuff + +on: + pull_request: + branches: + - main + types: + - opened + - synchronize + - reopened + - ready_for_review + paths: + - '**.php' + - 'composer.json' + - 'composer.lock' + - 'phpunit.xml' + +jobs: + test-and-lint-php: + name: Test & lint PHP stuff + timeout-minutes: 10 + if: github.event.pull_request.draft == false + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Cache dependencies + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: vendor + key: ${{ runner.os }}-composer-dependencies-${{ hashFiles('composer.lock') }} + restore-keys: ${{ runner.os }}-composer-dependencies + + - name: Setup PHP + uses: shivammathur/setup-php@c665c7a15b5295c2488ac8a87af9cb806cd72198 # 2.30.4 + with: + php-version: 8.2 + extensions: dom, curl, libxml, mbstring, zip, pcntl, intl, gd + coverage: none + + - name: Install Composer dependencies + run: composer install --prefer-dist --no-interaction --no-suggest + + - name: Run PHP linter + run: composer cs + + - name: Execute tests + run: php vendor/bin/phpunit --configuration phpunit.xml \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1f25853..4ef49f2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ .composer vendor composer.lock +index.php +.phpunit.result.cache diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..19d15b5 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,10 @@ + + + + + tests + + + \ No newline at end of file