{ "info": { "author": "Sean Chen", "author_email": "sean.chen@leocorn.com", "bugtrack_url": null, "classifiers": [ "Framework :: Buildout", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License (GPL)", "Topic :: Software Development :: Build Tools", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "`Check the GitHub Page `_ for details document\n\nGeneral Usage\n*******************\n\n.. contents:: Table of Contents\n :depth: 5\n\nExplain the story here.\n\nWhat's the story\n----------------\n\nContinuous Integration (CI) testing for small and medium projects.\n\n\nPreparing the case\n------------------\n\nImport modules.\n::\n\n >>> from fabric.operations import local\n >>> from fabric.context_managers import lcd\n\nCreate the working folder and the build folder.\nWe should have the absolute path for both.\n::\n\n >>> import os\n >>> test_folder = tmpdir('test')\n >>> build_folder = tmpdir('builds')\n\nWe will use the leocornus demo repository \n**leocornus-ci-projects** for testing.\n::\n\n >>> repo_url = 'https://github.com/leocornus/leocornus-ci-projects.git'\n\nget ready the working folder.\n::\n\n >>> with lcd(test_folder):\n ... clone = local('git clone %s' % repo_url, True)\n [localhost] local: git clone ...\n >>> prj_folder = os.path.join(test_folder, 'leocornus-ci-projects')\n\nGet the most recent 5 commits for testing.\n::\n\n >>> with lcd(prj_folder):\n ... local('git pull', True)\n ... ids = local('git log --format=%h -5 .', True)\n [localhost] local: git pull\n 'Already up-to-date.'\n [localhost] local: git log ...\n >>> commit_ids = ids.splitlines()\n >>> len(commit_ids)\n 5\n\nPrepare a buildlog\n~~~~~~~~~~~~~~~~~~\n\nThe buildlog will have only one line to track the last build id \nand commit id.\nWe will use the number 2 commit as an example for the last build.\nThe first entry of the git log is the lastest commit by default.\nSo we will only build the latest commit.\n::\n\n >>> logdata = \"%s-%s\" % (100, commit_ids[1])\n >>> write(prj_folder, '.buildlog', logdata)\n >>> print(logdata)\n 100-...\n\nThe file .buildlog will have the content like following::\n\n 100-80fc8b4\n\nPrepare a cicfg\n~~~~~~~~~~~~~~~\n\nthe **.cicfg** will be searched from the following location:\n\n- project folder, while user could customize it by project.\n- user's home folder **~/.cicfg**, it will be override by the \n same file in project folder.\n\nWe will use the .cicfg file in suer's home folder for testing.\nThe method **expanduser** in build testing context will return\na temporary folder.\nWe will not test this for now.\n::\n\n ...>>> home_folder = os.path.expanduser(\"~\")\n ...>>> print(home_folder)\n ...>>> ci_scripts = \"\"\"\n ...... [ci]\n ...... script:\n ...... ls -la\n ...... \"\"\"\n ...>>> write(home_folder, '.cicfg', ci_scripts)\n\nPrepare a mwrc file\n~~~~~~~~~~~~~~~~~~~\n\nGet ready a sample mwrc file for testing.\nWe will save the mwrc file in working folder.\n::\n\n >>> rc_file = os.path.join(prj_folder, '.mwrc')\n >>> mwrc = open(rc_file, 'w')\n >>> cfg_data = \"\"\"\n ... [mwclient]\n ... update_wiki = no\n ... host = mediawiki.site.com\n ... path = /wiki/\n ... username = seanchen\n ... password = password\n ... \n ... [wiki page]\n ... title: Project:CI/Builds/%(build_id)s-%(commit_id)s\n ... comment: build log for commit %(commit_id)s\n ... content: \n ... %(build_status)s\n ... ===Commit===\n ...
%(commit_message)s
\n ... ===Build Log===\n ...
%(build_log)s
\n ... \"\"\"\n >>> mwrc.write(cfg_data)\n >>> mwrc.close()\n\nSet up the ci buildout\n----------------------\n\nGet ready a buildout to execute CI testing.\n::\n\n >>> write(sample_buildout, 'buildout.cfg',\n ... \"\"\"\n ... [buildout]\n ... parts = test-ci\n ...\n ... [test-ci]\n ... recipe = leocornus.recipe.ci\n ... working-folder = %(prj_folder)s\n ... builds-folder = %(builds_folder)s\n ... wiki-rc-file = %(rc_file)s\n ... \"\"\" % dict(prj_folder=prj_folder, builds_folder=build_folder,\n ... rc_file=rc_file))\n >>> ls(sample_buildout)\n d bin\n - buildout.cfg\n d develop-eggs\n d eggs\n d parts\n\nExecute the buildout\n--------------------\n\nrun the buildout::\n\n >>> os.chdir(sample_buildout)\n >>> print(system(buildout))\n Installing test-ci.\n test-ci: Working Folder ...\n test-ci: Builds Folder ...\n test-ci: Save Builds 0\n test-ci: Last build id 100\n test-ci: Last commit id ...\n test-ci: Total number of commits pending build 1\n test-ci: Next commit to build 101-...\n test-ci: Repository Remote: https://github.com/...\n test-ci: Repository Branch: master\n test-ci: Project Folder: projects/...\n test-ci: Get ready build folder: .../builds/101/...\n test-ci: Execute test script: npm test\n test-ci: Result: Build success!\n test-ci: Convert build log to HTML.\n test-ci: Wiki page title: Project:CI/Builds/101-...\n test-ci: Wiki update is OFF\n ...\n\nbuildout won't store those Fabric local output.\n::\n\n [localhost] local: git pull\n [localhost] local: git log ...\n test-ci: Total number of commits pending build 1\n test-ci: Next commit to build 101-...\n [localhost] local: echo 101-... > .buildlog\n [localhost] local: git remote -v\n [localhost] local: git branch\n [localhost] local: git log --name-only --format=%h -1 ...\n test-ci: Repository Remote: https://github.com/leocornus/leocourns-ci-projects.git\n test-ci: Repository Branch: master\n test-ci: Project Folder: projects/...\n [localhost] local: echo projects/...\n test-ci: Get ready build folder: .../builds/101/...\n test-ci: Result: Build success!\n ...\n\nexplore the build log\n---------------------\n\nRead the build log.\n::\n\n >>> log_file = '%s/101.log' % build_folder\n >>> blog = open(log_file)\n >>> logs = blog.read()\n >>> #print(logs)\n >>> 'git init' in logs\n True\n\nquick test for converting build log\n::\n\n >>> from subprocess import Popen\n >>> from subprocess import check_output\n >>> from subprocess import PIPE\n >>> cat = Popen(['cat', log_file], stdout=PIPE)\n >>> html_log = check_output(['aha', '-b', '--no-header'], stdin=cat.stdout)\n >>> #print(html_log)\n >>> 'color:lime' in html_log\n True\n\nTear down\n---------\n\nThe **buildoutTearDown** should clean up temp directories.\n\nclean the .cicfg file.\n::\n\n ...>>> remove = local('rm -rf %s' % cicfg, True)\n ...[localhost] local: rm -rf ...\n\nDownload\n***************", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/leocornus/leocornus.recipe.ci", "keywords": "development buildout recipe package ci", "license": "GPLv2", "maintainer": null, "maintainer_email": null, "name": "leocornus.recipe.ci", "package_url": "https://pypi.org/project/leocornus.recipe.ci/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/leocornus.recipe.ci/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/leocornus/leocornus.recipe.ci" }, "release_url": "https://pypi.org/project/leocornus.recipe.ci/0.0.1/", "requires_dist": null, "requires_python": null, "summary": "zc.buildout recipe for manage and execute CI test cases.", "version": "0.0.1" }, "last_serial": 1573798, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "795ffbb2a5f2461ea1e1aaf0acfb0401", "sha256": "bc600871a14f951b2c273ab717f317f1168de9d755089f98bf6dc47361d6a624" }, "downloads": -1, "filename": "leocornus.recipe.ci-0.0.1.tar.gz", "has_sig": false, "md5_digest": "795ffbb2a5f2461ea1e1aaf0acfb0401", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18307, "upload_time": "2015-06-01T18:55:20", "url": "https://files.pythonhosted.org/packages/af/e0/403945688957a35dc1db06bbb0ec15e0f68faa3559766aed10e711f81bc3/leocornus.recipe.ci-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "795ffbb2a5f2461ea1e1aaf0acfb0401", "sha256": "bc600871a14f951b2c273ab717f317f1168de9d755089f98bf6dc47361d6a624" }, "downloads": -1, "filename": "leocornus.recipe.ci-0.0.1.tar.gz", "has_sig": false, "md5_digest": "795ffbb2a5f2461ea1e1aaf0acfb0401", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18307, "upload_time": "2015-06-01T18:55:20", "url": "https://files.pythonhosted.org/packages/af/e0/403945688957a35dc1db06bbb0ec15e0f68faa3559766aed10e711f81bc3/leocornus.recipe.ci-0.0.1.tar.gz" } ] }