{"id":8317,"date":"2020-06-27T18:34:38","date_gmt":"2020-06-27T18:34:38","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=8317"},"modified":"2020-06-27T18:34:38","modified_gmt":"2020-06-27T18:34:38","slug":"getting-started-with-circleci-and-github","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/getting-started-with-circleci-and-github\/","title":{"rendered":"Getting started with Circleci and GitHub"},"content":{"rendered":"<p>In my previous post I talked about using CI\/CD along with GitHub and in that post we concentrated on Appveyor. Let&#8217;s now look at one of the alternatives, <a href=\"https:\/\/circleci.com\/\" rel=\"noopener noreferrer\" target=\"_blank\">Circleci<\/a>.<\/p>\n<p>As you&#8217;d expect, you need to create an account and I used GitHub authentication as I wanted this CI\/CD application working with my GitHub projects. It&#8217;s probably not a requirement but certainly everything integrated nicely (I&#8217;ve not yet seen if that differs with alternative repositories hosts).<\/p>\n<p>Once you&#8217;ve created your account you&#8217;ll need to install the Circleci application within GitHub &#8211; I actually don&#8217;t recall the process but I suspect there&#8217;s an &#8220;Install Application&#8221; button or the likes.<\/p>\n<p><strong>Let\u2019s get started<\/strong><\/p>\n<p>Due to the GitHub integration you&#8217;ll see a list of your projects. Simply press the <em>Set Up Project<\/em> button. That&#8217;s pretty much all there is to it to get started, but we&#8217;re probably going to want to customise the process.<\/p>\n<p>In your project&#8217;s repository add the file config.yml into the .circleci folder, as below<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n.circleci\/config.yml\r\n<\/pre>\n<p>This allows us to write the configuration for our Circleci build pipeline using a DSL. Here&#8217;s one for an F# project I have in Circleci<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n version: 2.1\r\n\r\n orbs:\r\n  win: circleci\/windows@2.2.0\r\n\r\n jobs:\r\n   build:\r\n     executor: win\/default     \r\n    \r\n     steps:\r\n       - checkout\r\n       - run: dotnet build\r\n       - run: dotnet test Image.Processing.Tests\r\n<\/pre>\n<p>In this case we&#8217;re using the 2.1 (see <a href=\"https:\/\/circleci.com\/docs\/reference-2-1\/#circleci-2-1-configuration-reference-guide\" rel=\"noopener noreferrer\" target=\"_blank\">CircleCI 2.1 Configuration Reference Guide<\/a>. <\/p>\n<p>The first thing we do (after setting the version of the DSL) is to map to an orb definition. In this case we&#8217;re using a predefined orb, we can actually create our own orbs if needed (but we&#8217;re not going there at the moment, or maybe ever, we&#8217;ll have to wait and see).<\/p>\n<p><em>Note: An orb is a shareable package of configuration, see <a href=\"https:\/\/circleci.com\/orbs\/registry\/\" rel=\"noopener noreferrer\" target=\"_blank\">Explore Orbs<\/a> for a whole bunch of different orbs.<\/em>.<\/p>\n<p>Now we supply the <em>jobs<\/em>. In this case a <em>build<\/em> job using <em>win\/default<\/em>, basically a Windows image. <\/p>\n<p>Next we set up the build steps. These are self-explanatory, as you&#8217;d expect, we need to <em>checkout<\/em> our code, build the code and then run our tests. There&#8217;s a <em>checkout<\/em> step, the rest can be thought of as simply commands to run.<\/p>\n<p>We&#8217;re now going to want to add a badge to the README.md in our project to allow us and others to see the status of our build.<\/p>\n<p>Unlike Appveryor (unless I&#8217;m missing something, in which case I&#8217;ll update this post later) there&#8217;s no copy &#038; paste option for the badge link, instead have a look as <a href=\"https:\/\/circleci.com\/docs\/2.0\/status-badges\/\" rel=\"noopener noreferrer\" target=\"_blank\">Adding Status Badges<\/a>, here&#8217;s the template<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n&#x5B;!&#x5B;&lt;ORG_NAME&gt;](https:\/\/circleci.com\/&lt;VCS&gt;\/&lt;ORG_NAME&gt;\/&lt;PROJECT_NAME&gt;.svg?style=svg)](&lt;LINK&gt;)\r\n<\/pre>\n<p>So for my F# Image.Processing project this looks like the following<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n&#x5B;!&#x5B;putridparrot](https:\/\/circleci.com\/gh\/putridparrot\/Image.Processing.svg?style=svg)](https:\/\/circleci.com\/gh\/circleci\/circleci-docs)\r\n<\/pre>\n<p>At this time, I&#8217;m not sure how to link to the specific build (or whether this is possible), I &#8216;ll add to this post in the future if I find it&#8217;s possible.<\/p>\n<p><em>Note: If you prefer, change <em>style=svg<\/em> to <em>style=shield<\/em> for a different looking status image.<\/em><\/p>\n<p>That should get you started.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my previous post I talked about using CI\/CD along with GitHub and in that post we concentrated on Appveyor. Let&#8217;s now look at one of the alternatives, Circleci. As you&#8217;d expect, you need to create an account and I used GitHub authentication as I wanted this CI\/CD application working with my GitHub projects. It&#8217;s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[301,302,297],"tags":[],"class_list":["post-8317","post","type-post","status-publish","format-standard","hentry","category-ci-cd","category-circleci","category-github"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8317","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=8317"}],"version-history":[{"count":4,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8317\/revisions"}],"predecessor-version":[{"id":8321,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8317\/revisions\/8321"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=8317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=8317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=8317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}