-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 216534e
Showing
4 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM php:7.3-cli | ||
|
||
LABEL "com.github.actions.name"="PHP Syntax checker" | ||
LABEL "com.github.actions.description"="Run PHP Syntax checker (php -l)" | ||
LABEL "com.github.actions.icon"="eye" | ||
LABEL "com.github.actions.color"="gray-dark" | ||
|
||
LABEL version="7.3" | ||
LABEL repository="https://github.com/StephaneBour/actions-php-lint" | ||
LABEL homepage="https://github.com/StephaneBour/actions-php-lint" | ||
LABEL maintainer="Stéphane Bour <[email protected]>" | ||
|
||
COPY "entrypoint.sh" "/entrypoint.sh" | ||
|
||
RUN chmod +x /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# PHP Syntax checker (lint) action | ||
|
||
This action controls the syntax of php files in a folder, excluding the vendor folder. | ||
|
||
## Inputs | ||
|
||
### `dir` | ||
|
||
The folder to control. Default `"."`. | ||
|
||
## Example usage | ||
|
||
```yaml | ||
uses: StephaneBour/[email protected] | ||
with: | ||
dir: './src' | ||
``` | ||
## Change PHP Version | ||
You can use : | ||
``` | ||
StephaneBour/[email protected] | ||
StephaneBour/[email protected] | ||
StephaneBour/[email protected] | ||
StephaneBour/[email protected] | ||
StephaneBour/[email protected] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: 'PHP Syntax Checker (Lint)' | ||
description: 'php syntax control (php -l)' | ||
inputs: | ||
dir: | ||
description: 'Folder to check syntax' | ||
required: false | ||
default: '.' | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
args: | ||
- ${{ inputs.dir }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
PHP_FULL_VERSION=$(php -r 'echo phpversion();') | ||
|
||
if [ -z "$1" ]; then | ||
DIR_TO_SCAN="." | ||
else | ||
DIR_TO_SCAN="$1" | ||
fi | ||
|
||
echo "## Running PHP Syntax Checker (lint) on ${DIR_TO_SCAN}" | ||
echo "PHP Version : ${PHP_FULL_VERSION}" | ||
|
||
if [ ! -d "${DIR_TO_SCAN}" ] && [ ! -f "${DIR_TO_SCAN}" ]; then | ||
echo "\nInvalid directory or file: ${DIR_TO_SCAN}" | ||
echo "\n\n" | ||
|
||
exit 2 | ||
fi | ||
|
||
ERROR=0 | ||
for file in $(find ${DIR_TO_SCAN} -type f -name "*.php" ! -path "./vendor/*"); do | ||
RESULTS=$(php -l ${file} || true) | ||
|
||
if [ "${RESULTS}" != "No syntax errors detected in ${file}" ]; then | ||
echo "\n${RESULTS}\n" | ||
ERROR=1 | ||
fi | ||
done | ||
|
||
exit "${ERROR}" |