GithubHelp home page GithubHelp logo

eugenganshorn / syntaxchecks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from neikei/syntaxchecks

0.0 2.0 0.0 37 KB

Syntaxchecks for Bash, PHP, Python, Ruby, Yaml and Crontab files. Ready to use with Jenkins, Bamboo and Bitbucket Pipelines.

License: GNU General Public License v3.0

Python 88.95% Shell 11.05%

syntaxchecks's Introduction

Syntaxchecks

Introduction

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.

Requirements

  • 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

Implemented checks

  • Bash
  • PHP
  • Python
  • Ruby
  • YAML
  • Crontabs

Parameter

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

Usage

Manual execution

# 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

Makefile

.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"

Jenkins

# 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

Bamboo

# 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

Bitbucket Pipelines

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

Regular expressions

# 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)/.*$"

Third party software

  • chkcrontab - Modified to check crontabs without defiened user.

Example crontab format:

# m h  dom mon dow   command
0 5 * * 1 echo "Hello world!"

syntaxchecks's People

Contributors

neikei avatar

Watchers

James Cloos avatar Eugen Ganshorn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.