diff --git a/.github/workflows/action-phpunit.yml b/.github/workflows/action-phpunit.yml index d63e050..d7eef84 100644 --- a/.github/workflows/action-phpunit.yml +++ b/.github/workflows/action-phpunit.yml @@ -14,6 +14,13 @@ on: required: false type: string default: "" + coverage: + required: false + type: boolean + default: false + secrets: + CODECOV_TOKEN: + required: false jobs: phpunit: @@ -25,6 +32,8 @@ jobs: matrix: mysql_image: ["mysql:8.0", "mariadb:10.11"] php_version: ["8.2", "8.3"] + env: + COVERAGE: ${{ inputs.coverage && matrix.mysql_image == 'mysql:8.0' && matrix.php_version == '8.3' }} steps: - name: Checkout SwagMigrationMagento uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -43,4 +52,14 @@ jobs: working-directory: custom/plugins/${{ inputs.extension_name }} run: | composer dump-autoload --dev - php -d pcov.enabled=1 -d pcov.directory=${PWD}/src -d pcov.exclude='~(vendor|tests|node_modules)~' ${GITHUB_WORKSPACE}/vendor/bin/phpunit --configuration phpunit.xml.dist + php -d pcov.enabled=${{ env.COVERAGE == 'true' && '1' || '0' }} -d pcov.directory=${PWD}/src -d pcov.exclude='~(vendor|tests|node_modules)~' ${GITHUB_WORKSPACE}/vendor/bin/phpunit --configuration phpunit.xml.dist ${{ env.COVERAGE == 'true' && '--coverage-clover clover.xml' || '' }} + + - name: Upload coverage to Codecov + if: env.COVERAGE == 'true' + uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + root_dir: ${{ github.workspace }}/custom/plugins/${{ inputs.extension_name }} + working-directory: ${{ github.workspace }}/custom/plugins/${{ inputs.extension_name }} + files: ./clover.xml diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 6ced428..ecd908c 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -35,3 +35,6 @@ jobs: with: extension_name: ${{ github.event.repository.name }} platform_branch: trunk + coverage: true + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.gitignore b/.gitignore index 75fbc6d..d088953 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ src/Resources/public/administration/ src/Resources/public/static/ composer.lock php-cs-fixer.migration-magento.cache +clover.xml diff --git a/tests/TestBootstrap.php b/tests/TestBootstrap.php index fbe4d5c..b312d5e 100644 --- a/tests/TestBootstrap.php +++ b/tests/TestBootstrap.php @@ -14,7 +14,8 @@ } elseif (is_readable(__DIR__ . '/../../../../src/Core/TestBootstrapper.php')) { require __DIR__ . '/../../../../src/Core/TestBootstrapper.php'; } else { - exit('Could not find TestBootstrapper.php'); + fwrite(\STDERR, 'Could not find TestBootstrapper.php' . \PHP_EOL); + exit(1); } return (new TestBootstrapper())