Simple way to test your ext on TravisCI

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
nickvergessen
Former Team Member
Posts: 4397
Joined: Mon Apr 30, 2007 5:33 pm
Location: Stuttgart, Germany
Name: Joas Schilling
Contact:

Simple way to test your ext on TravisCI

Post by nickvergessen » Tue Apr 22, 2014 12:45 am

****************************************************************

UPDATE :: This post is out of date!

View phpBB's official documentation here:

Continuous Integration With Travis CI

Thank you, The Extension Development Team

****************************************************************


Source Acme/Demo :: Wiki :: How to test your extension with phpunit and TravisCI
  1. Go to Travis Accounts, Sync the list of repositories, Enable your extensions repository
  2. Copy the following files to your extension:
    • travis/prepare-phpbb.sh
    • .travis.yml
    • phpunit.xml.dist
    NOTE: You need to set the executable permission for travis/prepare-phpbb.sh. To do so, you can run the following command:

    Code: Select all

    git update-index --chmod=+x travis/prepare-phpbb.sh
  3. Edit .travis.yml
    • find:

      Code: Select all

          - EXTNAME="acme/demo"  # CHANGE name of the extension HERE
    • replace with:

      Code: Select all

          - EXTNAME="yourvendor/yourextension"
    • Example:

      Code: Select all

          - EXTNAME="nickvergessen/newspage"
  4. Finished! Now write your tests.
Testing your code will help you to avoid making the same mistakes over and over again.

To run the tests locally, you need to install phpBB from its Git repository. Afterwards run the following command from the phpBB Git repository's root:

Windows:

Code: Select all

phpBB\vendor\bin\phpunit.bat -c phpBB\ext\acme\demo\phpunit.xml.dist
others:

Code: Select all

phpBB/vendor/bin/phpunit -c phpBB/ext/acme/demo/phpunit.xml.dist
No Support via PM

User avatar
nickvergessen
Former Team Member
Posts: 4397
Joined: Mon Apr 30, 2007 5:33 pm
Location: Stuttgart, Germany
Name: Joas Schilling
Contact:

Re: Simple way to test your ext on TravisCI

Post by nickvergessen » Thu Jun 12, 2014 9:55 pm

The manual is a lot smaller now as we merged the testing framework into the phpBB core.
No Support via PM

User avatar
VSE
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 4841
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: Simple way to test your ext on TravisCI

Post by VSE » Thu Jun 12, 2014 10:13 pm

I unit test most of my extensions with this!!
  1. It feels good to have that "build passing" badge on your repo :)
  2. It does help pin point when you might have missed a mistake in your code; or something in phpBB's code changed breaking compatability with your extension. It's also great for revealing possible issues with other versions of PHP and different database types that you can't use in your own local dev environment.
  3. It's easy to implement!
For more examples of unit-tests using this framework, check out these extension's Github repos:
  • phpbb-extensions/boardrules
  • board3/Board3-Portal
  • VSEphpbb/abbc3
  • VSEphpbb/dbtool
  • VSEphpbb/similartopics
  • VSEphpbb/topicpreview
Dictated but not read.
Official phpBB Extensions My Extensions & MODs
Please do not PM me for support.

Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 25185
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: Simple way to test your ext on TravisCI

Post by Paul » Thu Aug 07, 2014 12:55 pm

Running EPV (Extension Pre Validator) on Travis Tests:

EDIT:
This is no longer recommended.
To see how to run EPV on Travis please see this updated post.


The .travis.yml file in the acme demo has been updated to include running the Extension Pre validator (EPV) to be used on Travis.

To use EPV in travis you need to update your travis.yml to the lastest version (grab a new copy of the acme-demo extensions .travis.yml, and update your extension name info in it).

After that, include in your composer.json EPV as development dependency:

Code: Select all

	"require-dev": {
		"phpbb/epv": "dev-master"
	},
After that, you should create your composer.lock file by running

Code: Select all

composer.phar update --dev

