From a73e9a4c2e3f032707f450861c7811190061609d Mon Sep 17 00:00:00 2001 From: Philipp Bammes Date: Tue, 26 May 2026 09:28:09 +0200 Subject: [PATCH 1/7] feat: add Codecov support to tests-unit-php workflow --- .github/workflows/tests-unit-php.yml | 17 +++++++++++++++++ docs/php.md | 18 +++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests-unit-php.yml b/.github/workflows/tests-unit-php.yml index c91911ab4..b03d94d1d 100644 --- a/.github/workflows/tests-unit-php.yml +++ b/.github/workflows/tests-unit-php.yml @@ -23,6 +23,11 @@ on: default: '--coverage-text' required: false type: string + CODECOV_COVERAGE_FILE: + description: Path to the coverage file to upload to Codecov. Upload is skipped when the file does not exist. + default: 'coverage.xml' + required: false + type: string secrets: COMPOSER_AUTH_JSON: description: Authentication for privately hosted packages and repositories as a JSON formatted object. @@ -30,6 +35,9 @@ on: ENV_VARS: description: Additional environment variables as a JSON formatted object. required: false + CODECOV_TOKEN: + description: Codecov token. + required: false jobs: tests-unit-php: @@ -68,3 +76,12 @@ jobs: - name: Run PHPUnit run: ./$(composer config bin-dir)/phpunit ${{ inputs.PHPUNIT_ARGS }} + + - name: Upload coverage to Codecov + if: ${{ hashFiles(inputs.CODECOV_COVERAGE_FILE) != '' }} + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ${{ inputs.CODECOV_COVERAGE_FILE }} + flags: unittests + verbose: true diff --git a/docs/php.md b/docs/php.md index 68991f832..aec1f9018 100644 --- a/docs/php.md +++ b/docs/php.md @@ -147,12 +147,13 @@ jobs: #### Inputs -| Name | Default | Description | -|------------------|---------------------|--------------------------------------------------------------------------------| -| `PHP_VERSION` | `'8.2'` | PHP version with which the scripts are executed | -| `PHP_EXTENSIONS` | `''` | PHP extensions supported by shivammathur/setup-php to be installed or disabled | -| `COMPOSER_ARGS` | `'--prefer-dist'` | Set of arguments passed to Composer | -| `PHPUNIT_ARGS` | `'--coverage-text'` | Set of arguments passed to PHPUnit | +| Name | Default | Description | +|-------------------------|---------------------|--------------------------------------------------------------------------------| +| `PHP_VERSION` | `'8.2'` | PHP version with which the scripts are executed | +| `PHP_EXTENSIONS` | `''` | PHP extensions supported by shivammathur/setup-php to be installed or disabled | +| `COMPOSER_ARGS` | `'--prefer-dist'` | Set of arguments passed to Composer | +| `PHPUNIT_ARGS` | `'--coverage-text'` | Set of arguments passed to PHPUnit | +| `CODECOV_COVERAGE_FILE` | `'coverage.xml'` | Path to the coverage file to upload to Codecov | #### Secrets @@ -160,6 +161,7 @@ jobs: |----------------------|------------------------------------------------------------------------------------------| | `COMPOSER_AUTH_JSON` | Authentication for privately hosted packages and repositories as a JSON formatted object | | `ENV_VARS` | Additional environment variables as a JSON formatted object | +| `CODECOV_TOKEN` | Codecov token | **Example with configuration parameters:** @@ -174,9 +176,11 @@ jobs: matrix: php: [ "8.1", "8.2", "8.3" ] uses: inpsyde/reusable-workflows/.github/workflows/tests-unit-php.yml@main + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: PHP_VERSION: ${{ matrix.php }} - PHPUNIT_ARGS: '--coverage-text --debug' + PHPUNIT_ARGS: '--coverage-text --coverage-clover coverage.xml' ``` ## Lint PHP From 37abdc3cf5fb5fda54e69302ee660e03a946e907 Mon Sep 17 00:00:00 2001 From: Philipp Bammes Date: Tue, 26 May 2026 09:49:29 +0200 Subject: [PATCH 2/7] chore: bump codecov-action from v4 to v6 --- .github/workflows/tests-unit-php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests-unit-php.yml b/.github/workflows/tests-unit-php.yml index b03d94d1d..79707da5b 100644 --- a/.github/workflows/tests-unit-php.yml +++ b/.github/workflows/tests-unit-php.yml @@ -79,7 +79,7 @@ jobs: - name: Upload coverage to Codecov if: ${{ hashFiles(inputs.CODECOV_COVERAGE_FILE) != '' }} - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v6 with: token: ${{ secrets.CODECOV_TOKEN }} files: ${{ inputs.CODECOV_COVERAGE_FILE }} From 205e825500d36b4d949921752b97f0684f5ca1c6 Mon Sep 17 00:00:00 2001 From: Philipp Bammes Date: Tue, 26 May 2026 09:57:23 +0200 Subject: [PATCH 3/7] chore: remove unnecessary statement --- .github/workflows/tests-unit-php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests-unit-php.yml b/.github/workflows/tests-unit-php.yml index 79707da5b..f03df1b05 100644 --- a/.github/workflows/tests-unit-php.yml +++ b/.github/workflows/tests-unit-php.yml @@ -24,7 +24,7 @@ on: required: false type: string CODECOV_COVERAGE_FILE: - description: Path to the coverage file to upload to Codecov. Upload is skipped when the file does not exist. + description: Path to the coverage file to upload to Codecov. default: 'coverage.xml' required: false type: string From 65344f3ddfd26d5dfb165284214181aa7762a858 Mon Sep 17 00:00:00 2001 From: Philipp Bammes Date: Tue, 26 May 2026 10:52:35 +0200 Subject: [PATCH 4/7] refactor: drop CODECOV_COVERAGE_FILE input, add clover flag via token --- .github/workflows/tests-unit-php.yml | 16 ++++++++-------- docs/php.md | 3 +-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests-unit-php.yml b/.github/workflows/tests-unit-php.yml index f03df1b05..c4857a2bd 100644 --- a/.github/workflows/tests-unit-php.yml +++ b/.github/workflows/tests-unit-php.yml @@ -23,11 +23,6 @@ on: default: '--coverage-text' required: false type: string - CODECOV_COVERAGE_FILE: - description: Path to the coverage file to upload to Codecov. - default: 'coverage.xml' - required: false - type: string secrets: COMPOSER_AUTH_JSON: description: Authentication for privately hosted packages and repositories as a JSON formatted object. @@ -75,13 +70,18 @@ jobs: composer-options: ${{ inputs.COMPOSER_ARGS }} - name: Run PHPUnit - run: ./$(composer config bin-dir)/phpunit ${{ inputs.PHPUNIT_ARGS }} + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + run: | + COVERAGE_ARGS="" + [ -n "$CODECOV_TOKEN" ] && COVERAGE_ARGS="--coverage-clover coverage.xml" + ./$(composer config bin-dir)/phpunit $COVERAGE_ARGS ${{ inputs.PHPUNIT_ARGS }} - name: Upload coverage to Codecov - if: ${{ hashFiles(inputs.CODECOV_COVERAGE_FILE) != '' }} + if: ${{ hashFiles('coverage.xml') != '' }} uses: codecov/codecov-action@v6 with: token: ${{ secrets.CODECOV_TOKEN }} - files: ${{ inputs.CODECOV_COVERAGE_FILE }} + files: ./coverage.xml flags: unittests verbose: true diff --git a/docs/php.md b/docs/php.md index aec1f9018..be80dc9e2 100644 --- a/docs/php.md +++ b/docs/php.md @@ -153,7 +153,6 @@ jobs: | `PHP_EXTENSIONS` | `''` | PHP extensions supported by shivammathur/setup-php to be installed or disabled | | `COMPOSER_ARGS` | `'--prefer-dist'` | Set of arguments passed to Composer | | `PHPUNIT_ARGS` | `'--coverage-text'` | Set of arguments passed to PHPUnit | -| `CODECOV_COVERAGE_FILE` | `'coverage.xml'` | Path to the coverage file to upload to Codecov | #### Secrets @@ -180,7 +179,7 @@ jobs: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: PHP_VERSION: ${{ matrix.php }} - PHPUNIT_ARGS: '--coverage-text --coverage-clover coverage.xml' + PHPUNIT_ARGS: '--coverage-text' ``` ## Lint PHP From 45e26eb7f2be668ac8ceccd40a5f733410ebb969 Mon Sep 17 00:00:00 2001 From: Philipp Bammes Date: Tue, 26 May 2026 10:57:48 +0200 Subject: [PATCH 5/7] chore: reformat Markdown table --- docs/php.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/php.md b/docs/php.md index be80dc9e2..941955b12 100644 --- a/docs/php.md +++ b/docs/php.md @@ -147,12 +147,12 @@ jobs: #### Inputs -| Name | Default | Description | -|-------------------------|---------------------|--------------------------------------------------------------------------------| -| `PHP_VERSION` | `'8.2'` | PHP version with which the scripts are executed | -| `PHP_EXTENSIONS` | `''` | PHP extensions supported by shivammathur/setup-php to be installed or disabled | -| `COMPOSER_ARGS` | `'--prefer-dist'` | Set of arguments passed to Composer | -| `PHPUNIT_ARGS` | `'--coverage-text'` | Set of arguments passed to PHPUnit | +| Name | Default | Description | +|------------------|---------------------|--------------------------------------------------------------------------------| +| `PHP_VERSION` | `'8.2'` | PHP version with which the scripts are executed | +| `PHP_EXTENSIONS` | `''` | PHP extensions supported by shivammathur/setup-php to be installed or disabled | +| `COMPOSER_ARGS` | `'--prefer-dist'` | Set of arguments passed to Composer | +| `PHPUNIT_ARGS` | `'--coverage-text'` | Set of arguments passed to PHPUnit | #### Secrets From 4f2b57ad75b36cc4ac3b9193e92020fae8bb9ca0 Mon Sep 17 00:00:00 2001 From: Philipp Bammes Date: Tue, 26 May 2026 11:52:15 +0200 Subject: [PATCH 6/7] feat: add Codecov support to tests-unit-js workflow --- .github/workflows/tests-unit-js.yml | 19 ++++++++++++++++++- docs/js.md | 4 +++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests-unit-js.yml b/.github/workflows/tests-unit-js.yml index e6725c18d..0a3809639 100644 --- a/.github/workflows/tests-unit-js.yml +++ b/.github/workflows/tests-unit-js.yml @@ -44,6 +44,9 @@ on: ENV_VARS: description: Additional environment variables as a JSON formatted object. required: false + CODECOV_TOKEN: + description: Codecov token. + required: false jobs: tests-unit-js: @@ -118,4 +121,18 @@ jobs: run: ${{ format('{0} {1}', inputs.PACKAGE_MANAGER, env.ARGS) }} - name: Run Jest - run: ./node_modules/.bin/jest ${{ inputs.JEST_ARGS }} + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + run: | + COVERAGE_ARGS="" + [ -n "$CODECOV_TOKEN" ] && COVERAGE_ARGS="--coverage" + ./node_modules/.bin/jest $COVERAGE_ARGS ${{ inputs.JEST_ARGS }} + + - name: Upload coverage to Codecov + if: ${{ hashFiles('coverage/lcov.info') != '' }} + uses: codecov/codecov-action@v6 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage/lcov.info + flags: unittests + verbose: true diff --git a/docs/js.md b/docs/js.md index ac95421d5..1cc33d700 100644 --- a/docs/js.md +++ b/docs/js.md @@ -39,6 +39,7 @@ jobs: | `GITHUB_USER_NAME` | Username for the GitHub user configuration | | `GITHUB_USER_SSH_KEY` | Private SSH key associated with the GitHub user passed as `GITHUB_USER_NAME` | | `ENV_VARS` | Additional environment variables as a JSON formatted object | +| `CODECOV_TOKEN` | Codecov token | **Example with configuration parameters:** @@ -53,9 +54,10 @@ jobs: NPM_REGISTRY_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} ENV_VARS: >- [{"name":"EXAMPLE_USERNAME", "value":"${{ secrets.USERNAME }}"}] + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: NODE_VERSION: 14 - JEST_ARGS: 'my-test --reporters=jest-junit --coverage' + JEST_ARGS: 'my-test --reporters=jest-junit' ``` ## Static analysis JavaScript From 67d7bad1ae848f95b6f493a9b498ccde704afd1d Mon Sep 17 00:00:00 2001 From: Philipp Bammes Date: Wed, 3 Jun 2026 10:19:12 +0200 Subject: [PATCH 7/7] feat: use workflow input for Codecov flags --- .github/workflows/tests-unit-js.yml | 9 +++++++-- .github/workflows/tests-unit-php.yml | 7 ++++++- docs/js.md | 2 ++ docs/php.md | 2 ++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests-unit-js.yml b/.github/workflows/tests-unit-js.yml index 0a3809639..448e0d1e6 100644 --- a/.github/workflows/tests-unit-js.yml +++ b/.github/workflows/tests-unit-js.yml @@ -25,9 +25,14 @@ on: type: string NODE_OPTIONS: description: Space-separated list of command-line Node options. - type: string default: '' required: false + type: string + CODECOV_FLAGS: + description: Flags to be passed to Codecov. + default: 'unittests' + required: false + type: string secrets: NPM_REGISTRY_TOKEN: description: Authentication for the private npm registry. @@ -134,5 +139,5 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} files: ./coverage/lcov.info - flags: unittests + flags: ${{ inputs.CODECOV_FLAGS }} verbose: true diff --git a/.github/workflows/tests-unit-php.yml b/.github/workflows/tests-unit-php.yml index c4857a2bd..1efae1c61 100644 --- a/.github/workflows/tests-unit-php.yml +++ b/.github/workflows/tests-unit-php.yml @@ -23,6 +23,11 @@ on: default: '--coverage-text' required: false type: string + CODECOV_FLAGS: + description: Flags to be passed to Codecov. + default: 'unittests' + required: false + type: string secrets: COMPOSER_AUTH_JSON: description: Authentication for privately hosted packages and repositories as a JSON formatted object. @@ -83,5 +88,5 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} files: ./coverage.xml - flags: unittests + flags: ${{ inputs.CODECOV_FLAGS }} verbose: true diff --git a/docs/js.md b/docs/js.md index 1cc33d700..649470150 100644 --- a/docs/js.md +++ b/docs/js.md @@ -27,6 +27,7 @@ jobs: | `NPM_REGISTRY_DOMAIN` | `'https://npm.pkg.github.com/'` | Domain of the private npm registry | | `NODE_VERSION` | `18` | Node version with which the unit tests are to be executed | | `JEST_ARGS` | `'--reporters=default --reporters=github-actions'` | Set of arguments passed to Jest | +| `CODECOV_FLAGS` | `'unittests'` | Flags to be passed to Codecov | **Note**: The default `github-actions` reporter requires Jest 28 or higher. @@ -58,6 +59,7 @@ jobs: with: NODE_VERSION: 14 JEST_ARGS: 'my-test --reporters=jest-junit' + CODECOV_FLAGS: 'js' ``` ## Static analysis JavaScript diff --git a/docs/php.md b/docs/php.md index 941955b12..c63a72c69 100644 --- a/docs/php.md +++ b/docs/php.md @@ -153,6 +153,7 @@ jobs: | `PHP_EXTENSIONS` | `''` | PHP extensions supported by shivammathur/setup-php to be installed or disabled | | `COMPOSER_ARGS` | `'--prefer-dist'` | Set of arguments passed to Composer | | `PHPUNIT_ARGS` | `'--coverage-text'` | Set of arguments passed to PHPUnit | +| `CODECOV_FLAGS` | `'unittests'` | Flags to be passed to Codecov | #### Secrets @@ -180,6 +181,7 @@ jobs: with: PHP_VERSION: ${{ matrix.php }} PHPUNIT_ARGS: '--coverage-text' + CODECOV_FLAGS: 'php' ``` ## Lint PHP