Giter Site home page Giter Site logo

vmcj / action-php-codesniffer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tinovyatkin/action-php-codesniffer

0.0 1.0 0.0 907 KB

Github Action to check your code with PHP_CodeSniffer that can check only PR changed files or even lines

License: MIT License

TypeScript 89.14% JavaScript 3.00% PHP 7.85%

action-php-codesniffer's Introduction

GitHub Action to run PHP_CodeSniffer of files changed in current PR or even on changed lines

This action runs PHP_CodeSniffer on files changed in a Pull Request, by default annotating only lines changed by the PR author. So, it's fast and great to work with legacy code:

annotations

Contrary to some existing solutions this actions works faster than Docker based actions (as it runs from Node.JS directly in the same VM) and runs only on changed files (good for big projects with some non-conform files as well as to gradually introduce code style).

Usage

Add a file like this to .github/workflows/phpcs.yml:

name: "CI"

on:
  pull_request:
    paths:
      - "**.php"
      - "phpcs.xml"
      - ".github/workflows/phpcs.yml"

jobs:
  phpcs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0 # important!

      # we may use whatever way to install phpcs, just specify the path on the next step
      # however, curl seems to be the fastest
      - name: Install PHP_CodeSniffer
        run: |
          curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
          php phpcs.phar --version

      - uses: tinovyatkin/action-php-codesniffer@v1
        with:
          files: "**.php" # you may customize glob as needed
          phpcs_path: php phpcs.phar
          standard: phpcs.xml

You also will need either to pick a build code style standard or create phpcs.xml file (like this for example). You may find all available configuration options at action.yml in this repository. Example of this action running over small change in big legacy codebase: https://github.com/tinovyatkin/woocommerce/pull/1/checks?check_run_id=642017335

action-php-codesniffer's People

Contributors

tinovyatkin avatar renovate-bot avatar vmcj avatar thenabeel avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.