(If you don't have composer.phar yet:

Code: Select all

curl -sS https://getcomposer.org/installer | php
After that, commit your code and your extension will be validated with EPV on travis on each commit. (Note that running composer.phar may add a vendor directory to your extension. You can delete this directory, and should not commit it to your repository.)

It should look likes this if you did everything right: https://travis-ci.org/nickvergessen/php ... 06651#L506
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development

User avatar
david63
Registered User
Posts: 16090
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Simple way to test your ext on TravisCI

Post by david63 » Thu Aug 07, 2014 2:29 pm

Is there any possibility that someone can explain this in words of one syllable so that those of us who do not have a degree in the current computer processes can understand what it is all about?
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
VSE
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 4841
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: Simple way to test your ext on TravisCI

Post by VSE » Thu Aug 07, 2014 2:39 pm

david63 wrote:Is there any possibility that someone can explain this in words of one syllable so that those of us who do not have a degree in the current computer processes can understand what it is all about?
The Extension Pre Validator is a new tool we created that will check your extension for valid code, such as valid PHP and valid usage of phpBB functions. It will find and report on any mistakes you may have made.

If you are using Github for your extensions, and utilizing the Travis-CI PHP-UNIT testing that we also provide access to for additional testing, you can make the changes mentioned above to take advantage of this test feature.
Dictated but not read.
Official phpBB Extensions My Extensions & MODs
Please do not PM me for support.

User avatar
david63
Registered User
Posts: 16090
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Simple way to test your ext on TravisCI

Post by david63 » Thu Aug 07, 2014 2:45 pm

VSE wrote:The Extension Pre Validator is a new tool we created that will check your extension for valid code, such as valid PHP and valid usage of phpBB functions. It will find and report on any mistakes you may have made.
That part I can follow.
VSE wrote:If you are using Github for your extensions, and utilizing the Travis-CI PHP-UNIT testing that we also provide access to for additional testing, you can make the changes mentioned above to take advantage of this test feature.
Github I am just about OK with - after that you lost me.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
VSE
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 4841
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: Simple way to test your ext on TravisCI

Post by VSE » Thu Aug 07, 2014 4:24 pm

david63 wrote:
VSE wrote:The Extension Pre Validator is a new tool we created that will check your extension for valid code, such as valid PHP and valid usage of phpBB functions. It will find and report on any mistakes you may have made.
That part I can follow.
VSE wrote:If you are using Github for your extensions, and utilizing the Travis-CI PHP-UNIT testing that we also provide access to for additional testing, you can make the changes mentioned above to take advantage of this test feature.
Github I am just about OK with - after that you lost me.
Then don't worry about this. Basically, this is just a bonus if you are using github with your extensions. No matter what, when the time comes to start submitting extensions for validation by phpBB, they will be run through the EPV anyway, so having it tested by github just helps you find potential issues before you submit for validation.
Dictated but not read.
Official phpBB Extensions My Extensions & MODs
Please do not PM me for support.

rxu
Extensions Development Team
Posts: 2923
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Name: Ruslan
Contact:

Re: Simple way to test your ext on TravisCI

Post by rxu » Fri Aug 08, 2014 5:58 am

The problem is that I can't find a link to related Travis job in commits list. Those are in PRs commits list, but I don't have such Prs in my repo as I edit it directly :)

User avatar
VSE
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 4841
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: Simple way to test your ext on TravisCI

Post by VSE » Fri Aug 08, 2014 9:45 am

rxu wrote:The problem is that I can't find a link to related Travis job in commits list. Those are in PRs commits list, but I don't have such Prs in my repo as I edit it directly :)
Use the ACME demo here: https://github.com/nickvergessen/phpbb-ext-acme-demo
Changes: https://github.com/nickvergessen/phpbb- ... aff4f80f35
(Note also the newly added composer.lock file)
Dictated but not read.
Official phpBB Extensions My Extensions & MODs
Please do not PM me for support.

rxu
Extensions Development Team
Posts: 2923
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Name: Ruslan
Contact:

Re: Simple way to test your ext on TravisCI

Post by rxu » Fri Aug 08, 2014 10:35 am

I already merged it into one of my exts just for test, so acme demo is useless for me now.
Where do I find the travis job for my commits?

Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 25185
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: Simple way to test your ext on TravisCI

Post by Paul » Fri Aug 08, 2014 10:51 am

rxu wrote:I already merged it into one of my exts just for test, so acme demo is useless for me now.
Where do I find the travis job for my commits?
(I just posted this on IRC as well)
We currently can't seem to find it indeed, Nicofoma said he sees it sometimes, however I can't seem to find it on my extension. However, you can always see it at http://travis-ci.org/<username>/<repo> (Plus you get a email if you break it. At least I do :P)
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development

Satanasov
Registered User
Posts: 1176
Joined: Sun Jul 29, 2012 5:48 am
Name: Stanislav Atanasov
Contact:

Re: Simple way to test your ext on TravisCI

Post by Satanasov » Thu Dec 11, 2014 3:32 am

Hello all,

