Update README.md #12
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Apply linting and code sniffer | |
on: | |
pull_request: | |
types: [opened, edited, reopened, synchronize] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout code | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
ref: ${{ github.event.pull_request.head.ref }} | |
# Step 2: Validate composer.json and composer.lock | |
- name: Validate composer.json and composer.lock | |
run: composer validate | |
# Validate composer.json and composer.lock files to ensure they are properly formatted. | |
# Step 3: Cache Composer packages | |
- name: Cache Composer packages | |
id: composer-cache | |
uses: actions/cache@v4 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php- | |
# Cache Composer packages to speed up dependency installation. | |
# Step 4: Install dependencies | |
- name: Install dependencies | |
if: steps.composer-cache.outputs.cache-hit != 'true' | |
run: composer install --prefer-dist --no-progress --no-suggest | |
# Install project dependencies using Composer if the cache is not hit. | |
# Step 5: Autocorrect PHP12 code standards violations | |
- name: Autocorrect PHP12 code standards violations | |
run: composer phpcbf | |
continue-on-error: true | |
# Attempt to automatically fix PHP code standard violations using PHP Code Beautifier and Fixer (phpcbf). | |
# Step 6: Set PHPCS config | |
- name: Set PHPCS config | |
run: composer phpcs-config-set | |
# Set PHPCS configuration to stop it exiting on a warning when linting. | |
# Step 7: Print lint results and check for errors | |
- name: Print lint results and check for errors | |
run: composer phpcs | |
# Run PHP CodeSniffer (phpcs) to check for PHP code standard violations and fail if any errors are detected. | |
# Step 8: Add & Commit | |
- name: Add & Commit | |
uses: EndBug/add-and-commit@v9 | |
with: | |
add: '.' | |
author_name: "${{ github.actor }}" | |
author_email: "${{ github.actor }}@users.noreply.github.com" | |
message: "Automated code lint ${{ github.sha }}" | |
# Add and commit the changes with a standardized commit message indicating automated code linting. |