Jekyll2019-09-26T11:55:04+00:00https://adrianmoisey.gitlab.io/feed.xmlAdrian MoiseyMy personal notes and blog6 Pro-Tips To Host a Kick-Ass Meetup2019-09-10T09:00:00+00:002019-09-10T09:00:00+00:00https://adrianmoisey.gitlab.io/2019/09/10/offerzen-meetup-post<h1 id="6-pro-tips-to-host-a-kick-ass-meetup">6 Pro-Tips To Host a Kick-Ass Meetup</h1>
<p>A few months ago I teamed up with OfferZen and wrote an article on what I learnt from running a meetup group,
Cape Town DevOps Meetup.</p>
<p>This article also includes some tips I learnt along the way.</p>
<p>It’s hosted over on <a href="https://www.offerzen.com/blog/6-pro-tips-to-host-a-kick-ass-meetup">OfferZen’s Blog</a></p>Adrian Moisey6 Pro-Tips To Host a Kick-Ass MeetupGitLab adds Scoped Labels2019-05-01T11:00:00+00:002019-05-01T11:00:00+00:00https://adrianmoisey.gitlab.io/2019/05/01/gitlab-scoped-labels<h1 id="gitlab-adds-scoped-labels">GitLab adds Scoped Labels</h1>
<p><a href="https://about.gitlab.com/2019/04/22/gitlab-11-10-released/#scoped-labels">Scoped labels</a> were introduced in <a href="https://about.gitlab.com/2019/04/22/gitlab-11-10-released/">GitLab 11.10</a>.</p>
<p>These can only be used in GitLab Premium/Silver (and Ultimate/Gold), which is unfortunate because none of my private
projects are on that level.</p>
<p>Scoped labels are mutually exclusive labels that share a namespace (or scope). These are created with the format of
<code class="highlighter-rouge"><scope>::<name></code> (note the double <code class="highlighter-rouge">::</code>).</p>
<p>Two scoped labels with the same scope but a different value cannot be simultaneously added apply to an issue.</p>
<h2 id="example-use-case">Example use case</h2>
<p>You might want to have labels that indicate the priority of an issue.
You can create multiple labels with the same scope: <code class="highlighter-rouge">priority::high</code>, <code class="highlighter-rouge">priority::medium</code> and <code class="highlighter-rouge">priority::low</code>
This would mean that if you have an issue with a <code class="highlighter-rouge">medium</code> priority and changed it to <code class="highlighter-rouge">high</code>, GitLab will
automatically remove the <code class="highlighter-rouge">medium</code> label for you. Handy!</p>
<p>GitLab’s documentation also has an example for using these labels with their Issue Board in the
<a href="https://docs.gitlab.com/ee/user/project/labels.html#workflows-with-scoped-labels-premium">documentation</a></p>
<h2 id="improvement-id-like-to-see">Improvement I’d like to see</h2>
<p>I can’t currently find a way to search scoped labels by their scope.
For example, I may want to search for all labels beginning in <code class="highlighter-rouge">priority::</code>.
I hope GitLab adds functionality around that.</p>Adrian MoiseyGitLab adds Scoped LabelsFiltering emails from GitLab in Gmail2019-01-25T17:00:00+00:002019-01-25T17:00:00+00:00https://adrianmoisey.gitlab.io/2019/01/25/gitlab-adds-list-id<h1 id="filtering-emails-from-gitlab-in-gmail">Filtering emails from GitLab in Gmail</h1>
<p>I use GitLab for a few different groups. My employer stores their code there, I’m involved with random open source
projects and the <a href="https://www.meetup.com/Cape-Town-DevOps/">Cape Town DevOps Meetup Group</a> uses GitLab to organise meetups.</p>
<p>Up until recently, I’ve found that I struggled to filter my incoming emails correctly. Between GitLab and Gmail, I had no
way to filter out each organisation into different labels. Sometimes this meant that certain issues I missed some
emails, particularly from issues that weren’t very busy.</p>
<p>I’m happy to say that a <a href="https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22817">recent community contribution</a> to
GitLab has solved this issue for me! GitLab 11.7 adds the <a href="https://tools.ietf.org/html/rfc2919">List-Id</a> header to
emails sent to you, allowing you to filter on group or project.</p>
<p>In Gmail, you can simply search for <code class="highlighter-rouge">list:<organisation></code> (eg. <code class="highlighter-rouge">list:list:gitlab-org</code>), and create your filter from that.
My preferred configuration is to create a label per organisation that I follow and filter all those emails accordingly.</p>Adrian MoiseyFiltering emails from GitLab in GmailParallel jobs in GitLab-Runner with Pytest2018-11-27T17:00:00+00:002018-11-27T17:00:00+00:00https://adrianmoisey.gitlab.io/2018/11/27/parallel-jobs-in-gitlab-runner-with-pytest<h1 id="parallel-jobs-in-gitlab-with-pytest">Parallel jobs in GitLab with Pytest</h1>
<p>On 22 November 2018, GitLab released version <a href="https://about.gitlab.com/2018/11/22/gitlab-11-5-released/">11.5</a> which introduced a new attribute for the GitLab Runner called <code class="highlighter-rouge">parallel</code>.<br />
This option allows you to split a single job into multiple jobs, and let them run in parallel.<br />
I’m going to describe how you can use this feature to split up tests into multiple jobs with <code class="highlighter-rouge">pytest</code>.</p>
<h2 id="configuring-your-job">Configuring your job</h2>
<p>The config option is quite simple, you define the number of parallel jobs to run using <code class="highlighter-rouge">parallel: N</code> in your job definition. The <a href="https://docs.gitlab.com/ee/ci/yaml/#parallel">GitLab Runner</a> docs have more details.
Here’s an example from a snippet of my <code class="highlighter-rouge">.gitlab-ci.yml</code> file:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>pytest:
stage: test
image: $CONTAINER_IMAGE:latest
parallel: 5
services:
- mysql:5.5
- redis
script:
- pytest
</code></pre></div></div>
<p>This will run 5 instances of <code class="highlighter-rouge">pytest</code>, with two additional environment variables. <code class="highlighter-rouge">CI_NODE_TOTAL</code> and <code class="highlighter-rouge">CI_NODE_INDEX</code>.<br />
<code class="highlighter-rouge">CI_NODE_TOTAL</code> will give you the number of jobs that are run, while <code class="highlighter-rouge">CI_NODE_INDEX</code> will be the number of the instance. For example, the third job will be <code class="highlighter-rouge">CI_NODE_TOTAL=5</code> and <code class="highlighter-rouge">CI_NODE_INDEX=3</code>.</p>
<h2 id="configuring-pytest">Configuring pytest</h2>
<p>Standard <code class="highlighter-rouge">pytest</code> doesn’t support splitting tests between multiple jobs, but, fortunately for us, there is a plugin to do that.<br />
<a href="https://github.com/mark-adams/pytest-test-groups">pytest-test-groups</a> allows you to split tests up into groups, by passing in a count, and the index of that run. After installing pytest-test-groups, we can tweak the <code class="highlighter-rouge">.gitlab-ci.yml</code> file like this:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>pytest:
stage: test
image: $CONTAINER_IMAGE:latest
parallel: 5
services:
- mysql:5.5
- redis
script:
- pytest --test-group-count $CI_NODE_TOTAL --test-group=$CI_NODE_INDEX
</code></pre></div></div>
<p>Now, when we run the job, we should get output similar to this in the “pipeline” section of GitLab:
<img src="/img/parallel.png" alt="GitLab-Runner Parallel" /></p>
<h2 id="final">Final</h2>
<p>As you can see, this feature is quite simple to use and configure. Some things to note before considering it:</p>
<ol>
<li>The idea of running jobs in parallel is to make your tests run faster. But depending on your setup, sometimes this isn’t the case. On the code base I tested, our database migrations were slow, which caused our tests to run slower in parallel. Considering this is an easy setup, it’s worth testing.</li>
<li>If you use tools that generate reports (such as code coverage) you’ll end up with multiple reports. This means you may need to figure out how to combine these reports to make them useful again.</li>
</ol>Adrian MoiseyParallel jobs in GitLab with PytestPyConZA 20172017-10-09T01:00:00+00:002017-10-09T01:00:00+00:00https://adrianmoisey.gitlab.io/2017/10/09/pyconza-2017<h1 id="pyconza-2017">PyConZA 2017</h1>
<p>PyConZA 2017 was hosted at The River Club on Thursday and Friday the 5th and 6th of October. This was my 4th PyConZA conference I’ve been to. Having missed the last one in Cape Town, I was quite looking forward to having two days of 100% Python.</p>
<h2 id="talks">Talks</h2>
<p>Not really worried about the lineup at a PyConZA, I didn’t really know which talks to look forward to, or what to expect. Below are some of the talks that resonated with me.</p>
<h3 id="great-keynote">Great keynote</h3>
<p>The Keynote, <a href="https://za.pycon.org/talks/1/">Don’t try to look smart. Be smart</a>, was something I didn’t quite expect. <a href="http://flaper87.com/">Flavio</a>’s talk struck a chord with me. As I’ve grown, I’ve learnt a lot of lessons about myself, and the world around me. A lot of what he spoke about are lessons I’ve been learning over the years, relating to how I should present myself to the world, and how I should behave around other people. Be nice! Pick your battles! Time is your most important asset.</p>
<h3 id="graphql">GraphQL</h3>
<p>My friend <a href="https://twitter.com/imsickofmaps">Mike Jones</a> gave a talk on <a href="https://za.pycon.org/talks/34/">GraphQL and Django</a>. Since my workplace uses GraphQL, it made sense for me to learn more. He spoke about why one might want to use GraphQL. He also had some nice examples of implementation, and how to test it. Some of which I need to apply to our project.</p>
<h3 id="zappa">Zappa</h3>
<p>An international speaker, from Brazil, <a href="https://twitter.com/jonatasbaldin">Jonatas Baldin</a> spoke on <a href="https://za.pycon.org/talks/47/">Serverless and Zappa.</a>. Having an understanding of Serverless, I thought I wouldn’t learn too much from this talk, however, he showed off Zappa. Wow. he showed off how easy it was set up an entire Django project on AWS Lambda. Serverless is definitely something I need to keep an eye on.</p>
<h3 id="takealot-challenge">Takealot challenge</h3>
<p>Dan Wells, from Takealot, set up a challenge for the attendees. He printed a unique secret for everyone, and pointed them at a URL (hosted on his laptop). I managed to complete it, and really enjoyed it. The biggest challenge for me was figuring out how to HMAC-SHA256 the body of the content I was sending.
Each step of the challenge had a clue, and required you to POST the answer. Step 1 gave you a BASE64 encoded image, of a cheeseburger. Step 2 gave you a string, that had been encrypted with a simple Caesar cipher. Step 3 required you to figure out which NLP library he used to figure out the sentiment of a string, and send him the result. All in all, it was great fun.</p>
<h2 id="networking">Networking</h2>
<p>PyConZA (and any other tech conference or meetup) is a really nice time to meet other people. The talks are normally the main attraction, however, those can always be watched later on YouTube. I really enjoyed the people at conferences. I met a lot of new people at PyConZA 2017, managed to learn tons from them, and get inspired by talking to them.</p>
<h3 id="breaking-the-ice---with-stickers">Breaking the ice - with stickers</h3>
<p>Sometimes networking at conferences is difficult. Speaking to new people can be intimidating. A new tactic of mine is to bring along some tech stickers, and <a href="https://twitter.com/adrianmoisey/status/916208170527227905">tweet</a> that I’m handing them out. It turns out that people love stickers for their laptops, so it’s a great way to meet new people. I’m certainly going to keep doing this. I’ve already been labelled “The Sticker Man”, may just lean into it.</p>
<p>I’ve heard of other tricks, for example, setting a challenge for yourself, go speak to at least 3 people wearing red shoes.</p>
<h3 id="cool-people">Cool people</h3>
<p>I had the privilege of hosting <a href="https://twitter.com/jonatasbaldin">Jonatas Baldin</a> for three nights. It was great to have such an enthusiastic person around all the time. We spoke about Django, Channels, Serverless, GraphQL, Cape Town, travel, DevOpsDays, etc etc. His excitement was contagious!</p>
<p>It turns out he wrote the Python tutorial on <a href="https://www.howtographql.com/">https://www.howtographql.com/</a>, and he has a tutorial on Django Channels on his GitHub account, which I took a look at. I’m to hoping implement <em>something</em> with Django Channels soon (hopefully for GraphQL subscriptions).</p>
<p>During the conference I chatted to a few people, and learnt a few tips. My friend, Jethro Muller, pointed me at <a href="https://pypi.python.org/pypi/responses">responses</a>, a library for mocking requests. I managed to write a few test on our main project at work, using responses. I was impressed with how easy it was to implement.</p>
<h3 id="excitement-and-inspiration">Excitement and inspiration</h3>
<p>I find that spending two days with Python people, talking about Python all the time, gets me inspired. It makes me want to go do awesome things and learn more things. That’s part of why I’m writing this blog post, I’m trying make sense of the conference, and share my experience. This is also a reminder to me that if I need an “energy” boost, to go to a meetup, talk to people, find out about new tech. It helps.</p>
<h3 id="touring-cape-town">Touring Cape Town</h3>
<p>On the day following the conference, myself, Jonatas, <a href="https://twitter.com/lschuirmann">Lasse Schuirmann</a> and my wife went exploring Cape Town. We started off with breakfast in Kalk Bay, drove down to Simon’s Town, paid our respects to <a href="https://en.wikipedia.org/wiki/Just_Nuisance">Just Nuisance</a>, visited the penguins at Boulder’s Beach, ate some pizza at The Red Herring in Noordhoek, looked at the view of Cape Town from Ou Kaapse Weg, tasted some wine at Steenberg Vineyards, watched the sun set from Signal Hill, and finally ate some hamburgers at Hudson’s.</p>
<p>It was great to be able to show off our city to people who have never seen it before. Sometimes I forget about what Cape Town has to offer. Seeing the city from the eyes of a tourist reminds me to try appreciate what I have.</p>
<p><img src="/img/pycon-2017.jpg" alt="Steenberg Vineyard" /></p>Adrian MoiseyPyConZA 2017Hello world2017-06-26T01:00:00+00:002017-06-26T01:00:00+00:00https://adrianmoisey.gitlab.io/2017/06/26/hello-world<p>Hello world</p>Adrian MoiseyHello world