feat(coding-standard-baseline)!: remove coding-standard-baseline action (#223)

This commit is contained in:
Damien Retzinger
2026-04-26 21:49:48 -04:00
committed by GitHub
parent de415eaff5
commit 953de845eb
2 changed files with 0 additions and 196 deletions
-45
View File
@@ -1,45 +0,0 @@
# Magento 2 Coding Standard Action
This Github Action automates the enforcement of Magento Coding Standards. It ensures code consistency and quality by checking code against Magento's specific coding guidelines.
## Inputs
For detailed descriptions of each input, refer to [action.yml](./action.yml).
## Why a Baseline?
Running PHP CodeSniffer (PHPCS) with a baseline is crucial for managing legacy code. It allows you to set a "starting point" for code quality, ignoring existing issues while ensuring no new issues are introduced. This approach is especially useful for large codebases where addressing all existing issues at once is not feasible. The baseline serves as a record of known issues, enabling teams to focus on maintaining and gradually improving code quality in new or modified code.
## Usage Example
The following example demonstrates how to set up the action in your workflow:
Check how this action is used in mage-os [here](https://github.com/mage-os/mageos-magento2/blob/2.4-develop/.github/workflows/coding-standard-baseline.yml).
```yml
name: Coding Standard Baseline
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
coding-standard:
runs-on: ubuntu-latest
steps:
- uses: graycoreio/github-actions-magento2/coding-standard-baseline@main
with:
head_repo: "mage-os/mageos-magento2"
head_ref: "main"
php_version: "8.2"
composer_version: "2"
version: "*"
severity: "5"
warning_severity: "8"
error_severity: "8"
baseline_version: "*"
```
-151
View File
@@ -1,151 +0,0 @@
name: "M2 Coding Standard"
author: "Mage-OS"
description: "A Github Action that runs the Magento Coding Standard."
inputs:
php_version:
type: string
required: true
default: "8.2"
description: "PHP version used to do the coding standard check (default: 8.2)."
composer_version:
type: string
required: true
default: "2"
description: "The version of composer to use (default: 2)."
version:
type: string
required: false
default: "*"
description: "The version of the coding standard to use (default: latest)."
severity:
type: string
required: false
default: "5"
description: "The minimum severity required to display an error or warning (default: 5)"
warning_severity:
type: string
required: false
default: "8"
description: "The minimum severity required to display a warning (default: 8)."
error_severity:
type: string
required: false
default: "8"
description: "The minimum severity required to display an error (default: 8)."
baseline_version:
type: string
required: false
default: "*"
description: "The version of phpcs baseline to use (default: latest)."
head_repo:
type: string
required: true
description: "The repository full name of the head branch. E.g.: mage-os/mageos-magento2"
head_ref:
type: string
required: true
description: "The branch name of the head branch. E.g.: main"
runs:
using: composite
steps:
- name: Checkout head
uses: actions/checkout@v6
with:
ref: ${{ inputs.head_ref }}
repository: ${{ inputs.head_repo }}
- uses: dorny/paths-filter@v2
name: Filter changed files
id: filter
with:
list-files: shell
filters: |
baseline:
- modified: '**/**.{php,phtml,graphqls,less,css,html,xml,js}'
phpcs:
- added|modified: '**/**.{php,phtml,graphqls,less,css,html,xml,js}'
- name: Check changed files for PHPcs
if: steps.filter.outputs.phpcs == 'true'
shell: bash
run: |
echo "One or more files relevant to PHPCS have changed."
echo "List all the files that have been added or changed: ${{ steps.filter.outputs.phpcs_files }}"
- name: Setup PHP
if: steps.filter.outputs.phpcs == 'true'
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php_version }}
tools: composer:v${{ inputs.composer_version }}
coverage: none
- name: Install coding standards
if: steps.filter.outputs.phpcs == 'true'
shell: bash
run: |
composer create-project --no-plugins --no-dev \
magento/magento-coding-standard \
magento-coding-standard "${{ github.event.inputs.version || '*' }}"
- name: Install phpcs baseline
if: steps.filter.outputs.phpcs == 'true'
working-directory: magento-coding-standard
shell: bash
run: |
composer config --no-plugins allow-plugins.digitalrevolution/php-codesniffer-baseline true
composer require --dev "digitalrevolution/php-codesniffer-baseline: ${{ github.event.inputs.baseline_version || '*' }}"
- name: Checkout base
if: steps.filter.outputs.phpcs == 'true'
uses: actions/checkout@v6
with:
ref: ${{github.event.pull_request.base.ref}}
repository: ${{github.event.pull_request.base.repo.full_name}}
path: base
- name: Create phpcs.baseline.xml from base
shell: bash
working-directory: base
if: steps.filter.outputs.baseline == 'true'
run: |
php ${{ github.workspace }}/magento-coding-standard/vendor/bin/phpcs --standard=Magento2 \
$([ -n "${{ inputs.severity }}" ] && echo "--severity=${{ inputs.severity }}") \
$([ -n "${{ inputs.warning_severity }}" ] && echo "--warning-severity=${{ inputs.warning_severity }}") \
$([ -n "${{ inputs.error_severity }}" ] && echo "--error-severity=${{ inputs.error_severity }}") \
--report=\\DR\\CodeSnifferBaseline\\Reports\\Baseline --report-file=phpcs.baseline.xml \
${{ steps.filter.outputs.baseline_files }} || /bin/true
- name: Copy baseline to head
if: steps.filter.outputs.baseline == 'true'
shell: bash
run: |
cp ${{ github.workspace }}/base/phpcs.baseline.xml ${{ github.workspace }}/magento-coding-standard/phpcs.baseline.xml
# Since we ran phpcs in the base folder, the files in phpcs.baseline.xml contain the base folder in the path.
# We need to remove /base/ so that the phpcs can locate the correct files.
- name: Remove base dir from phpcs baseline
if: steps.filter.outputs.baseline == 'true'
shell: bash
run: |
sed -i "s|/base/|/|" ${{ github.workspace }}/magento-coding-standard/phpcs.baseline.xml
- name: Execute phpcs on head for changed files
shell: bash
if: steps.filter.outputs.phpcs == 'true'
run: |
php ${{ github.workspace }}/magento-coding-standard/vendor/bin/phpcs --standard=Magento2 \
$([ -n "${{ inputs.severity }}" ] && echo "--severity=${{ inputs.severity }}") \
$([ -n "${{ inputs.warning_severity }}" ] && echo "--warning-severity=${{ inputs.warning_severity }}") \
$([ -n "${{ inputs.error_severity }}" ] && echo "--error-severity=${{ inputs.error_severity }}") \
${{ steps.filter.outputs.phpcs_files }}