diff --git a/.github/workflows/action-phpunit.yml b/.github/workflows/action-phpunit.yml index 9aa6a99..b55bde9 100644 --- a/.github/workflows/action-phpunit.yml +++ b/.github/workflows/action-phpunit.yml @@ -9,6 +9,13 @@ on: platform_branch: required: true type: string + coverage: + required: false + type: boolean + default: false + secrets: + CODECOV_TOKEN: + required: false jobs: phpunit: @@ -32,4 +39,18 @@ jobs: } - name: Run PHPUnit - run: composer -d custom/plugins/${{ inputs.extension_name }} run phpunit + run: | + composer -d custom/plugins/${{ inputs.extension_name }} run phpunit -- --log-junit junit.xml ${{ inputs.coverage && '--coverage-clover clover.xml' || '' }} + # PHPUnit writes only once the whole suite has run, so a report without it + # means the process died early (e.g. exit() in code under test) even though it exited 0 + grep -q '' custom/plugins/${{ inputs.extension_name }}/junit.xml + + - name: Upload coverage to Codecov + if: inputs.coverage + 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/php.yml b/.github/workflows/php.yml index b16fba9..b01ba21 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -57,6 +57,9 @@ jobs: with: extension_name: ${{ github.event.repository.name }} platform_branch: ${{ matrix.shopware-version }} + coverage: ${{ matrix.shopware-version == 'trunk' }} + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} smoke_test: name: Smoke test diff --git a/.gitignore b/.gitignore index 63bf71f..3e78253 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ node_modules /src/Resources/app/administration/test/e2e/cypress/results/ /src/Resources/app/administration/test/app/ /src/Resources/public/ +junit.xml +clover.xml