Skip to content
Permalink
Browse files

Add phpsqllint for check sql queries

  • Loading branch information
4144 committed Nov 18, 2019
1 parent 61e6b22 commit 05ea79929aa099d25b543f4a86db721f5f7e700e
@@ -38,6 +38,14 @@ matrix:
- env: ignore=this
- compiler: false
include:
- language: php
env: sqlcheck=true
script:
- travis_retry composer self-update
- cd tools/php-sqllint
- travis_retry composer install --no-interaction --prefer-source
- cd ../..
- ./tools/checksql.sh
- compiler: gcc
env: LDFLAGS="-fuse-ld=gold" CONFIGURE_FLAGS="--enable-debug CC=gcc-6 --disable-manager --enable-Werror --enable-packetver=20191113 --enable-packetver-re --enable-buildbot" HPM="1"
addons:
@@ -0,0 +1,13 @@
#!/bin/bash

function checkdir {
for sql in $1/*.sql
do
echo "checking ${sql}"
php -d memory_limit=4G ./tools/php-sqllint/bin/php-sqllint "${sql}" || exit 1
done
}

checkdir "sql-files"
checkdir "sql-files/upgrades"
checkdir "sql-files/tools"
@@ -0,0 +1,31 @@
#!/usr/bin/env php
<?php
/**
* SQL linter (syntax checker) written in PHP
*
* PHP version 5
*
* @category Tools
* @package PHP-SQLlint
* @author Christian Weiske <cweiske@cweiske.de>
* @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
* @link http://cweiske.de/php-sqllint.htm
*/
namespace phpsqllint;
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
//local git checkout
include_once __DIR__ . '/../vendor/autoload.php';
} else if (file_exists('vendor/autoload.php')) {
//dependency composer installation
include_once 'vendor/autoload.php';
}
if (file_exists(__DIR__ . '/../src/phpsqllint/Autoloader.php')) {
include_once __DIR__ . '/../src/phpsqllint/Autoloader.php';
Autoloader::register();
}
$cli = new Cli();
$cli->run();
?>
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="utf-8"?>
<project name="php-sqllint" default="phar" basedir=".">

<!--<property name="version" value="dev" />-->
<loadfile property="version" file="VERSION">
<filterchain>
<striplinebreaks />
</filterchain>
</loadfile>

<property name="pharfile" value="${phing.dir}/dist/${phing.project.name}-${version}.phar" />
<property name="pharfilebz2" value="${phing.dir}/dist/${phing.project.name}-${version}.bz2.phar" />
<property name="libdir" value="${phing.dir}/lib"/>

<fileset id="fs.phar" dir="${phing.dir}">
<include name="bin/**"/>
<include name="lib/**"/>
<include name="src/**"/>

<include name="README.rst"/>
<include name="VERSION"/>

<include name="vendor/autoload.php"/>
<include name="vendor/composer/*.php"/>
<include name="vendor/pear/console_commandline/Console/**"/>
<include name="vendor/pear/pear_exception/PEAR/**"/>
<include name="vendor/phpmyadmin/sql-parser/src/**"/>
</fileset>


<typedef name="pearPackageFileSet" classname="phing.types.PearPackageFileSet" />

<target name="phar" depends="collectdeps"
description="Create zip file for release"
>
<!-- strip the shebang from bin script -->
<copy file="${phing.dir}/bin/php-sqllint" tofile="${phing.dir}/bin/phar-php-sqllint.php">
<filterchain>
<striplinecomments>
<comment value="#" />
</striplinecomments>
</filterchain>
</copy>

<mkdir dir="${phing.dir}/dist"/>
<delete file="${pharfile}"/>
<pharpackage basedir="${phing.dir}"
destfile="${pharfile}"
stub="${phing.dir}/src/stub-phar.php"
alias="php-sqllint.phar"
compression="none"
>
<fileset refid="fs.phar"/>
</pharpackage>

<pharpackage basedir="${phing.dir}"
destfile="${pharfilebz2}"
stub="${phing.dir}/src/stub-phar.php"
alias="php-sqllint.phar"
compression="bzip2"
>
<fileset refid="fs.phar"/>
</pharpackage>

<exec executable="chmod">
<arg value="+x"/>
<arg value="${pharfile}"/>
<arg value="${pharfilebz2}"/>
</exec>
</target>


<target name="collectdeps" description="Copy package dependencies to lib/">
<exec command="composer install"/>
<!--
<delete dir="${libdir}"/>
<mkdir dir="${libdir}"/>
<pearPackageFileset id="dep-Console_CommandLine" package="pear.php.net/Console_CommandLine"/>
<pearPackageFileset id="dep-PEAR" package="pear.php.net/PEAR">
<include name="PEAR/Exception.php"/>
</pearPackageFileset>
<copy todir="${libdir}">
<fileset refid="dep-Console_CommandLine"/>
<fileset refid="dep-PEAR"/>
</copy>
-->
</target>


<target name="docs" description="render documentation">
<rst file="README.rst"/>
</target>

<target name="update-website" depends="docs">
<exec command="xmlstarlet sel -t -c '/_:html/_:body/_:div' README.html
| xmllint --format -
|grep -v '?xml version'
> ~/Dev/html/cweiske.de/www/php-sqllint.htm"/>
</target>

</project>
@@ -0,0 +1,22 @@
{
"name": "cweiske/php-sqllint",
"description": "Command line tool to validate (syntax check) SQL files",
"type": "project",
"bin": ["bin/php-sqllint"],
"require": {
"phpmyadmin/sql-parser": "^4.1.1",
"pear/console_commandline": "^1.2"
},
"homepage": "http://cweiske.de/php-sqllint.htm",
"license": "AGPL-3.0",
"authors": [
{
"name": "Christian Weiske",
"email": "cweiske@cweiske.de",
"homepage": "http://cweiske.de/"
}
],
"support": {
"issues": "https://github.com/cweiske/php-sqllint/issues"
}
}

Some generated files are not rendered by default. Learn more.

0 comments on commit 05ea799

Please sign in to comment.
You can’t perform that action at this time.