I have a target set up in ant which runs a PHP lint check on all modified files since the last check.
<target
name="lint"
unless="lint.done">
<apply executable="php" taskname="lint" failonerror="true">
<arg value="-l">
<fileset dir="...">
<include name="**/*.php">
<modified/>
</fileset>
</apply>
</target>
Unfortunately, if this fails due to a single file failing the lint check, all other files will not be lint checked but will still be stored in the modified cache. The file which caused the fail will also be cached by modified
This means the next time this runs, the check will pass, even if no changes were made to address why the lint check failed.
In the end, if a lint error does occur, the build should fail. The hard part is trying to get it to fail and not halt before it has finished linting.
The solutions would be to implement the following:
- If the check fails, don't update the modified cache.
- If the check fails on one file, continue linting other files, but still mark the build as a failure.
Are either / both of these solutions possible?
For this first point, I know you can pass an argument to modified
which stops the cache being updated. Could you then call a second modified
after the lint check to only cache the files if the check was successful?
For the second point, the main way I can think of is to not fail on lint error, but to pass the lint results into a script which would check and output all failed files at once if it needed to.