From c772eed5260310d2d637b0374e9c4c6d20181895 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Feb 28 2017 15:44:17 +0000 Subject: PR#324 jenkins' docs Merges #324 Fixes # 320 --- diff --git a/docs/source/configuring_jenkins.rst b/docs/source/configuring_jenkins.rst new file mode 100644 index 0000000..55d149c --- /dev/null +++ b/docs/source/configuring_jenkins.rst @@ -0,0 +1,144 @@ +Unit tests in Fedora's Jenkins +============================== + +We're using Fedora's `Jenkins `_ +infrastructure for automatically running unit tests for new commits in +master branch. + +Current setup uses periodical checking of koji's git and when new commits are +seen, tests are run. Normal developer needn't to care about his workflow, but can +use it for his advantage as it can run tests for him with platforms he has no +access to. Currently are tests run on Fedora 24, Fedora 25 and CentOS 6 +platforms. + +Usage +----- + +If you need any change in jenkins setup, please file a pagure issue. As part +of solving issue, this documentation must be updated to reflect current state +in jenkins. + +If you want to run tests against specific repo (your or official branch), log +in to jenkins (via FAS unified login), navigate to `Build with parameters +`_ and put +your repository url to ``REPO`` and name of branch to ``BRANCH``. +``BRANCH_TO`` could be left blank as it is default set to *master*. Pressing +``BUILD`` should give you link to running build in all supported +environments. + + +Configuration +------------- + +- Public access is for everyone with no need to log in to jenkins. +- Admin access is via same interface and currently tkopecek and mikem have + access there. If you need access for yourself (you're probably part of + brew/koji team) create jira in BREW project requesting this. + Prerequisite for this is Fedora account (probably same one you are using + for work in pagure). + +- Setup - Following items are set-up via + https://jenkins.fedorainfracloud.org/job/koji/configure + +- Please don't change access rules (*Enable project-based security* + fields) unless you've a corresponding jira for that, so every change of + access is tracked there. +- *Job notifications* - when jenkins job finishes, it will send some info to + pagure. Such call will add a comment to PR. For this REST hook needs to + be configured: + + * Format: JSON + * Protocol: HTTP + * Event: Job Finalized + * URL: /build-finished + * Timeout: 30000 + * Log: 0 + +- *This build is parametrized* (checkbox set to true) - it allows jenkins + to use other branches than master (especially for PRs). Three parameters + are defined there: + + * REPO - The repository for the pull request. + * BRANCH - The branch for the pull request. + * BRANCH_TO - A branch into which the pull request should be merged. + +- *Discard Old Builds* + + * Strategy: Rotation + * Days to keep build: 20 + * Max # of builds to keep: empty + +- *Disable build* - it could be used if a lot of failing build happens with + no vision of early recovery - temporarily suspend jenkins jobs +- *Execute concurrent builds if necessary* - We currently have no need of this +- *Restrict where this project can be run* - Fedora 24 is used for now which means 'F24' value +- *Source Code Management* + + * Git + * Repositories + + * Repository URL: https://pagure.io/koji.git + * Credentials: none + * Branches to build: origin/master + +- *Build triggers* + + * *Trigger builds remotely*: true + + * Authentication tokens: + + * *Poll SCM*: + + * Schedule: H/5 * * * * + +- *Build* - most important part - script which runs tests itself. Here you can also add missing requirements which will get installed via pip (not via rpms from F24!) + +.. code-block:: shell + + # setup virtual environment + rm -rf kojienv + virtualenv --system-site-packages kojienv + source kojienv/bin/activate + + # install python requirements via pip, you can also specify exact versions here + # three steps are because of EL7 target. packaging is required by setuptools + # which are required by other packages. Not working in one transaction + pip install pip packaging --upgrade --ignore-installed + pip install setuptools --upgrade --ignore-installed + pip install nose psycopg2 python-qpid-proton mock coverage --upgrade --ignore-installed + # rehash package to be sure updated versions are used + hash -r + + # merge PR into main repository + if [ -n "$REPO" -a -n "$BRANCH" ]; then + git config --global user.email "test@example.com" + git config --global user.name "Tester" + git remote rm proposed || true + git remote add proposed "$REPO" + git fetch proposed + git checkout "origin/${BRANCH_TO:-master}" + git merge --no-ff "proposed/$BRANCH" -m "Merge PR" + fi + + # remove possible coverage output and run tests + coverage erase + PYTHONPATH=hub/.:cli/.:plugins/hub/.:plugins/cli/. nosetests --with-coverage --cover-package . + coverage xml + + # run additional tests if configured + #pylint . > pylint_report.txt + #pep8 . > pep8_report.txt + + # kill virtual environment + deactivate + + +- *Post-build actions* + + * *Publish Cobertura Coverage report*: coverage.xml - this will create coverage report accessible via jenkins web ui + * *E-mail notification*: + + * Recipients: tkopecek@redhat.com brew-devel@redhat.com + * Send separate e-mails to individuals who broke the build + +- *Send messages to fedmsg* diff --git a/docs/source/writing_koji_code.rst b/docs/source/writing_koji_code.rst index 0667b4c..b730660 100644 --- a/docs/source/writing_koji_code.rst +++ b/docs/source/writing_koji_code.rst @@ -631,6 +631,8 @@ Here are some guidelines on producing preferable pull requests. with new code - Please maintain backward-compatibility up to RHEL 5 (which means Python 2.4) +- Check, that unit tests are not broken. Simply run ``make test`` in main + directory of your branch. Note that the core development team for Koji is small, so it may take a few days for someone to reply to your request. @@ -669,3 +671,7 @@ You will need to install the following packages to actually run the tests. Please note that it is currently not supported to use *virtualenv* when hacking on Koji. + +Unit tests are run automatically for any commit in master branch. We use +Fedora's jenkins instance for that. Details are given here: :doc:`Unit tests +in Fedora's Jenkins `.