Skip to content
Add annotations to your PHPUnit tests when running under Github Actions
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md
action.yml
index.js
package.json
phpunit-matcher-context.png
phpunit-matcher-logs.png

README.md

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

PHPUnit Action Matcher Context Example

Usage

To configure these matchers, add the following step to your workflow YAML file before running PHPUnit with the --teamcity flag.

- name: Configure matchers
  uses: mheap/phpunit-matcher-action@master

Here's a complete workflow example (located at .github/workflows/phpunit.yml) that runs your tests and adds annotations for failures

name: PHPUnit
on: [pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - 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@master
    - name: Run Tests
      run: ./vendor/bin/phpunit --teamcity test

How this works

Problem matchers 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).

You can’t perform that action at this time.