<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Wouter Admiraal&apos;s Blog</title>
    <description>Thoughts from the strange mind of Wouter Admiraal</description>
    <link>https://wadmiraal.net</link>
    <atom:link href="https://wadmiraal.net/feed.xml" rel="self" type="application/rss+xml" />
    
    
      <item>
        <title>Measuring What Matters: How to Use GetDx, LinearB, and Co as a Leadership Tool, Not Surveillance</title>
        <description>&lt;p&gt;About a year ago, Sonar decided to introduce &lt;a href=&quot;https://getdx.com/&quot;&gt;DX&lt;/a&gt;. I&apos;ll admit I was sceptical and hesitant to use it for my team. Because, how can you possible hope to measure an activity like software engineering objectively? Every team&apos;s context is different, which means certain metrics might look &amp;quot;bad&amp;quot; for one team while actually being acceptable, or look &amp;quot;ok&amp;quot; for another while being totally unacceptable. Furthermore, software engineering is both a creative activity and a team effort, which makes measuring &lt;em&gt;individual&lt;/em&gt; productivity incredibly difficult and error-prone. I had +15 years of experience at that time, and +5 years as a leader; I had learned to trust my instincts and value things like extreme ownership, honesty and transparency, continuous improvement, etc, as sure indicators of my teams performing well. I couldn&apos;t see how you could &lt;em&gt;measure&lt;/em&gt; such things objectively (and, spoiler alert, you can&apos;t; at least, not &lt;em&gt;directly&lt;/em&gt;).&lt;/p&gt;
&lt;p&gt;I also remembered the &lt;a href=&quot;https://www.mckinsey.com/industries/technology-media-and-telecommunications/our-insights/yes-you-can-measure-software-developer-productivity&quot;&gt;highly controversial McKinsey article&lt;/a&gt; which claimed to have cracked the code on measuring software developer productivity. I didn&apos;t buy it and know many others didn&apos;t either. I already saw my own engineers push back and challenge — for good reasons — what I thought would be the go-to metrics, like amounts of PRs closed per engineer, or lines of code written (to be fair, this is not what McKinsey was suggesting).&lt;/p&gt;
&lt;p&gt;So yeah... I was sceptical. The only reason I did give it an honest shot was that I had read &lt;a href=&quot;https://www.goodreads.com/book/show/35747076-accelerate&quot;&gt;Accelerate&lt;/a&gt; a few months before, which explains how the DORA metrics work. This was extremely insightful and showed that, maybe, if used correctly and intelligently, we may gain something from using DX.&lt;/p&gt;
&lt;p&gt;1 year later and I&apos;ve come to &lt;em&gt;love&lt;/em&gt; using DX. Even my engineers see the value, and I have become one of its strongest proponents in the company. And I want to share my experience here because if you&apos;re not using them (correctly), you&apos;re missing out.&lt;/p&gt;
&lt;h1&gt;How to use these tools&lt;/h1&gt;
&lt;p&gt;I&apos;ll share my experience using DX, but obviously there are others out there, like LinearB, Jellyfish, etc. I don&apos;t know which tool is best, or even if there is an objectively better tool. As long as you get more insights into your team&apos;s activity you will likely be able to benefit from it.&lt;/p&gt;
&lt;h2&gt;The number 1 rule: THE METRIC IS NOT THE OBJECTIVE&lt;/h2&gt;
&lt;p&gt;Let me say that again: &lt;strong&gt;the metric is not the objective!&lt;/strong&gt; Seriously, it&apos;s so tempting to look at metrics and have the urge to see them improve. This leads to objectives like &amp;quot;Reduce PR cycle time&amp;quot; or &amp;quot;Increase PR throughput&amp;quot;; they are utterly useless and may even negatively affect your team&apos;s morale. Our engineers are smart and they will quickly game the system if they feel this will shut up leadership; but it doesn&apos;t mean they will like doing this.&lt;/p&gt;
&lt;p&gt;Instead, always remind yourself and the team that metrics should be seen as &amp;quot;proxies&amp;quot;, or &lt;em&gt;signals&lt;/em&gt;.&lt;/p&gt;
&lt;h2&gt;Data as a signal, not a verdict&lt;/h2&gt;
&lt;p&gt;These tools are extremely powerful when used as &lt;em&gt;signals&lt;/em&gt;, not as objective truths. Take PR cycle time for example. It&apos;s is very interesting to look at the team&apos;s PR cycle times and then discuss with them how they &lt;em&gt;feel&lt;/em&gt; about their PR review times. If the data shows it&apos;s quite slow but they&apos;re happy with it, what does that mean? Is it because they&apos;re very quality-focused and are OK to take more time to ship better code? Or, do they feel it&apos;s too slow even if the data shows it&apos;s actually quite good? Many metrics won&apos;t tell you much until you look at the broader context and &lt;em&gt;correlate&lt;/em&gt; it with the engineers&apos; experience. I.e., it&apos;s a signal, but it&apos;s up to you to dig deeper and understand what it actually means in your specific context. This digging deeper is where you will get the real value out of this data.&lt;/p&gt;
&lt;p&gt;Furthermore, many metrics can — and should — be looked at over long periods of time to identify trends. If you have a graph showing PR throughput, for instance, you will likely see it swing wildly week over week (because people were sick, or on holiday, or at a conference, etc). But over the long term, what is the &lt;em&gt;trend&lt;/em&gt;? Over a 3 month, or even 6 month period, is it stable? Or going up? Or down? And what does that tell you? Did you expect it?&lt;/p&gt;
&lt;p&gt;There is no single right answer to such questions. But just like a good doctor will treat certain symptoms as signals that guide his diagnostic, you will need to step back and reflect on this with your team to understand what these metrics are telling you. They don&apos;t necessarily need to lead to immediate action; the understanding itself is already valuable.&lt;/p&gt;
&lt;h2&gt;Never look at just one metric. Ever.&lt;/h2&gt;
&lt;p&gt;This is probably obvious, but let me state it anyway: the single biggest mistake you can make is look at only 1 metric. It&apos;s not only meaningless, it can actually be harmful. It&apos;s as if you were looking at the number of unique visitors to your website but are ignoring bounce rate. If you only focus on getting more visits but don&apos;t realize 95% are bouncing, you&apos;re wasting a lot of that effort.&lt;/p&gt;
&lt;p&gt;Similarly, you should look at multiple metrics for your team. If your team&apos;s PR throughput is low and PR cycle time is high, that may look &amp;quot;bad&amp;quot;; but if at the same time your change fail rate is best in class, you&apos;re doing something right. Conversely, if your PR throughput and cycle times are in the top 5th percentile industry-wise, that may look &amp;quot;amazing&amp;quot;; but if at the same your change fail rate is 50%, you&apos;re doing something horribly wrong.&lt;/p&gt;
&lt;p&gt;The easiest ones to start with, in my experience, are &lt;em&gt;team&lt;/em&gt; PR throughput, &lt;em&gt;team&lt;/em&gt; PR cycle time, and &lt;em&gt;team&lt;/em&gt; change fail rate (don&apos;t look at the data for individual engineers, it is unlikely to tell you anything useful). But be curious! Explore things like review load per engineer, backlog size, sprint burnup, ticket cycle time, and more. DX has a pretty decent AI that can help you explore available data and write queries; I use it extensively and find it super useful.&lt;/p&gt;
&lt;h2&gt;Transparency and a shared journey&lt;/h2&gt;
&lt;p&gt;Be very open with your engineers; tell them you&apos;re looking at data and &lt;em&gt;show&lt;/em&gt; it to them. If you have a dashboard, give them access to it so they see what you see. Be open about the fact you&apos;re figuring this out and that you would like to figure this out with them, together.&lt;/p&gt;
&lt;p&gt;What I did with my team was first share my dashboard and suggest we look at it together every retrospective. We would spend ~10mins going over the graphs and trying to understand what we were looking at. And I would always remind them (and myself) about the number 1 rule: &lt;strong&gt;the metric is not the objective&lt;/strong&gt;. To illustrate, I&apos;ve had the experience multiple times now were an engineer, when first exposed to the graphs, would say something like &amp;quot;Oh, but I like to open a PR very early in draft mode. That will impact the metrics, should I not do that?&amp;quot; And I always say the same thing: &amp;quot;&lt;strong&gt;You do what makes sense to you.&lt;/strong&gt; The metrics don&apos;t matter, we don&apos;t change what we do just to make the numbers look better.&amp;quot; I feel this has helped build trust: my engineers know we&apos;re not changing our ways of working only to make a graph look better, we&apos;re trying to see how the graphs correlate to our ways of working (which can, ultimately, lead to real improvements; more on that later).&lt;/p&gt;
&lt;h2&gt;Percentiles: your shield against sterile debates&lt;/h2&gt;
&lt;p&gt;You might face a situation where your engineers start pointing out reasons the data is tainted and thus unreliable. For instance, on my team, we sometimes need to make changes on repos where we need to ask another team for a review, which is typically slow. There are also company-wide sensitive repos where we cannot merge on Fridays, so some PRs need to wait until Monday morning to be merged. These situations can can really mess up our PR cycle time data, especially if you look at the &lt;em&gt;averages&lt;/em&gt;. But in our case these are exceptions, not the norm. Because of that they will impact our &lt;em&gt;average&lt;/em&gt; values but not &lt;em&gt;median&lt;/em&gt; values. This is why I have found that splitting data into p50, p75, and p90 buckets really helps:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/posts-media/measure-what-matter/fig01.jpg&quot; alt=&quot;I split data into p50, p75, and p90 buckets and discard average data&quot;&gt;
&lt;em&gt;Screenshot from our PR cycle time dashboard&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The reason I have ended up using these 3 buckets for multiple metrics is for several reasons:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;p50 is what matters most&lt;/strong&gt;: it represents at least half of what your team experiences on a day-to-day basis, and is a solid baseline. If these numbers tend to show you have a problem, you will need to focus your efforts here first.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;p90 shows you the worst-case scenarios you likely still have some control over&lt;/strong&gt;: there will always be cases that are outside your team&apos;s control. You need to acknowledge and embrace this, which is why we discard the top 10% worst data. Why bother looking at it, if you cannot influence it? But the 90th percentile shows where your team is likely &amp;quot;suffering&amp;quot; the most, and where you may still have some level of control.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;p75 is the bridge between the 2&lt;/strong&gt;: when changing processes with the expectation it will positively correlate with your p90 data, you will likely see the impact on p75 first. This can create momentum and excitement, or, on the contrary, help you identify early whether an initiative is not paying off.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Another positive impact of using such buckets is it allows you to avoid sterile debates. Whenever an engineer starts arguing that such and such circumstances mess up our data, I remind them that these are A) exceptions, and B) likely to end up in our p90 bucket, or even in the top 10% we don&apos;t even have a graph for. &lt;em&gt;We should not care about those&lt;/em&gt;, nor use them as excuses not to look at our data.&lt;/p&gt;
&lt;p&gt;There will always be cases where the data is not 100% accurate, and this can lead to lack of trust. Find ways to circumvent this noise and recenter the conversation on what matters.&lt;/p&gt;
&lt;h1&gt;The real payoff: a deeper understanding of your team&lt;/h1&gt;
&lt;p&gt;For me, the main aha! moment was when I was playing with data and discovered that my best performing engineer had become a bottleneck for our team.&lt;/p&gt;
&lt;p&gt;This person had moved to a full stack position a few months prior, having been a frontend engineer before. Our team was now made up of 4 backend engineers, 1 frontend engineer, and 1 fullstack engineer. This meant our fullstack engineer had to review all PRs from our only frontend dev, but would also receive review requests from the backend engineers. I was playing with our data some day and wanted to see if there was a difference in throughput in backend Vs frontend PRs, as they use wildly different stacks. The difference was shocking: we were closing &lt;em&gt;way&lt;/em&gt; more frontend PRs per week compared to backend PRs! The frontend and fullstack engineers were producing code extremely quickly. So I thought, what about PR cycle time? Again I was shocked, but for another reason: &lt;strong&gt;the cycle times on the frontend PRs were way worse than the backend PRs!&lt;/strong&gt; How was that possible? It didn&apos;t make sense; how could the throughput be so &amp;quot;good&amp;quot; and yet the cycle time be so &amp;quot;bad&amp;quot;? So I started thinking and then it dawned on me: the fullstack engineer was perhaps overloaded with review requests. So I gathered the data it turned out he was doing almost &lt;strong&gt;50% of all PR reviews in the entire team!&lt;/strong&gt; But he was so good people barely noticed; he would still deliver his own work on time and didn&apos;t complain about being overloaded with requests. Except that his fellow frontend engineer was waiting longer, on average, on his reviews compared to his teammates. But he didn&apos;t dare complain because he knew his colleague was super busy. So this went unnoticed for months until I played with the data.&lt;/p&gt;
&lt;p&gt;This showed me that the data could be used as &lt;em&gt;signals&lt;/em&gt; to start better understanding the team&apos;s way of working.&lt;/p&gt;
&lt;h2&gt;The data is only as good as what you do with it&lt;/h2&gt;
&lt;p&gt;Say you change your spec process and make it a lot more thorough to avoid surprises. You can expect to see a slight dip in your PR throughput, although it shouldn&apos;t impact your PR cycle time. But, you would expect your change fail rate to drop, or your sprint burnup chart to show better results, etc. This correlation with data is very powerful, because we can now use data to check what we&apos;re doing well or not. We don&apos;t need to rely on our gut feeling (only); we should actually see impact in the data.&lt;/p&gt;
&lt;p&gt;This moves the conversation from subjective &amp;quot;feelings&amp;quot; to objectively measurable results. And the more you do this — the more you correlate, observe, and discuss — the more your team starts to &lt;em&gt;trust&lt;/em&gt; the data. Not because it&apos;s always right, but because they&apos;ve seen it help drive real change.&lt;/p&gt;
&lt;p&gt;Here&apos;s the thing: after a year of using DX, I&apos;m convinced using engineering-related productivity data is extremely powerful. What made it work for my team wasn&apos;t the software — it was deciding upfront that we&apos;d be open minded about it and use it to try to learn, not assess individual performance. Transparency over surveillance. Curiosity over judgment. Signals, not verdicts. If you get that mindset right, the tool almost doesn&apos;t matter — and your engineers won&apos;t just tolerate the dashboard, they&apos;ll start asking to look at it with you. That&apos;s when you know you&apos;ve got it right.&lt;/p&gt;
</description>
        <pubDate>Sun, 15 Feb 2026 00:00:00 GMT</pubDate>
        <link>https://wadmiraal.net/lore/2026/02/15/measure-what-matters/</link>
        <guid isPermaLink="true">https://wadmiraal.net/lore/2026/02/15/measure-what-matters/</guid>
      </item>
    
      <item>
        <title>Getting Hired: Make yourself visible</title>
        <description>&lt;p&gt;For any given job posting, you might be competing with dozens of other developers, perhaps with more experience than you. So how can you stand a chance to still get the job?&lt;/p&gt;
