Difference between revisions of "Continuous Integration"

From OpenEMR Project Wiki
(usage documentation)
(Simplifying CI local execution explanations using the updated ci.sh)
Line 1: Line 1:
When code is pushed your Github pull request, our [https://travis-ci.org/openemr/openemr Continuous Integration service] will check for programmer errors from PHP v5.6 up to PHP v7.1. Make sure the service status is green and not red!
When code is pushed your Github pull request, our [https://travis-ci.org/openemr/openemr Continuous Integration service] will check for programmer errors from PHP v5.6 up to PHP v7.1. Make sure the service status is green and not red!


Here's how to run the checks locally (these are for Linux/Mac environments):
== Running Locally ==
The following sections provide instruction for Linux/OSX/WSL users who may want to run the CI commands locally. Doing this will help you to make sure you'll pass CI checks before committing/pushing your code. For all of the following, replace <code><openemrRoot></code> with the root directory of the project on your machine.
=== Linting Check (All) ===


== Linting Check (All) ==
<pre>
CI_JOB=lint_syntax ci/ci.php -d <openemrRoot>
</pre>
 
=== Linting Check (One File) ===


<pre>
<pre>
find . -type d \( -path ./vendor \
php -l <file>
                  -o -path ./interface/main/calendar/modules \
                  -o -path ./interface/reports \
                  -o -path ./contrib/util \
                  -o -path ./library/html2pdf/vendor/tecnickcom \
                  -o -path ./library/classes/fpdf \
                  -o -path ./library/html2pdf \
                  -o -path ./gacl \
                  -o -path ./library/edihistory \) -prune -o \
      -name "*.php" -print0 | xargs -0 -n1 -P8 php -l
</pre>
</pre>


== Linting Check (One File) ==
=== Styling Check (Checking your changed files) ===


This will check your staged files (files you've used <code>git add</code> on):
<pre>
<pre>
php -l services/PatientService.php
CI_JOB=lint_style_staged ci/ci.php -d <openemrRoot>
</pre>
</pre>


== Styling Check (All) ==
This will check a commit before you push it:
 
<pre>
<pre>
curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
CI_JOB=lint_style_new_commit ci/ci.php -d <openemrRoot>
php phpcs.phar -pn --extensions=php,inc --standard=ci/phpcs.xml --report=summary .
</pre>
</pre>


== Styling Check (One File) ==
=== Styling Check (One File) ===


<pre>
<pre>
curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
php phpcs.phar -pn --extensions=php,inc --standard=ci/phpcs.xml --report=summary services/PatientService.php
php phpcs.phar -pn --extensions=php,inc --standard=ci/phpcs_strict.xml --report=summary <file>
</pre>
</pre>


(Make sure you don't check in the phpcs.phar)
(Make sure you don't check in the phpcs.phar)

Revision as of 22:44, 16 July 2017

When code is pushed your Github pull request, our Continuous Integration service will check for programmer errors from PHP v5.6 up to PHP v7.1. Make sure the service status is green and not red!

Running Locally

The following sections provide instruction for Linux/OSX/WSL users who may want to run the CI commands locally. Doing this will help you to make sure you'll pass CI checks before committing/pushing your code. For all of the following, replace <openemrRoot> with the root directory of the project on your machine.

Linting Check (All)

CI_JOB=lint_syntax ci/ci.php -d <openemrRoot>

Linting Check (One File)

php -l <file>

Styling Check (Checking your changed files)

This will check your staged files (files you've used git add on):

CI_JOB=lint_style_staged ci/ci.php -d <openemrRoot>

This will check a commit before you push it:

CI_JOB=lint_style_new_commit ci/ci.php -d <openemrRoot>

Styling Check (One File)

curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
php phpcs.phar -pn --extensions=php,inc --standard=ci/phpcs_strict.xml --report=summary <file>

(Make sure you don't check in the phpcs.phar)