Skip to content

Commit

Permalink
create phplint-problem-matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
korelstar committed Feb 13, 2020
1 parent c18e12a commit 65ba096
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Test
on:
push:
branches:
- master
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Set up php${{ matrix.php-versions }}
uses: shivammathur/setup-php@v1
- name: add problem matcher for php lint
run: ./index.js
- name: lint PHP file with syntax error
run: php -l test/error.php || true

11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# phplint-problem-matcher

This problem matcher lets you show errors from `php -l` as annotation in GitHub Actions.

## Usage

Add the step to your workflow, before `php -l` is called.

```yaml
- uses: korelstar/phplint-problem-matcher@v1
```
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: 'phplint problem matcher'
author: 'Kristof Hamann'
description: 'Shows php lint errors as annotation (with file and code line) in GitHub Actions'
runs:
using: 'node12'
main: 'index.js'
branding:
icon: 'check-square'
color: 'green'
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
console.log(`::add-matcher::${__dirname}/phplint-matcher.json`);
16 changes: 16 additions & 0 deletions phplint-matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"problemMatcher": [
{
"owner": "phplint-matcher",
"pattern": [
{
"regexp": "^(.+):\\s+\\s+(.+) in (.+) on line (\\d+)$",
"code": 1,
"message": 2,
"file": 3,
"line": 4
}
]
}
]
}
3 changes: 3 additions & 0 deletions test/error.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

echo "syntax error"

0 comments on commit 65ba096

Please sign in to comment.