添加forwardPorts端口并完善工作流
This commit is contained in:
97
.gitea/workflows/code-check.yaml
Normal file
97
.gitea/workflows/code-check.yaml
Normal file
@@ -0,0 +1,97 @@
|
||||
name: PHP Code Check
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, master, develop ]
|
||||
pull_request:
|
||||
branches: [ main, master, develop ]
|
||||
|
||||
jobs:
|
||||
code-quality:
|
||||
name: Code Quality Check
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.2'
|
||||
extensions: mbstring, xml, ctype, json
|
||||
coverage: none
|
||||
tools: php-cs-fixer, phpstan, psalm
|
||||
|
||||
- name: Validate PHP syntax
|
||||
run: |
|
||||
echo "Checking PHP syntax..."
|
||||
find . -name "*.php" -not -path "./vendor/*" -exec php -l {} \; | grep -v "No syntax errors"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "✓ All PHP files have valid syntax"
|
||||
fi
|
||||
|
||||
- name: Install Composer dependencies
|
||||
if: hashFiles('composer.json') != ''
|
||||
run: |
|
||||
if [ -f "composer.json" ]; then
|
||||
composer install --prefer-dist --no-progress --no-suggest
|
||||
else
|
||||
echo "No composer.json found, skipping..."
|
||||
fi
|
||||
|
||||
- name: Run PHP_CodeSniffer
|
||||
continue-on-error: true
|
||||
run: |
|
||||
if [ -f "composer.json" ]; then
|
||||
if composer show --installed | grep -q "squizlabs/php_codesniffer"; then
|
||||
vendor/bin/phpcs --standard=PSR12 --colors -p .
|
||||
else
|
||||
echo "PHP_CodeSniffer not installed, skipping..."
|
||||
fi
|
||||
else
|
||||
echo "No composer.json, skipping PHP_CodeSniffer..."
|
||||
fi
|
||||
|
||||
- name: Run PHP CS Fixer (dry-run)
|
||||
continue-on-error: true
|
||||
run: |
|
||||
if command -v php-cs-fixer &> /dev/null; then
|
||||
php-cs-fixer fix --dry-run --diff --verbose
|
||||
else
|
||||
echo "PHP CS Fixer not available, skipping..."
|
||||
fi
|
||||
|
||||
- name: Run PHPStan
|
||||
continue-on-error: true
|
||||
run: |
|
||||
if [ -f "composer.json" ]; then
|
||||
if composer show --installed | grep -q "phpstan/phpstan"; then
|
||||
vendor/bin/phpstan analyse --level=5 --no-progress .
|
||||
elif command -v phpstan &> /dev/null; then
|
||||
phpstan analyse --level=5 --no-progress .
|
||||
else
|
||||
echo "PHPStan not installed, skipping..."
|
||||
fi
|
||||
else
|
||||
echo "No composer.json, skipping PHPStan..."
|
||||
fi
|
||||
|
||||
- name: Run Psalm
|
||||
continue-on-error: true
|
||||
run: |
|
||||
if [ -f "composer.json" ]; then
|
||||
if composer show --installed | grep -q "vimeo/psalm"; then
|
||||
vendor/bin/psalm --no-progress
|
||||
elif command -v psalm &> /dev/null; then
|
||||
psalm --no-progress
|
||||
else
|
||||
echo "Psalm not installed, skipping..."
|
||||
fi
|
||||
else
|
||||
echo "No composer.json, skipping Psalm..."
|
||||
fi
|
||||
|
||||
- name: Check code formatting
|
||||
run: |
|
||||
echo "✓ Code quality checks completed"
|
||||
Reference in New Issue
Block a user