The syntaxchecks are for PHP, Python, Ruby, Yaml and Crontab files. It is easy to use and implement into continuous integration tools like Jenkins, Bamboo and Bitbucket Pipeline.
- Git >= 1.7
- PHP >= 5.6
- Python >= 2.7.12
- Ruby >= 2.3.1
# Installation on Debian/Ubuntu
sudo apt install git php-cli python ruby
- Bash
- PHP
- Python
- Ruby
- YAML
- Crontabs
Parameter | Description | Example |
---|---|---|
-p | Path to the project | -p "/tmp/project" |
-s | Enable strict mode (Default: off) | -s |
-a | Check all files in path | -a |
-c | Check files in last commits | -c 1 |
-r | Overwrite exclude regex | -r "^./vendor/.$" |
# Check all files in project
./syntaxchecks.sh -p "/tmp/project" -a
# Check all files in project and stop at the first error
./syntaxchecks.sh -p "/tmp/project" -a -s
# Check all files in the last 5 commits of the project and stop at the first error
./syntaxchecks.sh -p "/tmp/project" -c 5 -s
.PHONY: syntaxcheck
syntaxcheck:
@echo "==> Syntaxcheck started"
wget https://github.com/neikei/syntaxchecks/archive/master.zip
unzip master.zip && rm master.zip
syntaxchecks-master/syntaxchecks.sh -p "`pwd`" -a -s
rm -rf syntaxchecks-master
@echo -e "==> Syntaxcheck finished\n"
# Install syntaxchecks in the home path of the jenkins application user
su - jenkins
cd ~
git clone https://github.com/neikei/syntaxchecks.git
# Build step to execute the syntaxchecks with Jenkins
~/syntaxchecks/syntaxchecks.sh -p "`pwd`" -c 1 -s
# Install syntaxchecks in the home path of the bamboo application user
su - bamboo
cd ~
git clone https://github.com/neikei/syntaxchecks.git
# Build step to execute the syntaxchecks with Bamboo
~/syntaxchecks/syntaxchecks.sh -p "${bamboo.build.working.directory}" -c 1 -s
image: php:7.1.1
pipelines:
default:
- step:
script:
- apt-get update && apt-get install -y unzip wget git php-cli python ruby
- wget https://github.com/neikei/syntaxchecks/archive/master.zip
- unzip master.zip && rm master.zip
- syntaxchecks-master/syntaxchecks.sh -p "`pwd`" -c 1 -s
- rm -rf syntaxchecks-master
script:
- wget https://github.com/neikei/syntaxchecks/archive/master.zip
- unzip master.zip && rm master.zip
- syntaxchecks-master/syntaxchecks.sh -p "`pwd`" -a -s
# find files for syntaxchecks
regex_bash_files="^.*\.sh$"
regex_php_files="^.*\.(php|php.skel|php.skel.*)$"
regex_yaml_files="^.*\.(yaml|yml)$"
regex_python_files="^.*\.py$"
regex_ruby_files="^.*(\.rb|Vagrantfile)$"
regex_crontab_files="^.*\.cron$"
# exclude vendor and cache directories
regex_exclude="^.*/(vendor|cache)/.*$"
- chkcrontab - Modified to check crontabs without defiened user.
Example crontab format:
# m h dom mon dow command
0 5 * * 1 echo "Hello world!"