Let me share something with you (I'm sharing it mostly, so I can have reference point when I need it again):

I'm writing extension that consist of main module and and few Add-ons. I still want to be able to test it on travis. I want to test the whole suit, so this calls for some changes in the

Code: Select all

.travis.yml
and

Code: Select all

travis/prepare-phpbb.sh
Please review the changes needed here (.travis.yml) and here (for travis/prepare-phpbb.sh)

What are these changes?

Basically I define the

Code: Select all

- EXTNAME="vendor"
Then I define a new global variable

Code: Select all

 - EXTSNIFF="vendor/coreextension"
because I am going to install dependences only for the core. And the sniff is set to ignore vendor folder only in $EXTNAME ... so we change it.

In install part of the

Code: Select all

.travis.yml
firstly we enter in the core extension (where the dependacies are important (where the composer.json is). We install the deps and then cd .. back to vendor dir (where the test folder is located).

The other change in

Code: Select all

.travis.yml
is to change $EXTNAME with $EXTSNIFF in sniff calling part (see few lines back why).

Then we turn to

Code: Select all

travis/prepare-phpbb.sh
As we have changed the root of the extension (it is not subfolder of the vendor) we need to remove one level of going back ...

Basically this will allow you to test "suits" of extensions. Hope I helped.
For list of all my extensions go to https://github.com/satanasov
If you want custom functions in some of my products - PM me and we will discuss it.

User avatar
Wolfsblvt
Registered User
Posts: 634
Joined: Sun Oct 26, 2014 9:12 pm
Location: Solingen, Germany
Contact:

Re: Simple way to test your ext on TravisCI

Post by Wolfsblvt » Thu Dec 11, 2014 1:08 pm

I've followed the instructions in this thread, including epv wich I really want to run on my extensions.
But I have a "problem" now.

When I checkin something to github my tests run like they should, you can see it here: https://travis-ci.org/Wolfsblvt/onlinet ... s/43664616 But for some very strange reason only the sixth of the seven test runs the epv. The errors should show up on all runs, shouldn't they?

This is my .travis.yml file:

Code: Select all

language: php

matrix:
  include:
    - php: 5.4
      env: DB=mysqli
    - php: 5.4
      env: DB=mysql
    - php: 5.4
      env: DB=mariadb
    - php: 5.4
      env: DB=postgres
    - php: 5.4
      env: DB=sqlite3
    - php: 5.5
      env: DB=mysqli
    - php: 5.6
      env: DB=mysqli
    - php: hhvm
      env: DB=mysqli
  allow_failures:
    - php: hhvm
  fast_finish: true

env:
  global:
    - EXTNAME="wolfsblvt/onlinetime"  # CHANGE name of the extension HERE
    - SNIFF="1"            # Should we run code sniffer on your code?
    - IMAGE_ICC="1"        # Should we run icc profile sniffer on your images?
    - EPV="1"              # Should we run EPV (Extension Pre Validator) on your code?
    - PHPBB_BRANCH="develop-ascraeus"

branches:
  only:
    - master
    - develop
    - /^develop-.*$/

before_install:
  - chmod +x travis/prepare-phpbb.sh

install:
  - composer install --dev --no-interaction --prefer-source
  - travis/prepare-phpbb.sh $EXTNAME $PHPBB_BRANCH
  - cd ../../phpBB3
  - travis/prepare-extension.sh $EXTNAME $PHPBB_BRANCH
  - travis/setup-phpbb.sh $DB $TRAVIS_PHP_VERSION

before_script:
  - travis/setup-database.sh $DB $TRAVIS_PHP_VERSION

script:
  - sh -c "if [ '$SNIFF' != '0' ]; then travis/ext-sniff.sh $DB $TRAVIS_PHP_VERSION $EXTNAME; fi"
  - sh -c "if [ '$IMAGE_ICC' != '0' ]; then travis/check-image-icc-profiles.sh $DB $TRAVIS_PHP_VERSION; fi"
  - phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/travis/phpunit-$DB-travis.xml --bootstrap ./tests/bootstrap.php
  - sh -c "if [ '$EPV' != '0' ] && [ '$TRAVIS_PHP_VERSION' = '5.3.3' ] && [ '$DB' = 'mysqli' ]; then phpBB/ext/$EXTNAME/vendor/bin/EPV.php run --dir='phpBB/ext/$EXTNAME/'; fi"
If you have a specific extension request and you are willing to pay for, you can write me a PM.
My extensions (Trending: @Mention SystemAdvanced PollsUser Online Time)

»Du kamst zu uns. Deine Stimme kam. Du zeigtest uns die Sterne. Sie funkelten. Wir konnten sehen.«

Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 25185
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: Simple way to test your ext on TravisCI

Post by Paul » Thu Dec 11, 2014 1:12 pm

No, they are only ran on 1 of them, not all.
These errors are also not from EPV, but from the code sniffer, which checks the coding guidelines.

Also, it seems you removed 5.3,3 from the build matrix, however EPV runs standard on 5.3.3. If you want to remove 5.3.3, you need to modify

Code: Select all

- sh -c "if [ '$EPV' != '0' ] && [ '$TRAVIS_PHP_VERSION' = '5.3.3' ] && [ '$DB' = 'mysqli' ]; then phpBB/ext/$EXTNAME/vendor/bin/EPV.php run --dir='phpBB/ext/$EXTNAME/'; fi"
to run on a different php version.
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development

Post Reply

Return to “Extension Writers Discussion”