Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3.0.0 #3

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
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
30 changes: 30 additions & 0 deletions .github/workflows/composer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Composer

on:
push:
pull_request:
workflow_call:
workflow_dispatch:

jobs:
composer:
name: Validation
runs-on: [ubuntu-latest]

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

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Validate composer
run: composer validate --strict --no-check-all
24 changes: 24 additions & 0 deletions .github/workflows/line-endings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Check Line Endings

on:
push:
pull_request:
workflow_call:
workflow_dispatch:

jobs:
check-line-endings:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Check Line Endings
run: |
if files_with_crlf=$(git grep -Il $'\r'); then
echo "CR line endings found in the following files, please fix them:"
echo "$files_with_crlf"
exit 1
else
echo "No CRLF line endings found, great!"
exit 0
fi
45 changes: 45 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: PHPStan

on:
push:
pull_request:
workflow_call:
workflow_dispatch:

jobs:
phpstan:
name: Analyze PHP (${{ matrix.refs == 'pr-head' && github.head_ref || github.base_ref || github.ref_name }})
runs-on: [ubuntu-latest]
strategy:
fail-fast: false
matrix:
refs: ['target-branch', 'pr-head']
exclude:
- refs: ${{ github.event_name != 'pull_request' && 'pr-head' }}

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: latest

- uses: actions/checkout@v4
with:
ref: ${{ matrix.refs == 'pr-head' && github.event.pull_request.head.sha || '' }}

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-*

- name: PHPStan Static Analysis
run: XDEBUG_MODE=off php vendor/bin/phpstan.phar analyze -vvv
65 changes: 65 additions & 0 deletions .github/workflows/syntax-php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: PHP Syntax

on:
push:
pull_request:
workflow_call:
workflow_dispatch:

jobs:
syntax_php:
name: PHP Syntax ${{ matrix.php-versions }}
runs-on: [ubuntu-latest]

strategy:
fail-fast: false
matrix:
php-versions: ['8.2', '8.3', '8.4']

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get last successful commit
id: last-successful-commit
uses: SamhammerAG/last-successful-build-action@v7
with:
branch: main
workflow: ${{ github.workflow }}
verify: true

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
with:
base_sha: ${{ steps.last-successful-commit.outputs.sha }}
files: |
**/*.{php}
!.phpstorm.meta.php/*

- name: Setup PHP
if: ${{ steps.changed-files.outputs.any_changed == 'true' }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
ini-values: error_reporting=E_ALL, short_open_tag=Off
tools: none

- name: Check changed files
if: ${{ steps.changed-files.outputs.any_changed == 'true' }}
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
set +e
ERROR=0
for FILE in ${ALL_CHANGED_FILES}; do
MESSAGE=$(php -l "$FILE" 2>&1 1>/dev/null)
if [ $? -ne 0 ]; then
ERROR=255
LINE=$(echo $MESSAGE | sed -En 's/.*on line ([0-9]+).*/\1/p')
echo "::error file=$FILE,line=$LINE::$MESSAGE"
fi
done
exit $ERROR
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# PhpStorm
.idea

# composer
/vendor

# PhpStan
.phpstan*.neon
phpstan*.neon
!.phpstan.dist.neon
!.phpstan.dist.*.neon
12 changes: 12 additions & 0 deletions .phpstan.dist.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
includes:
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
- vendor/phpstan/phpstan-strict-rules/rules.neon
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
- vendor/composer/composer/phpstan/rules.neon
parameters:
phpVersion:
min: 80200
max: 80400
paths:
- src
level: 10
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License
fballiano marked this conversation as resolved.
Show resolved Hide resolved

Copyright (c) Maho

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
19 changes: 16 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
{
"name": "mahocommerce/maho-composer-plugin",
"description": "Extension for Composer to copy assets and enable autoloading for Maho projects.",
"type": "composer-plugin",
"license": "MIT",
"require": {
"composer-plugin-api": "^2.0"
"composer-plugin-api": "^2.1",
"composer-runtime-api": "^2"
},
"require-dev": {
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpstan/phpstan-deprecation-rules": "^2.0",
fballiano marked this conversation as resolved.
Show resolved Hide resolved
"composer/composer": "^2.8"
},
"autoload": {
"psr-4": {
"Maho\\": "src/"
"Maho\\ComposerPlugin\\": "src/"
}
},
"extra": {
"class": "Maho\\MahoComposerPlugin"
"class": [
"Maho\\ComposerPlugin\\AutoloadPlugin",
"Maho\\ComposerPlugin\\FileCopyPlugin",
"Maho\\ComposerPlugin\\ModmanPlugin"
]
}
}
Loading