feat: add coding standard action (#51)

This commit is contained in:
Daniel Sloof
2022-09-06 16:36:33 +02:00
committed by GitHub
parent e8e2509a90
commit 2a102c253d
4 changed files with 138 additions and 1 deletions
+30
View File
@@ -0,0 +1,30 @@
# Magento 2 Coding Standard Action
A Github Action that runs the Magento Coding Standard.
## Inputs
See the [action.yml](./action.yml)
## Usage
```yml
name: Coding Standard
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
coding-standard:
runs-on: ubuntu-latest
steps:
- uses: graycoreio/github-actions-magento2/coding-standard@main
with:
version: 25 # Optional, will use the latest if omitted.
path: app/code # Optional, will be used when event is not a pull request.
```
+65
View File
@@ -0,0 +1,65 @@
name: "Coding Standard"
author: "Graycore"
description: "A Github Action that runs the Magento Coding Standard."
inputs:
php_version:
required: true
default: "8.1"
description: "PHP version used to do the coding standard check."
composer_version:
required: true
default: "2"
description: "The version of composer to use."
path:
required: true
default: 'app/code'
description: "The directory (relative to the project root) in which the coding standard will be checked. Used when the event is not a pull request."
version:
required: false
description: "The version of the coding standard to use. If not provided, will use the latest version."
runs:
using: composite
steps:
- name: Checkout Project
uses: actions/checkout@v3
with:
fetch-depth: 0
path: project
- name: Create Standard Directory
shell: bash
run: mkdir standard
- name: Set PHP Version
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php_version }}
tools: composer:v${{ inputs.composer_version }}
coverage: none
- name: Install Coding Standard
shell: bash
working-directory: standard
run: composer require "magento/magento-coding-standard:${{ inputs.version || '*' }}"
- name: Register Coding Standard
shell: bash
working-directory: standard
run: vendor/bin/phpcs --config-set installed_paths ${{ github.workspace }}/standard/vendor/magento/magento-coding-standard,${{ github.workspace }}/standard/vendor/phpcompatibility/php-compatibility
- name: Get Changed Files
shell: bash
working-directory: project
id: changed-files
run: echo "::set-output name=files::$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | xargs)"
if: github.event_name == 'pull_request'
- name: Coding Standard Check
shell: bash
run: ../standard/vendor/bin/phpcs --standard=Magento2 ${{ github.event_name == 'pull_request' && steps.changed-files.outputs.files || inputs.path }}
working-directory: project