From 5f39ad7e8e73d479e3bd1f40bf219737e8a98bd4 Mon Sep 17 00:00:00 2001 From: Marvin Buchmann <8483328+buchmarv@users.noreply.github.com> Date: Mon, 7 Oct 2024 11:02:09 +0200 Subject: [PATCH] [TASK] Add tests to CI (#18) * [TASK] Add tests to CI * Add coveralls * Add codeCoverageIgnore annotations --- .github/workflows/ci.yml | 16 +++++++++++++++- build/.coveralls.yml | 1 + src/Exception/NoTokenException.php | 3 +++ src/Security/KeyCloakUser.php | 3 +++ src/T3GKeycloakBundle.php | 3 +++ src/Validator/Name.php | 3 +++ 6 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 build/.coveralls.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33d2a86..538117c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: with: php-version: ${{ matrix.php }} extensions: mbstring, xml, ctype, iconv - coverage: none + coverage: pcov - name: Cache composer dependencies uses: actions/cache@v3 @@ -58,3 +58,17 @@ jobs: run: | git status git status | grep -q "nothing to commit, working tree clean" + + - name: Tests + run: | + php -dpcov.enabled=1 -dpcov.directory="." -dxdebug.mode="coverage" ./vendor/bin/phpunit -c build/phpunit.xml.dist --log-junit var/log/junit/phpunit.junit.xml --coverage-clover var/log/junit/coverage.xml --coverage-xml var/log/junit/coverage-xml/ + env: + COMPOSER_PROCESS_TIMEOUT: 1200 + + - name: Upload coverage results to Coveralls + continue-on-error: true + env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + composer global require php-coveralls/php-coveralls --no-progress --no-suggest --no-interaction + /home/runner/.composer/vendor/bin/php-coveralls -c build/.coveralls.yml -vvv --json_path=var/log/coveralls-upload.json diff --git a/build/.coveralls.yml b/build/.coveralls.yml new file mode 100644 index 0000000..63013fe --- /dev/null +++ b/build/.coveralls.yml @@ -0,0 +1 @@ +coverage_clover: var/log/junit/coverage.xml diff --git a/src/Exception/NoTokenException.php b/src/Exception/NoTokenException.php index d6d413d..d8b7f63 100644 --- a/src/Exception/NoTokenException.php +++ b/src/Exception/NoTokenException.php @@ -10,6 +10,9 @@ namespace T3G\Bundle\Keycloak\Exception; +/** + * @codeCoverageIgnore + */ class NoTokenException extends \Exception { } diff --git a/src/Security/KeyCloakUser.php b/src/Security/KeyCloakUser.php index e3c06b7..5053d9e 100644 --- a/src/Security/KeyCloakUser.php +++ b/src/Security/KeyCloakUser.php @@ -12,6 +12,9 @@ use Symfony\Component\Security\Core\User\UserInterface; +/** + * @codeCoverageIgnore + */ class KeyCloakUser implements UserInterface { private string $identifier; diff --git a/src/T3GKeycloakBundle.php b/src/T3GKeycloakBundle.php index dbeaa56..3476d2b 100644 --- a/src/T3GKeycloakBundle.php +++ b/src/T3GKeycloakBundle.php @@ -14,6 +14,9 @@ use Symfony\Component\HttpKernel\Bundle\Bundle; use T3G\Bundle\Keycloak\DependencyInjection\T3GKeycloakExtension; +/** + * @codeCoverageIgnore + */ final class T3GKeycloakBundle extends Bundle { /** diff --git a/src/Validator/Name.php b/src/Validator/Name.php index b8d34c2..c354deb 100644 --- a/src/Validator/Name.php +++ b/src/Validator/Name.php @@ -13,6 +13,9 @@ use Symfony\Component\Validator\Constraint; +/** + * @codeCoverageIgnore + */ #[\Attribute] class Name extends Constraint {