{"id":208,"date":"2020-06-19T19:17:20","date_gmt":"2020-06-19T18:17:20","guid":{"rendered":"https:\/\/blog.thomarite.uk\/?p=208"},"modified":"2020-07-17T20:22:13","modified_gmt":"2020-07-17T19:22:13","slug":"ci-basics-with-travis","status":"publish","type":"post","link":"https:\/\/blog.thomarite.uk\/index.php\/2020\/06\/19\/ci-basics-with-travis\/","title":{"rendered":"CI: Basics with Travis"},"content":{"rendered":"\n<p>For some time I wanted to learn a bit about CI\/CD. Today I have given a go to <a href=\"https:\/\/travis-ci.org\/\">Travis<\/a>.<\/p>\n\n\n\n<p>All this is based on  Kirk Byers <a href=\"https:\/\/pynet.twb-tech.com\/class-pyauto.html\">python course<\/a> and his git <a href=\"https:\/\/github.com\/ktbyers\/pyplus_course\">repo<\/a>.<\/p>\n\n\n\n<p>So I just created an empty repo and started working on it:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ git clone https:\/\/github.com\/thomarite\/test-ci.git\n\n$ cd test-ci\n$ pyenv local 3.7.3\n$ python -m venv virt_env\n$ source virt_env\/bin\/active\n\n$ python -m pip install pylama\n$ python -m pip install black\n$ python -m pip install pytest\n$ python -m pip install tox\n\n$ mkdir tests\n\n$ vim tests\/test_sample.py\ndef increment(x):\nreturn x + 1\n\n\ndef test_answer():\nassert increment(4) == 5\n\n$ vim requirements.txt\npytest==5.4.3\npylama==7.7.1\nblack==19.10b0\n\n$ vim .travis.yml\nlanguage: python\npython:\n\"3.7\"\n# command to install dependencies\ninstall:\npip install -r requirements.txt\n# command to run tests\nscript:\npylama .\nblack --check .\npy.test -s -v tests\/<\/pre>\n\n\n\n<p>Then you create an account with Travis-ci.org that is &#8220;free&#8221; and you link up to your repo.  As soon as you commit, you will how the tests run and if they are successful.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"247\" src=\"https:\/\/blog.thomarite.uk\/wp-content\/uploads\/2020\/06\/Screenshot-from-2020-06-19-19-15-09-1024x247.png\" alt=\"\" class=\"wp-image-209\" srcset=\"https:\/\/blog.thomarite.uk\/wp-content\/uploads\/2020\/06\/Screenshot-from-2020-06-19-19-15-09-1024x247.png 1024w, https:\/\/blog.thomarite.uk\/wp-content\/uploads\/2020\/06\/Screenshot-from-2020-06-19-19-15-09-300x72.png 300w, https:\/\/blog.thomarite.uk\/wp-content\/uploads\/2020\/06\/Screenshot-from-2020-06-19-19-15-09-768x185.png 768w, https:\/\/blog.thomarite.uk\/wp-content\/uploads\/2020\/06\/Screenshot-from-2020-06-19-19-15-09-1536x371.png 1536w, https:\/\/blog.thomarite.uk\/wp-content\/uploads\/2020\/06\/Screenshot-from-2020-06-19-19-15-09-2048x494.png 2048w, https:\/\/blog.thomarite.uk\/wp-content\/uploads\/2020\/06\/Screenshot-from-2020-06-19-19-15-09-1200x290.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p>As I have now a basic setup, I hope I carry on using it to any new python stuff I try.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For some time I wanted to learn a bit about CI\/CD. Today I have given a go to Travis. All this is based on Kirk Byers python course and his git repo. So I just created an empty repo and started working on it: $ git clone https:\/\/github.com\/thomarite\/test-ci.git $ cd test-ci $ pyenv local 3.7.3 &hellip; <a href=\"https:\/\/blog.thomarite.uk\/index.php\/2020\/06\/19\/ci-basics-with-travis\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;CI: Basics with Travis&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,21],"tags":[],"class_list":["post-208","post","type-post","status-publish","format-standard","hentry","category-unix","category-automation"],"_links":{"self":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts\/208","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/comments?post=208"}],"version-history":[{"count":1,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts\/208\/revisions"}],"predecessor-version":[{"id":210,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts\/208\/revisions\/210"}],"wp:attachment":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/media?parent=208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/categories?post=208"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/tags?post=208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}