Skip to content

Commit

Permalink
Create lint.yml (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
eramitgupta authored Dec 25, 2024
2 parents 09e487b + a0e0417 commit 05d9c40
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Lint Check

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
style:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mbstring, bcmath
tools: composer:v2

- name: Install Dependencies
run: composer install --no-scripts --no-interaction --prefer-dist

- name: Check code style with Pint
run: |
vendor/bin/pint --test
if [ $? -eq 0 ]; then
echo "✅ Code style is clean"
else
echo "❌ Code style issues found"
vendor/bin/pint --verbose
exit 1
fi
- name: Add Lint Results as PR Comment
if: github.event_name == 'pull_request' && failure()
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `
## ⚠️ PHP Code Style Check Failed
Please fix the code style issues found by Laravel Pint.
Run \`composer lint\` locally to see and fix the issues.
For more information about Laravel Pint, visit: https://laravel.com/docs/pint
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
9 changes: 9 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"homepage": "https://github.com/eramitgupta/laravel-role-permission",
"require": {
"php": "^8.0",
"laravel/pint": "^1.13",
"illuminate/auth": "^8.12|^9.0|^10.0|^11.0",
"illuminate/container": "^8.12|^9.0|^10.0|^11.0",
"illuminate/contracts": "^8.12|^9.0|^10.0|^11.0",
Expand All @@ -38,11 +39,19 @@
}
},
"prefer-stable": true,
"minimum-stability": "stable",
"extra": {
"laravel": {
"providers": [
"EragPermission\\PermissionServiceProvider"
]
}
},
"scripts": {
"lint": "pint",
"lint:dirty": "pint --dirty",
"post-install-cmd": [
"@lint"
]
}
}

0 comments on commit 05d9c40

Please sign in to comment.