Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions .github/workflows/tests-unit-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -44,6 +49,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:
Expand Down Expand Up @@ -118,4 +126,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: ${{ inputs.CODECOV_FLAGS }}
verbose: true
24 changes: 23 additions & 1 deletion .github/workflows/tests-unit-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,21 @@ 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.
required: false
ENV_VARS:
description: Additional environment variables as a JSON formatted object.
required: false
CODECOV_TOKEN:
description: Codecov token.
required: false

jobs:
tests-unit-php:
Expand Down Expand Up @@ -67,4 +75,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('coverage.xml') != '' }}
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: ${{ inputs.CODECOV_FLAGS }}
verbose: true
6 changes: 5 additions & 1 deletion docs/js.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -39,6 +40,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:**

Expand All @@ -53,9 +55,11 @@ 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'
CODECOV_FLAGS: 'js'
```

## Static analysis JavaScript
Expand Down
7 changes: 6 additions & 1 deletion docs/php.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,15 @@ 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

| Name | Description |
|----------------------|------------------------------------------------------------------------------------------|
| `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:**

Expand All @@ -174,9 +176,12 @@ 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'
CODECOV_FLAGS: 'php'
```

## Lint PHP
Expand Down
Loading