mirror of
https://github.com/graycoreio/github-actions-magento2.git
synced 2026-06-08 19:46:41 +00:00
66 lines
2.1 KiB
YAML
66 lines
2.1 KiB
YAML
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 "files=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | xargs)" >> $GITHUB_OUTPUT
|
|
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
|