Add a Laravel 5.5 skeleton
This commit is contained in:
parent
8e132c1633
commit
325f09ec29
7 changed files with 424 additions and 2 deletions
17
README.md
17
README.md
|
@ -12,8 +12,9 @@ Most of the configuration should be available in the inventory.
|
|||
|
||||
It is launched usually like this : `ansible-playbook site.yml`
|
||||
|
||||
## Prerequisite
|
||||
## Prerequisites
|
||||
|
||||
### Prerequisites for the Jenkins hosts
|
||||
Hosts should be accessible via SSH as the root user (else, add the usual
|
||||
`remote_user`/`become` instructions in ansible.cfg) and with the Python
|
||||
prerequisite of Ansible (usually `python-minimal`).
|
||||
|
@ -26,6 +27,18 @@ ansible foo.bar.com -m ping
|
|||
ansible-playbook -l foo.bar.com -v -C -D site.yml
|
||||
```
|
||||
|
||||
### Prerequisites for the repositories
|
||||
None at the moment : this playbook will not configure Gitea or anything
|
||||
else outside Jenkins. The webhooks and the access to allow Jenkins to
|
||||
clone/pull the repositories are to be done manually (a recap will be
|
||||
displayed at the end of the playbook).
|
||||
|
||||
### Prerequisites for the projects
|
||||
Nothing mandatory except the [`build.xml`](http://jenkins-php.org/automation.html)
|
||||
file at the root of each project.
|
||||
|
||||
See examples in the `roles/jenkins-php-v1/files/skeletons/' directory.
|
||||
|
||||
## Directory layout
|
||||
|
||||
We follow (more or less) the recommendations of
|
||||
|
@ -51,4 +64,4 @@ adapt.
|
|||
|
||||
## License
|
||||
|
||||
[CC-BY-SA 3.0](http://creativecommons.org/licenses/by-sa/3.0/) like http://jenkins-php.org/
|
||||
[CC-BY-SA 3.0](http://creativecommons.org/licenses/by-sa/3.0/) like http://jenkins-php.org/ by [Sebastian Bergmann](http://sebastian-bergmann.de/) and his contributors.
|
||||
|
|
272
roles/jenkins-php-v1/files/skeletons/laravel5.5/build.xml
Normal file
272
roles/jenkins-php-v1/files/skeletons/laravel5.5/build.xml
Normal file
|
@ -0,0 +1,272 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="name-of-project" default="full-build">
|
||||
<!-- By default, we assume all tools to be on the $PATH -->
|
||||
<property name="pdepend" value="pdepend"/>
|
||||
<property name="phpcpd" value="phpcpd"/>
|
||||
<property name="phpcs" value="phpcs"/>
|
||||
<property name="phpdox" value="phpdox"/>
|
||||
<property name="phploc" value="phploc"/>
|
||||
<property name="phpmd" value="phpmd"/>
|
||||
<!-- <property name="phpunit" value="phpunit"/> -->
|
||||
<property name="phpunit" value="${basedir}/vendor/bin/phpunit"/>
|
||||
|
||||
<!-- Use this when the tools are located as PHARs in ${basedir}/build/tools
|
||||
<property name="pdepend" value="${basedir}/build/tools/pdepend.phar"/>
|
||||
<property name="phpcpd" value="${basedir}/build/tools/phpcpd.phar"/>
|
||||
<property name="phpcs" value="${basedir}/build/tools/phpcs.phar"/>
|
||||
<property name="phpdox" value="${basedir}/build/tools/phpdox.phar"/>
|
||||
<property name="phploc" value="${basedir}/build/tools/phploc.phar"/>
|
||||
<property name="phpmd" value="${basedir}/build/tools/phpmd.phar"/>
|
||||
<property name="phpunit" value="${basedir}/build/tools/phpunit.phar"/> -->
|
||||
|
||||
<!-- Use this when the tools are managed by Composer in ${basedir}/vendor/bin
|
||||
<property name="pdepend" value="${basedir}/vendor/bin/pdepend"/>
|
||||
<property name="phpcpd" value="${basedir}/vendor/bin/phpcpd"/>
|
||||
<property name="phpcs" value="${basedir}/vendor/bin/phpcs"/>
|
||||
<property name="phpdox" value="${basedir}/vendor/bin/phpdox"/>
|
||||
<property name="phploc" value="${basedir}/vendor/bin/phploc"/>
|
||||
<property name="phpmd" value="${basedir}/vendor/bin/phpmd"/>
|
||||
<property name="phpunit" value="${basedir}/vendor/bin/phpunit"/> -->
|
||||
|
||||
<target name="full-build"
|
||||
depends="prepare,static-analysis,phpunit,phpdox,-check-failure"
|
||||
description="Performs static analysis, runs the tests, and generates project documentation"/>
|
||||
|
||||
<target name="full-build-parallel"
|
||||
depends="prepare,static-analysis-parallel,phpunit,phpdox,-check-failure"
|
||||
description="Performs static analysis (executing the tools in parallel), runs the tests, and generates project documentation"/>
|
||||
|
||||
<target name="quick-build"
|
||||
depends="prepare,lint,phpunit-no-coverage"
|
||||
description="Performs a lint check and runs the tests (without generating code coverage reports)"/>
|
||||
|
||||
<target name="static-analysis"
|
||||
depends="lint,phploc-ci,pdepend,phpmd-ci,phpcs-ci,phpcpd-ci"
|
||||
description="Performs static analysis" />
|
||||
|
||||
<!-- Adjust the threadCount attribute's value to the number of CPUs -->
|
||||
<target name="static-analysis-parallel"
|
||||
description="Performs static analysis (executing the tools in parallel)">
|
||||
<parallel threadCount="2">
|
||||
<sequential>
|
||||
<antcall target="pdepend"/>
|
||||
<antcall target="phpmd-ci"/>
|
||||
</sequential>
|
||||
<antcall target="lint"/>
|
||||
<antcall target="phpcpd-ci"/>
|
||||
<antcall target="phpcs-ci"/>
|
||||
<antcall target="phploc-ci"/>
|
||||
</parallel>
|
||||
</target>
|
||||
|
||||
<target name="clean"
|
||||
unless="clean.done"
|
||||
description="Cleanup build artifacts">
|
||||
<delete dir="${basedir}/build/api"/>
|
||||
<delete dir="${basedir}/build/coverage"/>
|
||||
<delete dir="${basedir}/build/logs"/>
|
||||
<delete dir="${basedir}/build/pdepend"/>
|
||||
<delete dir="${basedir}/build/phpdox"/>
|
||||
<property name="clean.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="prepare"
|
||||
unless="prepare.done"
|
||||
depends="clean"
|
||||
description="Prepare for build">
|
||||
<mkdir dir="${basedir}/build/api"/>
|
||||
<mkdir dir="${basedir}/build/coverage"/>
|
||||
<mkdir dir="${basedir}/build/logs"/>
|
||||
<mkdir dir="${basedir}/build/pdepend"/>
|
||||
<mkdir dir="${basedir}/build/phpdox"/>
|
||||
<property name="prepare.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="lint"
|
||||
unless="lint.done"
|
||||
description="Perform syntax check of sourcecode files">
|
||||
<apply executable="php" taskname="lint">
|
||||
<arg value="-l" />
|
||||
|
||||
<fileset dir="${basedir}/src">
|
||||
<include name="**/*.php" />
|
||||
<modified />
|
||||
</fileset>
|
||||
|
||||
<fileset dir="${basedir}/tests">
|
||||
<include name="**/*.php" />
|
||||
<modified />
|
||||
</fileset>
|
||||
</apply>
|
||||
|
||||
<property name="lint.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="phploc"
|
||||
unless="phploc.done"
|
||||
description="Measure project size using PHPLOC and print human readable output. Intended for usage on the command line.">
|
||||
<exec executable="${phploc}" taskname="phploc">
|
||||
<arg value="--count-tests" />
|
||||
<arg path="${basedir}/src" />
|
||||
<arg path="${basedir}/tests" />
|
||||
</exec>
|
||||
|
||||
<property name="phploc.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="phploc-ci"
|
||||
unless="phploc.done"
|
||||
depends="prepare"
|
||||
description="Measure project size using PHPLOC and log result in CSV and XML format. Intended for usage within a continuous integration environment.">
|
||||
<exec executable="${phploc}" taskname="phploc">
|
||||
<arg value="--count-tests" />
|
||||
<arg value="--log-csv" />
|
||||
<arg path="${basedir}/build/logs/phploc.csv" />
|
||||
<arg value="--log-xml" />
|
||||
<arg path="${basedir}/build/logs/phploc.xml" />
|
||||
<arg path="${basedir}/src" />
|
||||
<arg path="${basedir}/tests" />
|
||||
</exec>
|
||||
|
||||
<property name="phploc.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="pdepend"
|
||||
unless="pdepend.done"
|
||||
depends="prepare"
|
||||
description="Calculate software metrics using PHP_Depend and log result in XML format. Intended for usage within a continuous integration environment.">
|
||||
<exec executable="${pdepend}" taskname="pdepend">
|
||||
<arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
|
||||
<arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
|
||||
<arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
|
||||
<arg path="${basedir}/src" />
|
||||
</exec>
|
||||
|
||||
<property name="pdepend.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="phpmd"
|
||||
unless="phpmd.done"
|
||||
description="Perform project mess detection using PHPMD and print human readable output. Intended for usage on the command line before committing.">
|
||||
<exec executable="${phpmd}" taskname="phpmd">
|
||||
<arg path="${basedir}/src" />
|
||||
<arg value="text" />
|
||||
<arg path="${basedir}/build/phpmd.xml" />
|
||||
</exec>
|
||||
|
||||
<property name="phpmd.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="phpmd-ci"
|
||||
unless="phpmd.done"
|
||||
depends="prepare"
|
||||
description="Perform project mess detection using PHPMD and log result in XML format. Intended for usage within a continuous integration environment.">
|
||||
<exec executable="${phpmd}" taskname="phpmd">
|
||||
<arg path="${basedir}/src" />
|
||||
<arg value="xml" />
|
||||
<arg path="${basedir}/build/phpmd.xml" />
|
||||
<arg value="--reportfile" />
|
||||
<arg path="${basedir}/build/logs/pmd.xml" />
|
||||
</exec>
|
||||
|
||||
<property name="phpmd.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="phpcs"
|
||||
unless="phpcs.done"
|
||||
description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
|
||||
<exec executable="${phpcs}" taskname="phpcs">
|
||||
<arg value="--standard=PSR2" />
|
||||
<arg value="--extensions=php" />
|
||||
<arg value="--ignore=autoload.php" />
|
||||
<arg path="${basedir}/src" />
|
||||
<arg path="${basedir}/tests" />
|
||||
</exec>
|
||||
|
||||
<property name="phpcs.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="phpcs-ci"
|
||||
unless="phpcs.done"
|
||||
depends="prepare"
|
||||
description="Find coding standard violations using PHP_CodeSniffer and log result in XML format. Intended for usage within a continuous integration environment.">
|
||||
<exec executable="${phpcs}" output="/dev/null" taskname="phpcs">
|
||||
<arg value="--report=checkstyle" />
|
||||
<arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
|
||||
<arg value="--standard=PSR2" />
|
||||
<arg value="--extensions=php" />
|
||||
<arg value="--ignore=autoload.php" />
|
||||
<arg path="${basedir}/src" />
|
||||
<arg path="${basedir}/tests" />
|
||||
</exec>
|
||||
|
||||
<property name="phpcs.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="phpcpd"
|
||||
unless="phpcpd.done"
|
||||
description="Find duplicate code using PHPCPD and print human readable output. Intended for usage on the command line before committing.">
|
||||
<exec executable="${phpcpd}" taskname="phpcpd">
|
||||
<arg path="${basedir}/src" />
|
||||
</exec>
|
||||
|
||||
<property name="phpcpd.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="phpcpd-ci"
|
||||
unless="phpcpd.done"
|
||||
depends="prepare"
|
||||
description="Find duplicate code using PHPCPD and log result in XML format. Intended for usage within a continuous integration environment.">
|
||||
<exec executable="${phpcpd}" taskname="phpcpd">
|
||||
<arg value="--log-pmd" />
|
||||
<arg path="${basedir}/build/logs/pmd-cpd.xml" />
|
||||
<arg path="${basedir}/src" />
|
||||
</exec>
|
||||
|
||||
<property name="phpcpd.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="phpunit"
|
||||
unless="phpunit.done"
|
||||
depends="prepare"
|
||||
description="Run unit tests with PHPUnit">
|
||||
<exec executable="${phpunit}" resultproperty="result.phpunit" taskname="phpunit">
|
||||
<arg value="--configuration"/>
|
||||
<arg path="${basedir}/build/phpunit.xml"/>
|
||||
</exec>
|
||||
|
||||
<property name="phpunit.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="phpunit-no-coverage"
|
||||
unless="phpunit.done"
|
||||
depends="prepare"
|
||||
description="Run unit tests with PHPUnit (without generating code coverage reports)">
|
||||
<exec executable="${phpunit}" failonerror="true" taskname="phpunit">
|
||||
<arg value="--configuration"/>
|
||||
<arg path="${basedir}/build/phpunit.xml"/>
|
||||
<arg value="--no-coverage"/>
|
||||
</exec>
|
||||
|
||||
<property name="phpunit.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="phpdox"
|
||||
unless="phpdox.done"
|
||||
depends="phploc-ci,phpcs-ci,phpmd-ci"
|
||||
description="Generate project documentation using phpDox">
|
||||
<exec executable="${phpdox}" dir="${basedir}/build" taskname="phpdox"/>
|
||||
|
||||
<property name="phpdox.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="-check-failure">
|
||||
<fail message="PHPUnit did not finish successfully">
|
||||
<condition>
|
||||
<not>
|
||||
<equals arg1="${result.phpunit}" arg2="0"/>
|
||||
</not>
|
||||
</condition>
|
||||
</fail>
|
||||
</target>
|
||||
</project>
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0"?>
|
||||
<ruleset name="PSR2">
|
||||
<description>The PSR2 coding standard.</description>
|
||||
<rule ref="PSR2"/>
|
||||
<file>../app/</file>
|
||||
<exclude-pattern>vendor</exclude-pattern>
|
||||
<exclude-pattern>resources</exclude-pattern>
|
||||
<exclude-pattern>database/</exclude-pattern>
|
||||
<exclude-pattern>storage/</exclude-pattern>
|
||||
<exclude-pattern>node_modules/</exclude-pattern>
|
||||
</ruleset>
|
|
@ -0,0 +1,13 @@
|
|||
<phpdox xmlns="http://xml.phpdox.net/config">
|
||||
<project name="webcollek" source="../app" workdir="phpdox">
|
||||
<collector publiconly="false">
|
||||
<include mask="*.php" />
|
||||
</collector>
|
||||
|
||||
<generator output="build">
|
||||
<build engine="html" enabled="true" output="../api">
|
||||
<file extension="html" />
|
||||
</build>
|
||||
</generator>
|
||||
</project>
|
||||
</phpdox>
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0"?>
|
||||
<ruleset name="My first PHPMD rule set"
|
||||
xmlns="http://pmd.sf.net/ruleset/1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
|
||||
http://pmd.sf.net/ruleset_xml_schema.xsd"
|
||||
xsi:noNamespaceSchemaLocation="
|
||||
http://pmd.sf.net/ruleset_xml_schema.xsd">
|
||||
<description>
|
||||
My custom rule set that checks my code...
|
||||
</description>
|
||||
|
||||
<!-- Import the entire unused code rule set -->
|
||||
<rule ref="rulesets/unusedcode.xml" />
|
||||
|
||||
<!-- Import the entire cyclomatic complexity rule -->
|
||||
<rule ref="rulesets/codesize.xml/CyclomaticComplexity" />
|
||||
</ruleset>
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="../vendor/autoload.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false">
|
||||
<testsuites>
|
||||
<testsuite name="Feature">
|
||||
<directory suffix="Test.php">../tests/Feature</directory>
|
||||
</testsuite>
|
||||
|
||||
<testsuite name="Unit">
|
||||
<directory suffix="Test.php">../tests/Unit</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">../app</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<php>
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
<env name="CACHE_DRIVER" value="array"/>
|
||||
<env name="SESSION_DRIVER" value="array"/>
|
||||
<env name="QUEUE_DRIVER" value="sync"/>
|
||||
</php>
|
||||
<logging>
|
||||
<log type="coverage-html" target="./coverage"/>
|
||||
<log type="coverage-clover" target="./logs/clover.xml"/>
|
||||
<log type="coverage-crap4j" target="./logs/crap4j.xml"/>
|
||||
<log type="junit" target="./logs/junit.xml" logIncompleteSkipped="false"/>
|
||||
</logging>
|
||||
</phpunit>
|
58
roles/jenkins-php-v1/files/skeletons/laravel5.5/git_hooks_pre-commit
Executable file
58
roles/jenkins-php-v1/files/skeletons/laravel5.5/git_hooks_pre-commit
Executable file
|
@ -0,0 +1,58 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed.
|
||||
# Called by "git commit" with no arguments. The hook should
|
||||
# exit with non-zero status after issuing an appropriate message if
|
||||
# it wants to stop the commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-commit".
|
||||
|
||||
if git rev-parse --verify HEAD >/dev/null 2>&1
|
||||
then
|
||||
against=HEAD
|
||||
else
|
||||
# Initial commit: diff against an empty tree object
|
||||
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
||||
fi
|
||||
|
||||
# If you want to allow non-ASCII filenames set this variable to true.
|
||||
allownonascii=$(git config --bool hooks.allownonascii)
|
||||
|
||||
# Redirect output to stderr.
|
||||
exec 1>&2
|
||||
|
||||
# Cross platform projects tend to avoid non-ASCII filenames; prevent
|
||||
# them from being added to the repository. We exploit the fact that the
|
||||
# printable range starts at the space character and ends with tilde.
|
||||
if [ "$allownonascii" != "true" ] &&
|
||||
# Note that the use of brackets around a tr range is ok here, (it's
|
||||
# even required, for portability to Solaris 10's /usr/bin/tr), since
|
||||
# the square bracket bytes happen to fall in the designated range.
|
||||
test $(git diff --cached --name-only --diff-filter=A -z $against |
|
||||
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
|
||||
then
|
||||
cat <<\EOF
|
||||
Error: Attempt to add a non-ASCII file name.
|
||||
|
||||
This can cause problems if you want to work with people on other platforms.
|
||||
|
||||
To be portable it is advisable to rename the file.
|
||||
|
||||
If you know what you are doing you can disable this check using:
|
||||
|
||||
git config hooks.allownonascii true
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Stop at any uncatched non-zero status
|
||||
set -e
|
||||
|
||||
# If there are whitespace errors, print the offending file names and fail.
|
||||
git diff-index --check --cached $against --
|
||||
|
||||
# PHP checks
|
||||
echo "Checking PHP syntax (linting)..."
|
||||
git diff-index --diff-filter=ACMRT --cached --name-only HEAD -- | egrep '\.php$|\.inc$' | xargs --no-run-if-empty -d "\n" -n 1 php -l
|
||||
echo "Checking PHP CodeStyle..."
|
||||
git diff-index --diff-filter=ACMRT --cached --name-only HEAD -- | egrep '\.php$|\.inc$' | xargs --no-run-if-empty -d "\n" phpcs --standard=build/phpcs.xml --extensions=php --ignore=autoload.php --ignore=bootstrap/cache/
|
Reference in a new issue