Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Workflow example for GitHub Action #63

Closed
ocean90 opened this issue Mar 28, 2020 · 3 comments
Closed

Docs: Workflow example for GitHub Action #63

ocean90 opened this issue Mar 28, 2020 · 3 comments
Labels

Comments

@ocean90
Copy link
Member

ocean90 commented Mar 28, 2020

Idea:
For PRs, detect coding standard violations via PHP_CodeSniffer. Errors should prevent the PR from being merged and shown to the user.

Implementation:

Result:

name: PHP_CodeSniffer

on: pull_request

jobs:
  phpcs:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '7.3'
          coverage: none
          tools: composer, cs2pr

      - name: Get Composer cache directory
        id: composer-cache
        run: |
          echo "::set-output name=dir::$(composer config cache-files-dir)"

      - name: Setup cache
        uses: pat-s/always-upload-cache@v1.1.4
        with:
          path: ${{ steps.composer-cache.outputs.dir }}
          key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
          restore-keys: |
            ${{ runner.os }}-composer-

      - name: Install dependencies
        run: composer install --prefer-dist --no-suggest --no-progress

      - name: Detect coding standard violations
        run: vendor/bin/phpcs -nq --report=checkstyle | cs2pr

Limits:

  • Only 10 warning annotations and 10 error annotations per step (source)
@ocean90
Copy link
Member Author

ocean90 commented Apr 6, 2020

@grappler
Copy link
Contributor

I really like the GitHub Action though I think it is not necessary to give feedback on files that have not been changed like so:
image

By only checking the modified files it could slightly help with the annotation limit.

We could use the File Changes Action to only check the modified files.

@ocean90 ocean90 added the phpcs label May 18, 2020
@ocean90
Copy link
Member Author

ocean90 commented May 25, 2020

@ocean90 ocean90 closed this as completed May 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants