In PHP there are some standard tools to check.
- Codestyle
- Dependencies
- Complexity
- Syntaxerrors
and many more issues.
Its very handy to use tools like ant, to wrap up this QA tools. So you can automate the code review process and run this tool against your codebase.
Once you have ant installed, you can add a build.xml definition to your project. This definition orchestrates the single phptools to inspect your code and create docs. This tasks are called "Ant-Tasks"
After you have setup your build.xml you can simly start ant to run all tests.
Later you can add this ant tasks to your jenkins buildsystem to check every releaseversion for issues in quality.
Lets start.
Prerequisits
We need some things installed on the local machine.- ant
- composer
Create a testproject
I have created a small testproject with just 1 class and 1 testclass in it.But that's okay to demonstrate the case. If you take a look in the composer.json, you will see, that all buildtools will be installed during build. So you dont need to install any tool, except ant
Just clone the project:
git clone https://github.com/pboethig/testPHPProject.git
Create your build definition
We want to create a single task for each testing tool in our defintion.Additionalyl we have to prepare the buildfolder-structure and setup the project with this build definition.
Her is mine. It lives directly in the project root.
As you can see, there is a task named "<target>" for each tool which gets run on the codebase in the src folder.
The single targets gets run by the 2 targets TEST and REPORT. Later your will start the REPORT TASK via ant in the console. This will automaticly start the TEST target, so that single targets can be executed.
My build.xml from the projectroot
Start your local build
After you have installed the tools and configured your build tasks to run that tools on your codebaseOpen a terminal in your projectroot and run:
ant init
If you want to start a release build you simply can run:
After that you can see the results on the console and in the "build/logs" folder.
ant init package -DTAG_TO_BUILD=1.0.1
This will create a release packagein folder "release"
You can use this project-skelleton in jenkins buildjobs too.
For better understanding of the testresults it good to read the documentation of the tools.
Keine Kommentare:
Kommentar veröffentlichen