Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mheap/phpunit-matcher-action
Add annotations to your PHPUnit tests when running under Github Actions
https://github.com/mheap/phpunit-matcher-action
actions ci github github-action phpunit
Last synced: 12 days ago
JSON representation
Add annotations to your PHPUnit tests when running under Github Actions
- Host: GitHub
- URL: https://github.com/mheap/phpunit-matcher-action
- Owner: mheap
- Created: 2020-01-06T21:49:16.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-06-18T08:49:49.000Z (6 months ago)
- Last Synced: 2024-12-04T11:22:56.021Z (23 days ago)
- Topics: actions, ci, github, github-action, phpunit
- Language: JavaScript
- Homepage:
- Size: 861 KB
- Stars: 33
- Watchers: 4
- Forks: 6
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# phpunit-matcher-action
This action uses the built in PHPUnit `--teamcity` formatter to add annotations to your Github Actions builds.
![PHPUnit Action Matcher Logs Example](https://raw.githubusercontent.com/mheap/phpunit-matcher-action/main/phpunit-matcher-logs.png)
![PHPUnit Action Matcher Context Example](https://raw.githubusercontent.com/mheap/phpunit-matcher-action/main/phpunit-matcher-context.png)
## Usage
To configure these matchers, add the following step to your workflow YAML file before running PHPUnit with the `--teamcity` flag.
```yaml
- name: Configure matchers
uses: mheap/phpunit-matcher-action@v1
```Here's a complete workflow example (located at `.github/workflows/phpunit.yml`) that runs your tests and adds annotations for failures
```yaml
name: PHPUnit
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Composer dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist
- name: Configure matchers
uses: mheap/phpunit-matcher-action@v1
- name: Run Tests
run: ./vendor/bin/phpunit --teamcity test
```If you run your tests in a container and the Teamcity output will have a different base path, you can specify it using the `base_path` input:
```yaml
- name: Configure matchers
uses: mheap/phpunit-matcher-action@v1
with:
base_path: /path/to/other/folder
```## How this works
[Problem matchers](https://github.com/actions/toolkit/blob/master/docs/problem-matchers.md) work by defining a regular expression to extract information such as the file, line number and severity from any output logs. Each matcher has to be registered with Github Actions by adding `::add-matcher::/path/to/matcher.json` to the output.
This action generates regular expressions based on the Github workspace, writes out matcher files and then registers them with the Action runner.
It uses the Teamcity output as it contains all of the required information (file path, failure message and line number).