From a986e4881d76bcbcb92ba87ba06af7188589e579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20D=C3=A9siles?= Date: Fri, 30 Sep 2022 16:23:24 +0200 Subject: [PATCH 1/2] Introduce a new PHP agnostic action --- action.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 action.yml diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..125e90d --- /dev/null +++ b/action.yml @@ -0,0 +1,19 @@ +name: 'Prestashop PHP Linter Router' +description: 'PHP linter router' +inputs: + php-version: + description: 'Your target PHP version' + required: true + folder-to-exclude: + description: 'Folder to exclude' + required: false + default: '! -path "./vendor/*"' +runs: + using: 'composite' + steps: + - name: "Lint with php ${{ inputs.php-version }}" + shell: bash + run: | + echo "Pulled docker image: $(docker pull --quiet php:${{ inputs.php-version }})" + docker run --rm --entrypoint /bin/sh php:${{ inputs.php-version }} -c "! (find . -type f -name \"*.php\" ${{ inputs.folder-to-exclude }} -exec php -l -n {} \; | grep -v \"No syntax errors detected\")" + echo "No syntax error detected" From 2e15ec9ee9cff5f0521753bf6286b7f5d56c3b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20D=C3=A9siles?= Date: Fri, 30 Sep 2022 16:26:11 +0200 Subject: [PATCH 2/2] update documentation --- README.md | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 67b0812..4150084 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,28 @@ -# GitHub Action for PHP syntax check +# GitHub Action for PHP syntax checking This actions runs `php -l` on all PHP files found in the current project. ## Getting Started -Using this action can be done with this template: +Use this action like: -``` -steps: - - name: Checkout - uses: actions/checkout@v1 - with: - fetch-depth: 0 - - name: PHP syntax checker 7.2 - uses: prestashop/github-action-php-lint/7.2@v1 - with: - folder-to-exclude: "! -path \"./vendor/*\" ! -path \"./customer/folder/excluded/*\"" - - name: PHP syntax checker 7.3 - uses: prestashop/github-action-php-lint/7.3@v1 - with: - folder-to-exclude: "! -path \"./vendor/*\" ! -path \"./customer/folder/excluded/*\"" - - name: PHP syntax checker 5.6 - uses: prestashop/github-action-php-lint/5.6@v1 - with: - folder-to-exclude: "! -path \"./vendor/*\" ! -path \"./customer/folder/excluded/*\"" +```yaml +jobs: + php-linter: + name: PHP syntax checking + runs-on: ubuntu-latest + strategy: + matrix: + php_version: ["5.6", "7.2", "7.3"] + steps: + - name: Checkout sources + uses: actions/checkout@v2.0.0 + + - name: PHP syntax checker ${{ matrix.php_version }} + uses: "prestashop/github-action-php-lint@master" + with: + php-version: ${{ matrix.php_version }} + folder-to-exclude: "! -path \"./vendor/*\" ! -path \"./customer/folder/excluded/*\"" ``` The action ignores the folder `vendor` at root of project by default.