Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions CI/linters/pint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
pint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"

- name: Cache Composer
uses: actions/cache@v4
with:
path: vendor
key: composer-${{ hashFiles('composer.lock') }}
restore-keys: composer-

- name: Install dependencies
run: composer install --no-interaction --prefer-dist

- name: Run pint
run: |
set -euo pipefail

if [[ -x "vendor/bin/pint" ]]; then
PINT="vendor/bin/pint"
elif command -v pint &> /dev/null; then
PINT="pint"
else
echo "::error::laravel/pint not found (run 'composer require --dev laravel/pint')"
exit 1
fi

echo "ℹ️ Running Pint in check mode..."

if "$PINT" --test; then
echo "✅ pint passed"
else
echo "❌ pint found style issues"
exit 1
fi
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ that projects compose into their own workflows.
| markdownlint | linters | [CI/linters/markdownlint.yml](https://github.com/prog-time/workflows/blob/main/CI/linters/markdownlint.yml) |
| mermaid-cli | linters | [CI/linters/mermaid.yml](https://github.com/prog-time/workflows/blob/main/CI/linters/mermaid.yml) |
| phpcs | linters | [CI/linters/phpcs.yml](https://github.com/prog-time/workflows/blob/main/CI/linters/phpcs.yml) |
| Pint | linters | [CI/linters/pint.yml](https://github.com/prog-time/workflows/blob/main/CI/linters/pint.yml) |
| RuboCop | linters | [CI/linters/rubocop.yml](https://github.com/prog-time/workflows/blob/main/CI/linters/rubocop.yml) |
| Ruff | linters | [CI/linters/ruff.yml](https://github.com/prog-time/workflows/blob/main/CI/linters/ruff.yml) |
| ShellCheck | linters | [CI/linters/shellcheck.yml](https://github.com/prog-time/workflows/blob/main/CI/linters/shellcheck.yml) |
Expand Down
22 changes: 22 additions & 0 deletions scripts/CI/linters/pint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
pint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"

- name: Cache Composer
uses: actions/cache@v4
with:
path: vendor
key: composer-${{ hashFiles('composer.lock') }}
restore-keys: composer-

- name: Install dependencies
run: composer install --no-interaction --prefer-dist

- name: Run pint
run: bash scripts/shell/linters/pint.sh
20 changes: 20 additions & 0 deletions scripts/shell/linters/pint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail

if [[ -x "vendor/bin/pint" ]]; then
PINT="vendor/bin/pint"
elif command -v pint &> /dev/null; then
PINT="pint"
else
echo "::error::laravel/pint not found (run 'composer require --dev laravel/pint')"
exit 1
fi

echo "ℹ️ Running Pint in check mode..."

if "$PINT" --test; then
echo "✅ pint passed"
else
echo "❌ pint found style issues"
exit 1
fi
43 changes: 43 additions & 0 deletions tests/linters/pint.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bats

load "../helpers/common"

SCRIPT="$BATS_TEST_DIRNAME/../../scripts/shell/linters/pint.sh"

setup() {
setup_test_dir
}

teardown() {
teardown_test_dir
}

make_pint_stub() {
local exit_code="$1"
mkdir -p "$TEST_DIR/vendor/bin"
cat > "$TEST_DIR/vendor/bin/pint" <<STUB
#!/usr/bin/env bash
exit $exit_code
STUB
chmod +x "$TEST_DIR/vendor/bin/pint"
}

@test "pint not installed: exits 1 with error annotation" {
PATH="/usr/bin:/bin" run bash "$SCRIPT"
[ "$status" -eq 1 ]
[[ "$output" == *"::error::laravel/pint not found"* ]]
}

@test "clean code: exits 0 with success message" {
make_pint_stub 0
run bash "$SCRIPT"
[ "$status" -eq 0 ]
[[ "$output" == *"✅ pint passed"* ]]
}

@test "style issues: exits 1 with failure message" {
make_pint_stub 1
run bash "$SCRIPT"
[ "$status" -eq 1 ]
[[ "$output" == *"❌ pint found style issues"* ]]
}
Loading