Skip to content

Commit

Permalink
Add chatops phpstan-baseline command (yakamara#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Nov 6, 2020
1 parent 30f612c commit 6b2ab39
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 21 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/chatops.yml
@@ -0,0 +1,18 @@
name: Chatops

on:
issue_comment:
types: [created]

jobs:
slash-command-dispatch:
runs-on: ubuntu-latest
steps:
- name: Slash Command Dispatch
uses: peter-evans/slash-command-dispatch@v2
with:
token: ${{ secrets.STAABM_TOKEN }}
# reactions should be reported from github itself
reaction-token: ${{ secrets.GITHUB_TOKEN }}
commands: phpstan-baseline
issue-type: pull-request
69 changes: 48 additions & 21 deletions .github/workflows/phpstan.yml
@@ -1,27 +1,54 @@
name: PHP Checks

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
repository_dispatch:
types: [phpstan-baseline-command] # triggered by /phpstan-baseline PR comment

jobs:

phpstan-analysis:
name: phpstan static code analysis
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: intl, imagick
coverage: none # disable xdebug, pcov
tools: cs2pr

- name: Install Dependencies
run: composer install --prefer-dist

- run: |
vendor/bin/phpstan analyse --no-progress
phpstan-analysis:
name: phpstan static code analysis
runs-on: ubuntu-latest

steps:
- name: Add action run link to trigger comment
if: "github.event_name == 'repository_dispatch'"
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.STAABM_TOKEN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
```
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
```
- uses: actions/checkout@v2
with:
token: ${{ secrets.STAABM_TOKEN }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.ref }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: intl, imagick
coverage: none # disable xdebug, pcov

- name: Install Dependencies
run: composer install --ansi --prefer-dist

- run: composer phpstan-baseline # generate baseline
if: "github.event_name == 'repository_dispatch'"
- name: Commit changed files
if: "github.event_name == 'repository_dispatch'"
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply phpstan-baseline changes
branch: ${{ github.head_ref }}
file_pattern: '*.neon'

- run: vendor/bin/phpstan analyse --ansi --no-progress
if: "github.event_name != 'repository_dispatch'"

0 comments on commit 6b2ab39

Please sign in to comment.