&lt;p&gt;The first thing I do when screening job applicants is looking for work that&apos;s available online. A link to some online repositories, like your GitHub or GitLab.com account, is a huge plus. Other things like CodePen can also be interesting (some interesting things you might do on CodePen include complex pure-CSS interactions, WebGL animations, or even a simple game).&lt;/p&gt;
&lt;h2&gt;Do Open Source work&lt;/h2&gt;
&lt;p&gt;One great way to build both experience and exposure is to contribute to some project you like, or even build something on your own. It doesn&apos;t even have to be useful! Building something fun and challenging can be a great opportunity to showcase what you can do.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If you contribute to an existing open source project, make sure your work is correctly credited and linked to your profile.&lt;/li&gt;
&lt;li&gt;If you build something on your own, make sure it&apos;s easy to actually try out (interviewers will likely look at this; ideally, build and host it somewhere — GitHub Pages are great for this — or give clear instructions for running it locally).
&lt;ul&gt;
&lt;li&gt;Spend some extra time to write a good &lt;code&gt;README&lt;/code&gt; file! Why? Because written communication is a very important skill; if you are able to explain what your project is about as well as give clear instructions on how to use it, it will be a good plus for your profile.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Write clean elegant code&lt;/h2&gt;
&lt;p&gt;Any code should be well written, but this is even more important for code that is publicly available.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Write good comments, follow a style guide, use good naming conventions, etc.&lt;/li&gt;
&lt;li&gt;If applicable, write good and thorough documentation. It can all be in the project&apos;s &lt;code&gt;README&lt;/code&gt;, or a wiki, etc.&lt;/li&gt;
&lt;li&gt;Write tests, and strive for high coverage.
&lt;ul&gt;
&lt;li&gt;If possible, add a CI to the mix and use the public badge it provides to showcase a successful build (e.g., &lt;a href=&quot;https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/monitoring-workflows/adding-a-workflow-status-badge&quot;&gt;GitHub Actions&lt;/a&gt;, &lt;a href=&quot;https://circleci.com/docs/status-badges/&quot;&gt;CircleCI&lt;/a&gt;, etc).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Use a tool like &lt;a href=&quot;https://sonarcloud.io/&quot;&gt;SonarCloud&lt;/a&gt; (free for open source projects) to improve your code, and show a quality gate badge on your project (documentation about that &lt;a href=&quot;https://docs.sonarsource.com/sonarcloud/managing-your-projects/managing-your-project-as-developer/#using-project-badge&quot;&gt;here&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Choose your new job wisely&lt;/h2&gt;
&lt;p&gt;If you&apos;re trying to land a first job and you have multiple options, choose wisely. Your first job will have a huge impact on the rest of your carreer.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;All other things equal, prefer a company that is active in open source. This will allow you to contribute to open source projects while getting paid for it. Those contributions will usually be public and can be linked to for future job applications.&lt;/li&gt;
&lt;li&gt;All other things equal, prefer a company willing to explore new technologies and techniques. A job writing Apex or Cobol might pay higher but the experience you get is also much narrower and you might end up coding yourself in a corner&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Invest in knowledge&lt;/h2&gt;
&lt;p&gt;Our industry is always on the move. Some of the things you learn today will not be relevant anymore in 5 years. This is exhilirating, but it also means we always need to invest into learning new things.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Always Keep learning. Read at least 1 technical book per year (preferably more).&lt;/li&gt;
&lt;li&gt;Put aside some time every week to code on personal projects, especially early in your carreer. Over time, you will invest less time and that&apos;s ok. But use your early career years to build up as much experience as you can, on and off the job.&lt;/li&gt;
&lt;li&gt;Read about other things! Learn about nature, art, history, whatever you fancy. The wider your horizon, the more likely you will be able to approach complex problems with a fresh perspective.&lt;/li&gt;
&lt;li&gt;Raise your hand if the company is asking for volunteers to try out or learn a new technology. Those are golden opportunities to learn new things while getting paid for it.&lt;/li&gt;
&lt;li&gt;Learn from great open source projects. Crack the code open, and read. See how others solve problems, not just technical, but also about code organisation, maintenability, documentation, etc. This is an invaluable and inexhaustible source of inspiration and knowledge. Use it.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Know they &lt;del&gt;enemy&lt;/del&gt; future employer&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;What&apos;s written on the job offer? Too many buzz words? Do you fear you are not a good match? Know that job offers using many buzz words sometimes serve to attract candidates, not filter them out. If you know JS well, but have no experience in React, you can learn on the job; don&apos;t let the lack of experience in specific frameworks turn you off. Of course, if they ask for Java and you only know JS or PHP, then it would be waste of time…&lt;/li&gt;
&lt;li&gt;Know the company! What do they do? What projects or products do they offer? Do they have a blog? Do employees speak at conferences? Gather as much info as you can. If such topics come up during the interview, it will allow you to show genuine interest in the company. And believe me, a candidate showing up for an interview that doesn&apos;t have a clue what the company actually does can be quite a show stopper.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Be bold&lt;/h2&gt;
&lt;p&gt;This is probably the hardest part. If you really want to stand out, you have to sometimes be a little bold.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Apply for the job and if you don&apos;t hear back about 1 week later, contact the company directly. If there is a phone number, call them (it&apos;s always better to call!) If not, try finding a personal email address of the person actually responsible for the hiring; using &lt;code&gt;info@&lt;/code&gt; or &lt;code&gt;contact@&lt;/code&gt; addresses should be a last resort (as you will likely not reach the right person).
&lt;ul&gt;
&lt;li&gt;Don&apos;t be pushy but show genuine enthusiasm and interest. For example, you could say something like “I sent an application last week. I would really love to work for your company. I was just wondering if you had received it and when would be a convenient time for an interview.”
You may be uncomfortable doing this but you&apos;re not being rude or arrogant; you are showing genuine interest and motivation. At worst, the person might be a little annoyed and tell you to be patient (“We&apos;ll come back to you”), but at best, this will help you stand out and get more attention than other candidates.&lt;/li&gt;
&lt;li&gt;Especially if you&apos;re very junior, show you&apos;re all pumped up and willing to learn.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;During the interview, don&apos;t be afraid to have an opinion! Strong opinions can be highly valued in a company (and, a company that doesn&apos;t value strong opinions is likely not a company you would want to work for anyway). Of course, having strong opinions is one thing, being arrogant is totally different; don&apos;t be arrogant.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Good luck! And I’d love to know how it goes; don’t hesitate to ping me.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Further reading:&lt;/strong&gt; I highly recommend checking out &lt;a href=&quot;https://austinkleon.com/show-your-work/&quot;&gt;Show Your Work&lt;/a&gt; by Austin Kleon. The book is mostly targeted at creatives, but a lot of tips apply to software engineers. You can read an article I wrote about this book &lt;a href=&quot;/lore/2018/01/15/book-review-show-your-work/&quot;&gt;here&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
</description>
        <pubDate>Sun, 13 Oct 2024 00:00:00 GMT</pubDate>
        <link>https://wadmiraal.net/lore/2024/10/13/getting-hired-make-yourself-visible/</link>
        <guid isPermaLink="true">https://wadmiraal.net/lore/2024/10/13/getting-hired-make-yourself-visible/</guid>
      </item>
    
      <item>
        <title>Getting Hired: Nobody reads your cover letter</title>
        <description>&lt;p&gt;At the time of writing, there is a huge demand for software developers. And yet, some developers struggle to get hired. What gives?&lt;/p&gt;
&lt;p&gt;If you find yourself in this situation, whether you&apos;re a junior starting out, or a seasoned professional, it can be caused by two things:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You&apos;re terrible at programming (unlikely)&lt;/li&gt;
&lt;li&gt;You&apos;re not selling yourself right (much more likely)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Over the years, I&apos;ve given advice to several junior developers on how to land their first job. I&apos;ve also been responsible for hiring new developers at multiple companies. Here&apos;s one important thing you must know:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Nobody reads your cover letter&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Let me state that again:&lt;/p&gt;
&lt;h3&gt;Nobody reads your cover letter&lt;/h3&gt;
&lt;p&gt;It&apos;s so obvious, yet so many applications I&apos;ve seen seem to bet everything on only that. The cover letter is the &lt;em&gt;least&lt;/em&gt; important part of your application. How so?&lt;/p&gt;
&lt;p&gt;A company will receive dozens of applications for a single job posting. And almost all of them look the same: cheap, ugly, Word-template-based résumés, and a cover letter. Here&apos;s how I assess applications:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Any links to online work? Click and check it out.&lt;/li&gt;
&lt;li&gt;Scan through the résumé: any interesting experience, what kind of education?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Based on this first assessment, applications will either pass and receive some further scrutiny, or they are discarded. Notice the cover letter wasn&apos;t read. Who has time to read +20 letters, even more so if their résumé doesn&apos;t fit our expectations anyway?&lt;/p&gt;
&lt;p&gt;So what should you do instead?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;You must stand out!&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;Show your work&lt;/h2&gt;
&lt;p&gt;The first things I look for in any application is a &lt;em&gt;clickable*&lt;/em&gt; link to online work, preferably to a place where I can see actual code (GitHub, CodePen, you name it).&lt;/p&gt;
&lt;p&gt;Seeing code is much more valuable than reading about past job experiences. Just by looking at a piece of code, experienced developers can tell a lot about your level of expertise, and the way you work. You don&apos;t get that from a résumé. A junior developer with an impressive CodePen account is more interesting (to me) than a senior developer with pompous titles, but no code to look at. The former is demonstrating their skill; the latter, for all I know, might be only good at company politics and climbing ladders (seasoned developers know this happens way more often than it should).&lt;/p&gt;
&lt;p&gt;This is where junior developers can shine: don&apos;t have much (or any) work experience yet? Real code you wrote can convince companies to give you a chance to prove yourself. Write code in your free time, contribute to open source, put stuff online (I&apos;ll write more about this in another post). This will greatly improve your chances of landing a job.&lt;/p&gt;
&lt;h2&gt;Have a brutal look at your résumé&lt;/h2&gt;
&lt;p&gt;The second thing I look at is the résumé. And often, it&apos;s kind of a mess.&lt;/p&gt;
&lt;p&gt;Look at your résumé as if it were someone else&apos;s. What does it look like? Is it clear and easy to read? Is it relevant?&lt;/p&gt;
&lt;p&gt;Don&apos;t listen to well-meaning relatives saying:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;You should put &lt;em&gt;every&lt;/em&gt; work experience you have in there.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Sure, that might be true for some industries. But for the software world, focus on what matters. I don&apos;t care if you&apos;ve worked at your local grocery store, or if you were an intern at your uncle&apos;s law firm. If it hasn&apos;t helped you get better at writing code, then what&apos;s the point **?&lt;/p&gt;
&lt;p&gt;Make information that &lt;em&gt;matters&lt;/em&gt; prominent (i.e.: links to online work, &lt;em&gt;relevant&lt;/em&gt; job experiences). Keep it short and easy to scan through. Don&apos;t cram everything into a single page if this hurts legibility (the single-page-résumé myth is just that: a myth). Of course, if you need more than 2 pages, it seems unlikely all of it is relevant. Remove what isn&apos;t.&lt;/p&gt;
&lt;h2&gt;Don&apos;t write a cover letter; write documentation&lt;/h2&gt;
&lt;p&gt;Usually, cover letters might get read only when the company thinks you are a technical fit. And here&apos;s what they will look for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Motivation&lt;/li&gt;
&lt;li&gt;How well you write&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Motivation can be stated in a few sentences. Don&apos;t write a novel. Respect people&apos;s time.&lt;/p&gt;
&lt;p&gt;How well you write, I&apos;d argue, is much better demonstrated &lt;em&gt;in actual projects&lt;/em&gt;. Writing well is important, as people who write well tend to be better at communicating complex ideas. Notice that “writing well” in our context doesn&apos;t mean “writing prose” or “writing a lot”. It means getting ideas across in a clear, easy to read manner. Think &lt;em&gt;documentation&lt;/em&gt;, not &lt;em&gt;Jane Austen&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;I recommend you write clear and legible code, and &lt;em&gt;comment&lt;/em&gt; your code (and, of course, make this code available online). Write documentation for a project (never underestimate the power of a &lt;code&gt;README&lt;/code&gt; file). These can demonstrate real world situations where your writing skills are put to use. This is much more interesting to a potential employer than prose.&lt;/p&gt;
&lt;h2&gt;Exceptions&lt;/h2&gt;
&lt;p&gt;After reading all this, you might think that cover letters are completely irrelevant. There are times, though, where they are (unfortunately) necessary. I&apos;d say in either of the following situations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;When the job posting shows lack of understanding for our industry&lt;/li&gt;
&lt;li&gt;When applying at a very large firm, that is not specifically technology-oriented&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If the job posting seems odd, and shows a lack of understanding (i.e.: uses buzzwords a lot, asks for strange things like “Must know JavaScript and ECMAScript 6”, etc), it may be a sign that the hiring is done by some HR department, that might not have a clue. This is usually an indication that they will also do the first assessment, which means they won&apos;t look at your code. They can only judge you by your cover letter and résumé. In this situation, do spend time writing a good cover letter, and do put some more work experience into your résumé (like that time you worked at the grocery store).&lt;/p&gt;
&lt;p&gt;&lt;em&gt;But remember&lt;/em&gt;: if you pass the first hurdles, you will get assessed by technical people at some point, so keep all the above in mind!&lt;/p&gt;
&lt;p&gt;The same can be true when applying at a very large firm, that&apos;s not specifically into software (e.g.: ACME Staplers Inc wants to hire a new developer for their B2B portal). Here again, applications might first go through HR, before landing on a developer&apos;s desk.&lt;/p&gt;
&lt;h2&gt;Ask for feedback&lt;/h2&gt;
&lt;p&gt;Once you&apos;ve prepared your application, don&apos;t hesitate to ask for feedback. Do you know a senior developer somewhere? Do you participate in any tech communities online? Reach out, and get feedback.&lt;/p&gt;
&lt;p&gt;Finally, if your application does get rejected, don&apos;t despair. Reach out to the company, and politely ask why you didn&apos;t get the job. Explain you want to get better. Not only will it help you improve, but some companies might even be impressed and give you a second chance.&lt;/p&gt;
&lt;p&gt;Good luck! And I&apos;d love to know how it goes; don&apos;t hesitate to ping me.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Further reading:&lt;/strong&gt; I highly recommend checking out &lt;a href=&quot;https://www.goodreads.com/book/show/641604.Purple_Cow&quot;&gt;The Purple Cow&lt;/a&gt; by Seth Godin. It&apos;s about standing out in general, but the clever reader will see this can be applied to job searching as well. There&apos;s even a short chapter about exactly that.&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;em&gt;* Please don&apos;t make people copy-paste URLs. What is this, 2005?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;** Of course, if you&apos;ve worked +10 years in some industry, and are now re-orienting yourself to programming, that&apos;s another story.&lt;/em&gt;&lt;/p&gt;
</description>
        <pubDate>Wed, 23 Oct 2019 00:00:00 GMT</pubDate>
        <link>https://wadmiraal.net/lore/2019/10/23/getting-hired-nobody-reads-your-cover-letter/</link>
        <guid isPermaLink="true">https://wadmiraal.net/lore/2019/10/23/getting-hired-nobody-reads-your-cover-letter/</guid>
      </item>
    
      <item>
        <title>Simple functional testing in Drupal 8 with Travis CI</title>
        <description>&lt;p&gt;I was inspired to test this out when I read &lt;a href=&quot;https://www.lullabot.com/articles/the-simplest-path-to-a-drupal-local-environment&quot;&gt;this post&lt;/a&gt; by Lullabot. In many examples you can find online, you&apos;ll see a rather complex setting up process, usually including installing MySQL, Pear, Drush, and sometimes even a webserver.&lt;/p&gt;
&lt;p&gt;I&apos;m a big fan of SQLite in automated testing environments. It&apos;s much faster and simpler to set up, and usually comes pre-installed with many CI runners. Installing MySQL (or any other RDBS) is overkill, unless you use vendor-only functionality (which you shouldn&apos;t, if you can avoid it).&lt;/p&gt;
&lt;p&gt;Many examples make use of PHP&apos;s built-in ability to serve pages, which is a great idea. Sure, it&apos;s not fast nor efficient. But it makes more than up for the fact that you don&apos;t have to install something like Apache or NginX.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/wadmiraal/drupal8_tdd_form_validation/tree/functional_test_example&quot;&gt;Here&apos;s a working example for a module with functional tests&lt;/a&gt;. It is taken from &lt;a href=&quot;/lore/2018/02/12/drupal-forms-and-tdd-part-3-form-validation/&quot;&gt;part 3&lt;/a&gt; of my Drupal 8 TDD tutorial (the bonus video).&lt;/p&gt;
&lt;h2&gt;Functional tests require a full Drupal site&lt;/h2&gt;
&lt;p&gt;Just as with kernel tests (see my previous article about &lt;a href=&quot;/lore/2018/01/22/drupal-8-with-travisci-and-sonarcloud/&quot;&gt;using Travis CI and Sonarcloud here&lt;/a&gt;), we need a full Drupal code base. I find it convenient to use the &lt;a href=&quot;https://github.com/drupal-composer/drupal-project&quot;&gt;Composer template for Drupal projects&lt;/a&gt;. It installs Drupal in a nice, flexible, and standard way, which is how I structure my Drupal 8 projects.&lt;/p&gt;
&lt;p&gt;The only caveat is that, after getting the source code, your module code is no longer in the correct place. There are several ways around this, but I find it easiest to simply copy my module code to the correct location.&lt;/p&gt;
&lt;p&gt;You could also &lt;code&gt;cd&lt;/code&gt; into another directory, like &lt;code&gt;/tmp&lt;/code&gt;, install Drupal there, and then create a symlink to &lt;code&gt;$TRAVIS_BUILD_DIR&lt;/code&gt;. But I&apos;m afraid of potential future permission issues, in case Travis decides to change something in its default setup. Hence, I keep everything in the build directory, where I &lt;em&gt;know&lt;/em&gt; we have full write permissions.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note: if you&apos;re testing a full Drupal code base, then you obviously don&apos;t need this step, but would replace it with something like &lt;code&gt;composer install&lt;/code&gt; or &lt;code&gt; drush make&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;A working example&lt;/h2&gt;
&lt;p&gt;Here&apos;s our example &lt;code&gt;.travis.yml&lt;/code&gt; file:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;language: php
php:
  - &apos;7.0&apos;
  - &apos;7.1&apos;
cache:
  directories:
    - $HOME/.composer/cache/files
install:
  # We need a full Drupal project for our functional tests to work. Create a new project.
  - composer create-project drupal-composer/drupal-project:8.x-dev drupal --stability dev --no-interaction
  # Our code is no longer in the correct place. Copy it over.
  - mkdir -p drupal/web/modules/form_validation &amp;&amp; cp -a form_validation* tests src drupal/web/modules/form_validation
  # Run PHP as a webserver, in the background
  - (php -S localhost:8888 -t $(pwd)/drupal/web/ &amp;) &gt;&gt; /dev/null 2&gt;&amp;1
script:
  - cd drupal/web &amp;&amp; php ./core/scripts/run-tests.sh --php $(which php) --dburl sqlite://tmp/tests.sqlite --sqlite /tmp/tests.sqlite --url http://127.0.0.1:8888/ --directory modules/form_validation/tests/ --concurrency 4

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let&apos;s go over these lines:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;language: php
php:
  - &apos;7.0&apos;
  - &apos;7.1&apos;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;These are no-brainers: we&apos;re telling Travis to run these tests in PHP 7.0 and 7.1 environments.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;cache:
  directories:
    - $HOME/.composer/cache/files
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here we tell Travis CI to keep the Composer cache between builds, which greatly speeds things up.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;install:
  - composer create-project drupal-composer/drupal-project:8.x-dev drupal --stability dev --no-interaction
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is where we download a full copy of Drupal. We use the &lt;a href=&quot;https://github.com/drupal-composer/drupal-project&quot;&gt;Composer template for Drupal projects&lt;/a&gt;, and save it to a folder called &lt;code&gt;drupal&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Next…&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;  - mkdir -p drupal/web/modules/form_validation &amp;&amp; cp -a form_validation* tests src drupal/web/modules/form_validation
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here, we copy all our code over to the &lt;code&gt;drupal/web/modules/form_validation&lt;/code&gt; directory. This is necessary for functional tests, which will only work if put under the Drupal root.&lt;/p&gt;
&lt;p&gt;Next…&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;  - (php -S localhost:8888 -t $(pwd)/drupal/web/ &amp;) &gt;&gt; /dev/null 2&gt;&amp;1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here, we use PHP&apos;s built-in webserver, and tell it to serve from our new webroot. We make it run in the background, and redirect all output to &lt;code&gt;/dev/null&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;At this point, we&apos;re all set up. Notice that this is very simple. If your project is a Drupal project, instead of a module like here, you could omit the part where we download core, and replace it with your own build mechanism.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;script:
  - cd drupal/web &amp;&amp; php ./core/scripts/run-tests.sh --php $(which php) --dburl sqlite://tmp/tests.sqlite --sqlite /tmp/tests.sqlite --url http://127.0.0.1:8888/ --directory modules/form_validation/tests/ --concurrency 4
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here we finally do the running part. There&apos;s a lot going on in there, so let me break it down into chunks:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;--php $(which php)&lt;/code&gt;&lt;/pre&gt;
Within the Travis CI runner, &lt;code&gt;core/scripts/run-tests.sh&lt;/code&gt; seems to have some issues finding the PHP binaries. We use this to point it to correct location.&lt;/li&gt;
&lt;li&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;--dburl sqlite://tmp/tests.sqlite&lt;/code&gt;&lt;/pre&gt;
&lt;code&gt;core/scripts/run-tests.sh&lt;/code&gt; expects a Drupal site to be installed, and will look for the default database in the &lt;code&gt;settings.php&lt;/code&gt; file. But we didn&apos;t install Drupal. Here, we simply point it to a dummy SQLite database file. It doesn&apos;t even need to exist; it&apos;s just to keep it from complaining.&lt;/li&gt;
&lt;li&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;--sqlite /tmp/tests.sqlite&lt;/code&gt;&lt;/pre&gt;
Here we specify which database to use for the actual tests. Because we want to use SQLite, we have to use this &lt;code&gt;--sqlite&lt;/code&gt; option, and cannot simply rely on &lt;code&gt;--dburl&lt;/code&gt;. Go figure.&lt;/li&gt;
&lt;li&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;--url http://127.0.0.1:8888/&lt;/code&gt;&lt;/pre&gt;
Here we specify at what URL the site is running. This is necessary for the functional tests.&lt;/li&gt;
&lt;li&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;--directory modules/form_validation/tests/&lt;/code&gt;&lt;/pre&gt;
Here we specify where our tests are located. It&apos;s a bit easier than listing classes, or specifying a group.&lt;/li&gt;
&lt;li&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;--concurrency 4&lt;/code&gt;&lt;/pre&gt;
Here we specify how many test classes to run in parallel. Depending on the CI environment and your use-case, you can adjust this value. If you start running into unexplainable errors, it may be because this value is too high, and tests start getting mixed up.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that, as opposed to my previous examples, here we don&apos;t use PHPUnit to run our tests. This is because Drupal&apos;s &lt;code&gt;core/scripts/run-tests.sh&lt;/code&gt; script can run tests in parallel, which is harder to achieve with PHPUnit. Furthermore, you cannot compute code coverage when running functional tests, so PHPUnit wouldn&apos;t really have added any value anyway.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;As I&apos;ve mentioned many times before, I&apos;m not advocating the use of functional tests in Drupal projects. I really recommend you use unit and/or kernel tests instead. However, sometimes there really is no other option (like, when adding tests for existing code). And for those cases, knowing how to easily setup your favorite CI environment can be a real help.&lt;/p&gt;
</description>
        <pubDate>Mon, 12 Mar 2018 00:00:00 GMT</pubDate>
        <link>https://wadmiraal.net/lore/2018/03/12/simple-functional-testing-in-drupal-8-with-travisci/</link>
        <guid isPermaLink="true">https://wadmiraal.net/lore/2018/03/12/simple-functional-testing-in-drupal-8-with-travisci/</guid>
      </item>
    
      <item>
        <title>Book review: &amp;ldquo;Deep Work&amp;rdquo;, by Cal Newport</title>
        <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;DEEP WORK:&lt;/strong&gt; Professional activities performed in a state of distraction-free concentration that pushes your cognitive capabilities to their limit.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;To say this book has changed my way of organising my work and personal life is an understatement. I started reading—actually, &lt;em&gt;studying&lt;/em&gt; is a better term—during the last week of December 2017, and first week of January 2018. I usually read books of this length in a few days, but this one begged to be mulled over.&lt;/p&gt;
&lt;p&gt;It has drastically changed the way I do things and organize my life. In fact, as you may have noticed, I started blogging again. I decided to try and aim for 1 post a week in the first half of 2018. And I&apos;m pretty well on track so far, while having more responsibilities and obligations, both professionally and personally, than in 2017.&lt;/p&gt;
&lt;p&gt;I decided to read &lt;em&gt;&lt;a href=&quot;http://calnewport.com/books/deep-work/&quot;&gt;Deep Work&lt;/a&gt;&lt;/em&gt; after reading a blog post entitled &lt;a href=&quot;https://www.lullabot.com/articles/deep-work-gaining-focus-and-reaching-for-nobility-in-your-work&quot;&gt;Deep Work: Gaining Focus and Nobility in Your Work&lt;/a&gt;. It struck a chord in me. Some of the highlighted points were exactly things I struggled with, or wanted to achieve.&lt;/p&gt;
&lt;h2&gt;Embrace boredom&lt;/h2&gt;
&lt;p&gt;We live in a highly connected world, where distraction is just a tap away. How often do you find yourself having to wait for more than 1 minute, and automatically grabbing your phone to check up on some Tweets, emails, etc? How often, if you have more than 10 minutes on your hands, will you open Youtube?&lt;/p&gt;
&lt;p&gt;I did that. A lot. I didn&apos;t even do it to “just pass the time”. I did it to &lt;em&gt;use&lt;/em&gt; my time efficiently—or so I thought. I used this to quickly catch up on interesting Tweets, for instance (I mainly follow people that work in our industry, not so much friends or relatives). I&apos;m a big fan of learning, and love Youtube channels like &lt;a href=&quot;http://kurzgesagt.org/&quot;&gt;Kurzgesagt&lt;/a&gt;, &lt;a href=&quot;https://thecrashcourse.com/&quot;&gt;Crash Course&lt;/a&gt;, and &lt;a href=&quot;https://ed.ted.com/&quot;&gt;Ted ED&lt;/a&gt;. So, when commuting, or waiting for a doctor&apos;s appointment, why not learn something, thanks to these bite-sized videos which usually last less than 10 minutes?&lt;/p&gt;
&lt;p&gt;It turns out, this is &lt;em&gt;terribly wrong&lt;/em&gt;. It becomes addictive. I would use every spare minute during my day to try and squeeze in some more information. But, as Cal Newport puts it in this book, it&apos;s a “shallow” type of information and brain activity. It trains the brain to crave for small, distracting pieces of information, and makes it lose the ability for longer bouts of intense concentration and creativity. It&apos;s also pretty tiring, which at times left me feeling mentally exhausted, but without a sense of having used my time wisely.&lt;/p&gt;
&lt;p&gt;So when Cal Newport goes on to prove, using scientifc studies for supporting evidence, how much these habits can hurt, not only our day-to-day job performance, but in fact &lt;em&gt;every aspect of your life&lt;/em&gt;, it makes you stop and think really hard about your daily habits.&lt;/p&gt;
&lt;p&gt;I, for instance, decided to uninstall Twitter, and remove Youtube from my phone&apos;s home screen. I unsubscribed from all newsletters except one. I removed several sources from my RSS reader, and unsubscribed from several podcasts, only keeping the most relevant ones. I also introduced specific time slots in my week schedule for consuming these kinds of information, so I&apos;m not tempted to read or listen to them whenever I have some time on my hands (for example, I only read blog articles on my evening commute, and listen to podcasts at the gym or while doing chores).&lt;/p&gt;
&lt;p&gt;Since the beginning of the year, I try really hard to embrace boredom, to not immediately grab my phone whenever I have to wait for something. Instead, I try to let my mind wander, focus on some tricky tasks, or simply enjoy my surroundings.&lt;/p&gt;
&lt;p&gt;And it &lt;em&gt;&lt;strong&gt;really&lt;/strong&gt;&lt;/em&gt; works.&lt;/p&gt;
&lt;h2&gt;Get rid of distractions&lt;/h2&gt;
&lt;p&gt;I &lt;em&gt;hate&lt;/em&gt; being distracted at work. When you focus on something difficult and challenging, there&apos;s nothing worse than have someone ask you a stupid question on Slack, which would have taken him/her 5mins to figure out for themselves.&lt;/p&gt;
&lt;p&gt;But I do that, too.&lt;/p&gt;
&lt;p&gt;We all do. It&apos;s so easy. Struggle with something? Ask Jane, she&apos;s online, and probably has the answer. Forgot where that piece of documentation was? Instead of doing a quick search, ping Richard; he probably knows.&lt;/p&gt;
&lt;p&gt;Cal Newport has whole sections dedicated to these kinds of distractions, but also, more importantly, &lt;em&gt;how you can deal with them&lt;/em&gt;. It&apos;s brilliant.&lt;/p&gt;
&lt;p&gt;I think the best advice is that, &lt;em&gt;you don&apos;t have to answer immediately!&lt;/em&gt; We think we should answer chat messages within seconds, and emails within the next 15 minutes. But the fact (usually) is: you don&apos;t. If you ignore most chat messages in group channels, and only answer your emails once every other hour, you&apos;re &lt;em&gt;probably&lt;/em&gt; going to be OK (of course, there are exceptions to these rules, especially if you deal with client support).&lt;/p&gt;
&lt;p&gt;I disabled all notifications on my phone for work-related emails and chat. I now use Slack&apos;s &lt;em&gt;snooze&lt;/em&gt; functionality aggressively when I know I have to concentrate. I try to plan my work load in such a way that I get smaller, “shallow” tasks done in batches, so I have long stretches of time to focus on more complex tasks.&lt;/p&gt;
&lt;p&gt;And here again, it &lt;em&gt;&lt;strong&gt;really&lt;/strong&gt;&lt;/em&gt; works.&lt;/p&gt;
&lt;h2&gt;Almost a philosophical journey&lt;/h2&gt;
&lt;p&gt;Some parts of the book touch on aspects deeply ingrained in our human nature, like the way we function, the things that give us satisfaction, or can make us happy. Cal Newport uses research in fields like neurology, psychology, and sociology to make a clear case in favor of “deep work”.&lt;/p&gt;
&lt;p&gt;The part about the blacksmith Ric Furrer is a striking example of this, demonstrating how humans can find great pride and satisfaction in craftsmanship. I find it beautifully summarized in this quote:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A wooden wheel is not noble, but it&apos;s shaping can be.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It then traces a parallel with modern “knowledge worker” trades, which &lt;em&gt;can&lt;/em&gt; achieve the same level of depth and satisfaction as craftsmanships of old.&lt;/p&gt;
&lt;h2&gt;This is just the tip of the iceberg&lt;/h2&gt;
&lt;p&gt;There&apos;s so much valuable information in this book that it&apos;s impossible to summarize all of it here. And it&apos;s pretty dense and deep, so, in order to get the most out of it, I suggest you don&apos;t just read it like a novel. Instead, find some quiet time, go over the ideas in sequence, and don&apos;t hesitate to pause and think. I used some markers, and pen and paper to make notes, to think about how some things apply to my daily life, and what strategies I could use to make it better.&lt;/p&gt;
&lt;p&gt;For example, the next thing I&apos;d like to implement is Cal Newport&apos;s strategies to mitigate the &lt;a href=&quot;https://en.wikipedia.org/wiki/Zeigarnik_effect&quot;&gt;Zeigarnik effect&lt;/a&gt; (I had never heard of it either). It takes time and practice. But even implementing the most simple ideas of this book will already get you a long way.&lt;/p&gt;
&lt;p&gt;So, I won&apos;t distract you further. I simply &lt;em&gt;highly&lt;/em&gt; recommend you read this book.&lt;/p&gt;
</description>
        <pubDate>Mon, 26 Feb 2018 00:00:00 GMT</pubDate>
        <link>https://wadmiraal.net/lore/2018/02/26/book-review-deep-work/</link>
        <guid isPermaLink="true">https://wadmiraal.net/lore/2018/02/26/book-review-deep-work/</guid>
      </item>
    
      <item>
        <title>Drupal 8 Forms and TDD, part 4: form submission</title>
        <description>&lt;p&gt;In &lt;a href=&quot;/lore/2018/01/29/drupal-forms-and-tdd-part-1-file-validation/&quot;&gt;part 1&lt;/a&gt;, I showed how you can start using &lt;abbr title=&quot;Test Driven Development&quot;&gt;TDD&lt;/abbr&gt; when writing Drupal code, and how to apply it to testing a custom file validation callback. In &lt;a href=&quot;/lore/2018/02/05/drupal-forms-and-tdd-part-2-form-building/&quot;&gt;part 2&lt;/a&gt;, we tackled testing the form building, and in &lt;a href=&quot;/lore/2018/02/12/drupal-forms-and-tdd-part-3-form-validation/&quot;&gt;part 3&lt;/a&gt;, the form validation. In this final part, I&apos;ll show how you can test the form submission.&lt;/p&gt;
&lt;iframe src=&quot;https://www.youtube.com/embed/6_EmyfYp_7U&quot; width=&quot;700&quot; height=&quot;394&quot; frameborder=&quot;0&quot; allow=&quot;autoplay; encrypted-media&quot; allowfullscreen&gt;&lt;/iframe&gt;
&lt;h2&gt;Links&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;/lore/2018/01/29/drupal-forms-and-tdd-part-1-file-validation/&quot;&gt;Part 1&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/lore/2018/02/05/drupal-forms-and-tdd-part-2-form-building/&quot;&gt;Part 2&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/lore/2018/02/12/drupal-forms-and-tdd-part-3-form-validation/&quot;&gt;Part 3&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;a href=&quot;https://github.com/wadmiraal/drupal8_tdd_form_validation&quot;&gt;source code&lt;/a&gt; for the example.&lt;/li&gt;
&lt;li&gt;The &lt;a href=&quot;https://github.com/drupal-composer/drupal-project&quot;&gt;Composer template for Drupal project&lt;/a&gt; used for the project structure.&lt;/li&gt;
&lt;li&gt;The &lt;a href=&quot;https://api.drupal.org/api/drupal/core%21core.api.php/group/testing/8.5.x&quot;&gt;official documentation for writing automated tests in Drupal 8&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 19 Feb 2018 00:00:00 GMT</pubDate>
        <link>https://wadmiraal.net/lore/2018/02/19/drupal-forms-and-tdd-part-4-form-submission/</link>
        <guid isPermaLink="true">https://wadmiraal.net/lore/2018/02/19/drupal-forms-and-tdd-part-4-form-submission/</guid>
      </item>
    
      <item>
        <title>Drupal 8 Forms and TDD, part 3: form validation</title>
        <description>&lt;p&gt;In &lt;a href=&quot;/lore/2018/01/29/drupal-forms-and-tdd-part-1-file-validation/&quot;&gt;part 1&lt;/a&gt;, I showed how you can start using &lt;abbr title=&quot;Test Driven Development&quot;&gt;TDD&lt;/abbr&gt; when writing Drupal code, and how to apply it to testing a custom file validation callback. In &lt;a href=&quot;/lore/2018/02/05/drupal-forms-and-tdd-part-2-form-building/&quot;&gt;part 2&lt;/a&gt;, we tackled testing the form building. In this part, I&apos;ll show how you can test the form validation.&lt;/p&gt;
&lt;iframe src=&quot;https://www.youtube.com/embed/yLpNHiTVlhY&quot; width=&quot;700&quot; height=&quot;394&quot; frameborder=&quot;0&quot; allow=&quot;autoplay; encrypted-media&quot; allowfullscreen&gt;&lt;/iframe&gt;
&lt;p&gt;I also decided to shoot a quick bonus video with a functional test, to demonstrate the difference in time execution. Food for thought: in our particular example, the functional tests take &lt;strong&gt;~300x&lt;/strong&gt; longer than the unit tests, without adding any more value. As I mention towards the end, you could probably get that down to “only” 60x times longer, at the cost of maintainability.&lt;/p&gt;
&lt;iframe src=&quot;https://www.youtube.com/embed/Mze8aLFecp0&quot; width=&quot;700&quot; height=&quot;394&quot; frameborder=&quot;0&quot; allow=&quot;autoplay; encrypted-media&quot; allowfullscreen&gt;&lt;/iframe&gt;
&lt;h2&gt;Links&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;/lore/2018/01/29/drupal-forms-and-tdd-part-1-file-validation/&quot;&gt;Part 1&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/lore/2018/02/05/drupal-forms-and-tdd-part-2-form-building/&quot;&gt;Part 2&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/lore/2018/02/19/drupal-forms-and-tdd-part-4-form-submission/&quot;&gt;Part 4&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;a href=&quot;https://github.com/wadmiraal/drupal8_tdd_form_validation&quot;&gt;source code&lt;/a&gt; for the example.&lt;/li&gt;
&lt;li&gt;The &lt;a href=&quot;https://github.com/drupal-composer/drupal-project&quot;&gt;Composer template for Drupal project&lt;/a&gt; used for the project structure.&lt;/li&gt;
&lt;li&gt;The &lt;a href=&quot;https://api.drupal.org/api/drupal/core%21core.api.php/group/testing/8.5.x&quot;&gt;official documentation for writing automated tests in Drupal 8&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 12 Feb 2018 00:00:00 GMT</pubDate>
        <link>https://wadmiraal.net/lore/2018/02/12/drupal-forms-and-tdd-part-3-form-validation/</link>
        <guid isPermaLink="true">https://wadmiraal.net/lore/2018/02/12/drupal-forms-and-tdd-part-3-form-validation/</guid>
      </item>
    
      <item>
        <title>Drupal 8 Forms and TDD, part 2: form building</title>
        <description>&lt;p&gt;In &lt;a href=&quot;/lore/2018/01/29/drupal-forms-and-tdd-part-1-file-validation/&quot;&gt;part 1&lt;/a&gt;, I showed how you can start using &lt;abbr title=&quot;Test Driven Development&quot;&gt;TDD&lt;/abbr&gt; when writing Drupal code, and how to apply it to testing a custom file validation callback. In this part, I&apos;ll show how you can test the form building.&lt;/p&gt;
&lt;iframe src=&quot;https://www.youtube.com/embed/spY5tu1JT1U&quot; width=&quot;700&quot; height=&quot;394&quot; frameborder=&quot;0&quot; allow=&quot;autoplay; encrypted-media&quot; allowfullscreen&gt;&lt;/iframe&gt;
&lt;h2&gt;Links&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;/lore/2018/01/29/drupal-forms-and-tdd-part-1-file-validation/&quot;&gt;Part 1&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/lore/2018/02/12/drupal-forms-and-tdd-part-3-form-validation/&quot;&gt;Part 3&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/lore/2018/02/19/drupal-forms-and-tdd-part-4-form-submission/&quot;&gt;Part 4&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;a href=&quot;https://github.com/wadmiraal/drupal8_tdd_form_validation&quot;&gt;source code&lt;/a&gt; for the example.&lt;/li&gt;
&lt;li&gt;The &lt;a href=&quot;https://github.com/drupal-composer/drupal-project&quot;&gt;Composer template for Drupal project&lt;/a&gt; used for the project structure.&lt;/li&gt;
&lt;li&gt;The &lt;a href=&quot;https://api.drupal.org/api/drupal/core%21core.api.php/group/testing/8.5.x&quot;&gt;official documentation for writing automated tests in Drupal 8&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 05 Feb 2018 00:00:00 GMT</pubDate>
        <link>https://wadmiraal.net/lore/2018/02/05/drupal-forms-and-tdd-part-2-form-building/</link>
        <guid isPermaLink="true">https://wadmiraal.net/lore/2018/02/05/drupal-forms-and-tdd-part-2-form-building/</guid>
      </item>
    
      <item>
        <title>Drupal 8 Forms and TDD, part 1: file validation</title>
        <description>&lt;p&gt;Traditionally, testing Drupal forms has mainly consisted of testing the form through the UI using functional tests. However, with the revamp of the Forms API to a fully &lt;abbr title=&quot;Object Oriented&quot;&gt;OO&lt;/abbr&gt; paradigm, using unit tests has now become much easier.&lt;/p&gt;
&lt;p&gt;Using TDD when writing a form requires us to think a little bit differently about our code, compared to a more traditional approach. In this example, I&apos;ll consider a form with 3 particularities :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a CSV file upload with a custom validation callback&lt;/li&gt;
&lt;li&gt;a field that only appears for users with a certain permission&lt;/li&gt;
&lt;li&gt;a text field with a format validation&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Furthermore, upon submission, we will parse the CSV file and create new entities. I&apos;ll treat this as a series of posts. In this first post, we&apos;ll look how to get set up, and how to use TDD when writing a custom file validation callback.&lt;/p&gt;
&lt;iframe width=&quot;700&quot; height=&quot;394&quot; src=&quot;https://www.youtube.com/embed/iK15gqkV9oc&quot; frameborder=&quot;0&quot; allow=&quot;autoplay; encrypted-media&quot; allowfullscreen&gt;&lt;/iframe&gt;
&lt;h2&gt;Links&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;/lore/2018/02/05/drupal-forms-and-tdd-part-2-form-building/&quot;&gt;Part 2&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/lore/2018/02/12/drupal-forms-and-tdd-part-3-form-validation/&quot;&gt;Part 3&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/lore/2018/02/19/drupal-forms-and-tdd-part-4-form-submission/&quot;&gt;Part 4&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;a href=&quot;https://github.com/wadmiraal/drupal8_tdd_form_validation&quot;&gt;source code&lt;/a&gt; for the example.&lt;/li&gt;
&lt;li&gt;The &lt;a href=&quot;https://github.com/drupal-composer/drupal-project&quot;&gt;Composer template for Drupal project&lt;/a&gt; used for the project structure.&lt;/li&gt;
&lt;li&gt;The &lt;a href=&quot;https://api.drupal.org/api/drupal/core%21core.api.php/group/testing/8.5.x&quot;&gt;official documentation for writing automated tests in Drupal 8&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 29 Jan 2018 00:00:00 GMT</pubDate>
        <link>https://wadmiraal.net/lore/2018/01/29/drupal-forms-and-tdd-part-1-file-validation/</link>
        <guid isPermaLink="true">https://wadmiraal.net/lore/2018/01/29/drupal-forms-and-tdd-part-1-file-validation/</guid>
      </item>
    
      <item>
        <title>Drupal 8 with Travis CI and Sonarcloud</title>
        <description>&lt;p&gt;Using a service like Travis CI or Sonarcloud has always seemed like the holly grail for Drupal projects. It&apos;s unfortunate that these usually require quite a tedious setup, which includes installing a database and webserver, configuring them, and finally going as far as to install &lt;em&gt;Drupal itself&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;However, the main hurdle here is using &lt;em&gt;functional&lt;/em&gt; tests (or Behat tests, although I believe using Behat would justify the long setup). If your project only includes unit and/or kernel tests (and I argue &lt;em&gt;it should&lt;/em&gt;), using a CI actually becomes &lt;em&gt;much&lt;/em&gt; easier.&lt;/p&gt;
&lt;h2&gt;Understanding Drupal unit and kernel tests&lt;/h2&gt;
&lt;p&gt;In Drupal 8, thanks to the inclusion of a &lt;em&gt;dependency injection container&lt;/em&gt;, we can now mock parts of core in our test environments, allowing us to truly use unit tests. They complete in mere milliseconds, and are ideal for both &lt;abbr title=&quot;Test Driven Development&quot;&gt;TDD&lt;/abbr&gt; and using &lt;abbr title=&quot;Continuous Integration&quot;&gt;CI&lt;/abbr&gt;.&lt;/p&gt;
&lt;p&gt;However, Drupal 8&apos;s maze of dependencies and services mean we sometimes need to mock &lt;em&gt;a lot&lt;/em&gt; of Drupal code. So much in fact, that the &lt;code&gt;setUp()&lt;/code&gt; method of a unit test class can become larger than the actual test methods &lt;em&gt;combined&lt;/em&gt;. For this reason, some projects revert to functional tests, but—as I&apos;ve discussed before—they are &lt;em&gt;way&lt;/em&gt; to slow to run, and extremely hard to debug.&lt;/p&gt;
&lt;p&gt;Kernel tests, on the other hand, are much faster. They do need a database to run. However, contrary to functional tests, they don&apos;t require a running webserver. This is a huge win when setting up a CI environment, as most have some sort of built-in PHP environment, which often includes SQLite support. This means the runner setup will only include downloading Drupal, and moving our code into the correct location.&lt;/p&gt;
&lt;p&gt;Finally, both kernel and unit tests can be used to compute code coverage, which is incredibly useful when performing more in depth code analysis and quality control. This is not the case with functional tests.&lt;/p&gt;
&lt;h2&gt;Kernel tests depend on Drupal&apos;s file structure&lt;/h2&gt;
&lt;p&gt;When running automated tests on a CI server, it&apos;s tempting to use &lt;code&gt;composer require drupal/core:~8.4&lt;/code&gt; followed by &lt;code&gt;phpunit&lt;/code&gt;, but unfortunately it&apos;s not that simple.&lt;/p&gt;
&lt;p&gt;Although this would work for unit tests, kernel tests assume they are run in context of a Drupal project, so they will look for folders and files in places you may not expect.&lt;/p&gt;
&lt;p&gt;It&apos;s still worth the effort to set up, though. It may seem complicated at first, but I assure you: it&apos;s really not. Plus, it&apos;s still &lt;em&gt;much&lt;/em&gt; easier than if you were using functional tests…&lt;/p&gt;
&lt;h2&gt;A working example with Travis CI and Sonarcloud&lt;/h2&gt;
&lt;p&gt;In this example, I will use &lt;a href=&quot;https://travis-ci.org&quot;&gt;Travis CI&lt;/a&gt;, but of course other CI vendors would work too. It will “build” a fresh Drupal site, run our tests, and push our code, with test statistics, to &lt;a href=&quot;https://sonarcloud.io&quot;&gt;Sonarcloud&lt;/a&gt; for static code analysis.&lt;/p&gt;
&lt;p&gt;You can see a working example &lt;a href=&quot;https://github.com/wadmiraal/guernsey&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Imagine this is our module&apos;s file structure:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;├── .travis.yml
├── config/
│   └── install/
│       └── ...
├── my_module.info.yml
├── my_module.permissions.yml
├── my_module.routing.yml
├── sonar-project.properties
├── sqlite-driver-exception.patch
├── src/
│   └── ...
├── templates/
│   └── ...
├── tests/
│   └── src/
│       └── Unit/
│           └── ...
│       └── Kernel/
│           └── ...
└── travis-ci-phpunit.xml.dist.patch
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Our example &lt;code&gt;sonar-project.properties&lt;/code&gt; file looks like this:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-ini&quot;&gt;sonar.projectKey=my_organization:my_module
sonar.projectName=My Module
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And here&apos;s our example &lt;code&gt;.travis.yml&lt;/code&gt; file:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;language: php
php:
  - &apos;7.0&apos;
  - &apos;7.1&apos;
addons:
  sonarcloud:
    organization: &quot;my_organization&quot;
    token:
      secure: &quot;secure-string=&quot;
env:
  - SIMPLETEST_DB=sqlite://testdb.sqlite
install:
  - composer create-project drupal-composer/drupal-project:8.x-dev drupal --stability dev --no-interaction
  - composer require -d drupal &apos;drupal/flag:4.0-alpha2&apos;
  - patch -d drupal/web -p1 &lt; sqlite-driver-exception.patch
  - patch -d drupal/web/core -p1 &lt; travis-ci-phpunit.xml.dist.patch
  - mkdir -p drupal/web/modules/my_module &amp;&amp; cp -a my_module* tests templates src config drupal/web/modules/my_module
script:
  - drupal/vendor/bin/phpunit -c drupal/web/core drupal/web/modules/my_module/tests/ --coverage-clover clover.xml --log-junit junit.log
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let&apos;s go over these lines:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;language: php
php:
  - &apos;7.0&apos;
  - &apos;7.1&apos;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;These are no-brainers: we&apos;re telling Travis to run these tests in PHP 7.0 and 7.1 environments.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;addons:
  sonarcloud:
    organization: &quot;my_organization&quot;
    token:
      secure: &quot;secure-string=&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here we tell Travis to include the Sonarcloud plugin. We need to add the Sonarcloud &lt;em&gt;organization&lt;/em&gt; key, as well as an authentication token generated specifically for our repo. &lt;strong&gt;Don&apos;t add this in plain text!&lt;/strong&gt; You can securely add this key using &lt;a href=&quot;https://docs.travis-ci.com/user/environment-variables/#Encrypting-environment-variables&quot;&gt;&lt;code&gt;travis encrypt&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If your favorite CI doesn&apos;t have built-in support for Sonarcloud, they have an executable you can download and run after the build is complete.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;env:
  - SIMPLETEST_DB=sqlite://testdb.sqlite
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Kernel tests require a running database. The easiest solution is to use SQLite, which is basically a static file. You can either add this information to the &lt;code&gt;phpunit.xml.dist&lt;/code&gt; file, or set it as an environment variable. I prefer to make it explicit, hence this line.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;install:
  - composer create-project drupal-composer/drupal-project:8.x-dev drupal --stability dev --no-interaction
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is where we download a full copy of Drupal. We use the &lt;a href=&quot;https://github.com/drupal-composer/drupal-project&quot;&gt;Composer template for Drupal projects&lt;/a&gt;, and save it to a folder called &lt;code&gt;drupal&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;  - composer require -d drupal &apos;drupal/flag:4.0-alpha2&apos;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here we install our dependencies. In our example, we depend on a specific version of the &lt;a href=&quot;http://www.drupal.org/project/flag&quot;&gt;Flag&lt;/a&gt; module. You could add any modules (or even themes and profiles) you need, and Composer will put them in the correct location, thanks to the configuration shipping with the Composer template we&apos;re using.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;  - patch -d drupal/web -p1 &lt; sqlite-driver-exception.patch
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here, we apply our &lt;code&gt;sqlite-driver-exception.patch&lt;/code&gt; to Drupal core. This patch is—at the time of writing—required to make SQLite work with Drupal when running tests.&lt;/p&gt;
&lt;p&gt;It contains the following:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-diff&quot;&gt;diff --git a/core/lib/Drupal/Core/Database/Database.php b/core/lib/Drupal/Core/Database/Database.php
index dd19018828..f3abe2b24e 100644
--- a/core/lib/Drupal/Core/Database/Database.php
+++ b/core/lib/Drupal/Core/Database/Database.php
@@ -456,9 +456,15 @@ public static function ignoreTarget($key, $target) {
    */
   public static function convertDbUrlToConnectionInfo($url, $root) {
     $info = parse_url($url);
-    if (!isset($info[&apos;scheme&apos;], $info[&apos;host&apos;], $info[&apos;path&apos;])) {
+    if (!isset($info[&apos;scheme&apos;], $info[&apos;host&apos;])) {
       throw new \InvalidArgumentException(&apos;Minimum requirement: driver://host/database&apos;);
     }
+    if ($info[&apos;scheme&apos;] !== &apos;sqlite&apos; &amp;&amp; !isset($info[&apos;path&apos;])) {
+      throw new \InvalidArgumentException(&apos;Minimum requirement: driver://host/database&apos;);
+    }
+    elseif ($info[&apos;scheme&apos;] === &apos;sqlite&apos;) {
+      $info[&apos;path&apos;] = $info[&apos;host&apos;];
+    }
     $info += [
       &apos;user&apos; =&gt; &apos;&apos;,
       &apos;pass&apos; =&gt; &apos;&apos;,
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next…&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;  - patch -d drupal/web/core -p1 &lt; travis-ci-phpunit.xml.dist.patch
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here, we apply our &lt;code&gt;travis-ci-phpunit.xml.dist.patch&lt;/code&gt; to Drupal core. This patch basically tells PHPUnit we only want to compute code coverage statistics for our own code, to speed things up a bit, and avoid unnecessary warnings in Sonarcloud.&lt;/p&gt;
&lt;p&gt;It contains the following:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-diff&quot;&gt;diff a/phpunit.xml.dist b/phpunit.xml.dist
--- a/phpunit.xml.dist	2018-01-12 09:34:43.000000000 +0100
+++ b/phpunit.xml.dist	2018-01-12 09:35:06.000000000 +0100
@@ -55,11 +55,7 @@
   &amp;lt;!-- Filter for coverage reports. --&amp;gt;
   &amp;lt;filter&amp;gt;
     &amp;lt;whitelist&amp;gt;
-      &amp;lt;directory&amp;gt;./includes&amp;lt;/directory&amp;gt;
-      &amp;lt;directory&amp;gt;./lib&amp;lt;/directory&amp;gt;
-      &amp;lt;directory&amp;gt;./modules&amp;lt;/directory&amp;gt;
-      &amp;lt;directory&amp;gt;../modules&amp;lt;/directory&amp;gt;
-      &amp;lt;directory&amp;gt;../sites&amp;lt;/directory&amp;gt;
+      &amp;lt;directory&amp;gt;../modules/my_module&amp;lt;/directory&amp;gt;
       &amp;lt;!-- By definition test classes have no tests. --&amp;gt;
       &amp;lt;exclude&amp;gt;
         &amp;lt;directory suffix=&quot;Test.php&quot;&amp;gt;./&amp;lt;/directory&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next…&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;mkdir -p drupal/web/modules/my_module &amp;&amp; cp -a my_module* tests templates src config drupal/web/modules/my_module
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here, we copy all our code over to the &lt;code&gt;drupal/web/modules/my_module&lt;/code&gt; directory. This is necessary for kernel tests, which will only search for our code inside the Drupal root.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;script:
  - drupal/vendor/bin/phpunit -c drupal/web/core drupal/web/modules/my_module/tests/ --coverage-clover clover.xml --log-junit junit.log
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here we finally do the running part. We use the version of PHPUnit that comes with Drupal, to make sure we don&apos;t run into compatibility issues if Travis updates its binaries. We give the location to the &lt;code&gt;phpunit.xml.dist&lt;/code&gt; file using &lt;code&gt;-c&lt;/code&gt;, pass our module&apos;s code location to tell PHPUnit to &lt;em&gt;only&lt;/em&gt; run our tests, and generate coverage stats.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt; - sonar-scanner -Dsonar.sources=drupal/web/modules/my_module/src -Dsonar.php.tests.reportPath=junit.log -Dsonar.php.coverage.reportPaths=drupal/web/clover.xml
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the second part, we run the &lt;code&gt;sonar-scanner&lt;/code&gt; plugin, passing the Clover and JUnit log files for coverage analysis. Because of this, we need to pass the path to the source code actually tested, and &lt;em&gt;not&lt;/em&gt; the code in the Travis build root. Which is why &lt;code&gt;-Dsonar.sources&lt;/code&gt; points to our copied code, instead of simply the root of the folder.&lt;/p&gt;
&lt;p&gt;In our particular case, we only have kernel tests. If we had any unit tests, they would run fine as well. Functional tests, however, would not run in our case, but as I&apos;ve written on this blog before, you shouldn&apos;t necessarily &lt;em&gt;write&lt;/em&gt; functional tests in the first place (and they&apos;re &lt;em&gt;way&lt;/em&gt; more complex to run in a CI environment).&lt;/p&gt;
&lt;p&gt;Now, whenever we push to our repository, Travis CI will fetch the code and run our build, run the tests, and push the files for code analysis to Sonarcloud.&lt;/p&gt;
&lt;h2&gt;What can we learn from this example&lt;/h2&gt;
&lt;p&gt;This setup is pretty straightforward, once you know it. It&apos;s easy to replicate, and the only thing that will likely change is the dependency management. It also encourages us to use kernel and unit tests, and stay away from functional tests as much as possible.&lt;/p&gt;
&lt;p&gt;The ability to run tests using a CI server also opens the door for code analysis tools, like Code Climate (my personal favorite) and Sonarqube. These tools are invaluable for producing better quality code. And as icing on the cake: the ability to add test coverage statistics to the mix further encourages to write unit and kernel tests, &lt;em&gt;and&lt;/em&gt; to write &lt;em&gt;more&lt;/em&gt; of them (functional tests cannot compute code coverage; one more reason not to use them).&lt;/p&gt;
&lt;p&gt;All this isn&apos;t to say functional tests are &lt;em&gt;bad&lt;/em&gt;. They are just very complicated and time consuming to write, run, and debug. For this reason, they should not be used for testing highly specific units of logic; rather, they are best used for testing UIs and very high-level concepts. And even then, I&apos;d argue you&apos;d be better of using Behat tests, which, although even &lt;em&gt;more&lt;/em&gt; complicated to set up, at least encourage you to think more about the behavior and UI, rather than the underlying code. But that&apos;s a topic for another day.&lt;/p&gt;
</description>
        <pubDate>Mon, 22 Jan 2018 00:00:00 GMT</pubDate>
        <link>https://wadmiraal.net/lore/2018/01/22/drupal-8-with-travisci-and-sonarcloud/</link>
        <guid isPermaLink="true">https://wadmiraal.net/lore/2018/01/22/drupal-8-with-travisci-and-sonarcloud/</guid>
      </item>
    
  </channel>
</rss>
