Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-51458

Allow for Travis-CI integration in community moodle.git clones

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0
    • Fix Version/s: 3.0
    • Component/s: Unit tests
    • Labels:
    • Testing Instructions:
      Hide
      Setup
      1. Navigate to https://travis-ci.org
      2. Sign in with GitHub
      3. View your profile page
      4. Hit Sync (if necessary - probably not)
      5. Find 'Moodle', and enable it
      6. Click the cog icon next to id
      7. Ensure that 'Build only if .travis.yml is present' is enabled
      Important

      This will test that you are based upon a stable. Some of these tests may fail if your test branches are based off integration if the commits between origin/master and your branch contain either a linting failure, or a phpunit test failure.

      Basic build test
      1. Create a new branch based off this one (or integration), and push it to your personal github
      2. View travis-ci.org and watch
      Testing a phpunit test failure
      1. Find a unit test and insert a deliberate failure (hint, the first test run is 'core_phpunit_advanced_testcase::test_debugging'.)
      2. Commit the change and push to a branch on your github
      3. View travis-ci.org push
        1. Confirm that the failure was detected in the 4 phpunit runs (2 x DBs + 2 x versions)
      Test a PHP linting issue
      1. Create a new php file and insert a deliberate PHP linting failure
      2. Commit the change and push to a branch on your github
      3. View travis-ci.org push
        1. Confirm that the failure was detected in the 3 CITEST runs, but not in the phpunit runs
      Test a PHP 7 linting issue
      1. Create a new php file which contains a PHP7-only failure:
        <?php
        
        switch('foo') {
            case 'bar':
                break;
            default:
                break;
            default:
                break;
        }
        
      2. Commit the change and push to a branch on your github
      3. View travis-ci.org push
        1. Confirm that the failure was detected in 1 CITEST run for PHP7
        2. Confirm that the build as a whole succeeded despite the nightly failure
      Show
      Setup Navigate to https://travis-ci.org Sign in with GitHub View your profile page Hit Sync (if necessary - probably not) Find 'Moodle', and enable it Click the cog icon next to id Ensure that 'Build only if .travis.yml is present' is enabled Important This will test that you are based upon a stable. Some of these tests may fail if your test branches are based off integration if the commits between origin/master and your branch contain either a linting failure, or a phpunit test failure. Basic build test Create a new branch based off this one (or integration), and push it to your personal github View travis-ci.org and watch Testing a phpunit test failure Find a unit test and insert a deliberate failure (hint, the first test run is 'core_phpunit_advanced_testcase::test_debugging'.) Commit the change and push to a branch on your github View travis-ci.org push Confirm that the failure was detected in the 4 phpunit runs (2 x DBs + 2 x versions) Test a PHP linting issue Create a new php file and insert a deliberate PHP linting failure Commit the change and push to a branch on your github View travis-ci.org push Confirm that the failure was detected in the 3 CITEST runs, but not in the phpunit runs Test a PHP 7 linting issue Create a new php file which contains a PHP7-only failure: <?php switch ('foo') { case 'bar': break ; default : break ; default : break ; } Commit the change and push to a branch on your github View travis-ci.org push Confirm that the failure was detected in 1 CITEST run for PHP7 Confirm that the build as a whole succeeded despite the nightly failure
    • Affected Branches:
      MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_30_STABLE
    • Pull Master Branch:
      MDL-51458-master

      Description

      We have unit tests. Lots of unit tests.
      We have people writing code.
      We even have Jenkins running Unit tests on each commit.

      But only on commits to integration.git.

      It would be really awesome if we could empower our developers to have all of the Moodle unit tests run automatically whenever they push a branch to GitHub.

      At HQ, we simply do not have the resource on our Jenkins server to handle this (I don't think). However, GitHub integrates cleanly, easily, and freely with travis-ci.org.

      It would be super awesome if we could allow this integration to be enabled by individual developers so that, whenever they push their issues to GitHub it can be unit tested. They can be alerted to failures before it's even been peer reviewed.

      To integrate with travis-ci.org, we just need to include a .travis.yml with a pretty basic configuration.

      I've had a go at doing this, and have PHPUnit kicking off on both MySQL, and Postgres when I push any branch which contains my .travis.yml file.

      Everything is currently almost entirely contained within the .travis.yml file.
      There is one exception at present, and we can improve this too. At present, we can create the config.php using admin/cli/install.php, but that does not allow us to set the phpunit_dataroot or phpunit_prefix.
      At the moment I have created a new composer package which contains my postgres and my mysql (very basic) configurations instead of this. Although this then means that we have a package dependency which is installed via composer, it has two benefits:
      1) clear config.php which we can adjust in the repo; and
      2) we don't actually need to do both a Moodle install, and a phpunit install.

      Putting up for people's thoughts and views.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  1 Vote for this issue
                  Watchers:
                  10 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    16/Nov/15