<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ben Limmer on Medium]]></title>
        <description><![CDATA[Stories by Ben Limmer on Medium]]></description>
        <link>https://medium.com/@blimmer?source=rss-53181e6bb53b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*yuOFgCPZnI_Rrj2OAeq5Ng.jpeg</url>
            <title>Stories by Ben Limmer on Medium</title>
            <link>https://medium.com/@blimmer?source=rss-53181e6bb53b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 03:11:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@blimmer/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a Scaleable Protocol Buffers/gRPC Artifact Pipeline]]></title>
            <link>https://medium.com/building-ibotta/building-a-scaleable-protocol-buffers-grpc-artifact-pipeline-5265c5118c9d?source=rss-53181e6bb53b------2</link>
            <guid isPermaLink="false">https://medium.com/p/5265c5118c9d</guid>
            <category><![CDATA[protocol-buffers]]></category>
            <category><![CDATA[grpc]]></category>
            <category><![CDATA[lerna]]></category>
            <category><![CDATA[monorepo]]></category>
            <category><![CDATA[pipeline]]></category>
            <dc:creator><![CDATA[Ben Limmer]]></dc:creator>
            <pubDate>Mon, 04 Jun 2018 23:05:19 GMT</pubDate>
            <atom:updated>2019-04-17T02:51:56.954Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://ibotta.com/">Ibotta</a> uses <a href="https://grpc.io/">gRPC</a> and <a href="https://developers.google.com/protocol-buffers/">Protocol Buffers</a> to rapidly innovate in our microservice-driven environment. gRPC provides low-latency, <a href="https://grpc.io/docs/guides/concepts.html#bidirectional-streaming-rpc">bi-directional binary streaming</a> via <a href="https://en.wikipedia.org/wiki/HTTP/2">HTTP/2</a>. gRPC also relies on reusable, validateable, language-agnostic <a href="https://developers.google.com/protocol-buffers/">Protocol Buffers</a> messages.</p><p>Because of these advantages, many of our new services are using gRPC for their inter-service communication. We’re also using Protocol Buffers outside of gRPC for predictable serialization/deserialization of messages on streams and queues.</p><p>However, our initial implementation for packaging Protocol Buffers messages and gRPC services could not handle the influx of new <strong>technologist</strong> (engineers, data scientists and analysts) interest. This article describes the problems we faced with the initial implementation and how our new pipeline significantly decreased time to ship Protocol Buffers &amp; gRPC artifacts to production.</p><h3>The Initial Implementation</h3><p>During our initial exploratory phase of using gRPC, our strategy was to place services in the same package as our common Protocol Buffers (aka <strong>Protobuf</strong>) message definitions.</p><pre>ibotta_schemas<br>├── services<br>│   └── my_service<br>│       └── messages.proto   &lt;- service-specific Protobuf messages<br>│       └── service.proto    &lt;- gRPC service definition<br>└── system<br>    └── entity.proto         &lt;- shared Protobuf messages</pre><p>This methodology only allowed for one versioned package at a time (we called it ibotta_schemas) and resulted in a new version of the artifact anytime a core message or service mutated. At one point we saw the shared version published more than ten times in one day! This rapid release cycle made it extremely difficult for users of ib_schemas to keep up-to-date with releases that often didn’t impact their service.</p><p>With just a few services, this pattern worked well-enough for us. It allowed for the protoc compiler to easily discover shared messages, but we realized that it would not scale as we added <strong>many</strong> more services.</p><h4>Turn Back Now?</h4><p>If you’re just starting to experiment with gRPC or you only plan to have a few services, the pipeline I describe below might be overkill.</p><p>This article is targeted to an audience who need to create a pipeline to deploy artifacts for <strong>many gRPC services, developed by a variety of technologists, compiled for a diverse set of languages</strong>. If that sounds like you, please continue on. If it doesn’t, go experiment and come back to this article if you’re ready to move forward with wider adoption.</p><h3>Pipeline Requirements</h3><p>Our pipeline had three main requirements.</p><ol><li>Significantly reduce boilerplate to create and deploy language-specific artifacts for a new gRPC service</li><li>Enable gRPC services and Protocol Buffers messages to rely on shared .proto files stored in base packages</li><li>Build, version and publish gRPC artifacts in a variety of languages (Ruby, Java, Node, Python, etc.)</li></ol><p>The first of these goals was relatively straightforward to approach. Once we had a common pattern in place, we could introduce a <a href="http://yeoman.io/">Yeoman Generator</a> to create the needed files in the correct place. However, goals two and three were less straightforward. The follow sections describe how those problems were attacked.</p><h4>Depending on common .proto Files</h4><p>Sharing reusable messages is one of the strengths of Protocol Buffers. For instance, this is a common message that all services use to talk about an “entity” such as a Shopper, Offer, Bonus, etc. that has meaning across our system’s services.</p><pre>// entity.proto</pre><pre>syntax = &quot;proto3&quot;;<br><br>package ibotta_pb.system;<br><br>// Identifies an entity across systems.<br>message EntityUri {<br>    // Uniquely identifies the entity across all systems.<br>    string uri = 1;</pre><pre>    // Human-readable name of this object.<br>    // Should never be considered unique for any purposes<br>    // and should only be used for reference.<br>    // [Optional]<br>    string name = 2;<br>}</pre><p>For instance, a Shopper’s EntityUri might look like &#39;shopper~123&#39; or an Offer’s EntityUri might look like &#39;offer~456&#39;. Using a shared EntityUri message helps to standardize these messages across many microservices. This message definition is stored in a common package that we’ll call ib_core.</p><p>Let’s say that I’m generating a new gRPC service that wants to talk about a Shopper. Its internal message would look something like this:</p><pre>// my_service.proto</pre><pre>syntax = &quot;proto3&quot;;</pre><pre>package ibotta_pb.my_service;</pre><pre>import &quot;ibotta_pb/system/entity.proto&quot;;      &lt;- located in &quot;ib_core&quot;</pre><pre>message MyServiceRequest {<br>  ibotta_pb.system.EntityUri shopper_uri = 1;<br>}</pre><p>Importing the entity definition from ib_core exposes a few problems.</p><ol><li>The <a href="https://github.com/google/protobuf">protoc</a> compiler for our service needs to have access to the raw entity.proto file to generate the language-specific files for our gRPC service.</li><li>Changes to the core file definition should rebuild the gRPC service artifacts. For example, if we added a new field to EntityUri we’d want to rebuild and publish the artifacts for my_service so it can take advantage of that new field.</li></ol><p>We recognized this is a dependency management problem and we needed a powerful tool like <a href="https://docs.npmjs.com/getting-started/what-is-npm">npm</a>, <a href="https://bundler.io/">Bundler</a>, or <a href="https://maven.apache.org/">Maven</a>. Managing inter-dependencies between our core packages and our gRPC services with a bespoke solution was asking for subtle problems in the future.</p><p>Additionally, we wanted a common build and deployment system so that technologists could simply create their gRPC service definitions and have the proper artifacts uploaded to our private <a href="https://jfrog.com/artifactory/">Artifactory</a> in a few minutes.</p><h3>Using a Project Monorepo</h3><p>Because we wanted to share an opinionated build and deployment pipeline, a <strong>monorepo</strong> made a lot of sense for the project.</p><p>If you’re not familiar with the concept of a monorepo, I highly recommend reading <a href="https://medium.com/u/5dda6d1399ef">Markus Oberlehner</a>’s article, <a href="https://medium.com/@maoberlehner/monorepos-in-the-wild-33c6eb246cb9">Monorepos in the Wild</a>. Using his terms, this specific use of the monorepo pattern is a <a href="https://medium.com/@maoberlehner/monorepos-in-the-wild-33c6eb246cb9#---0-17">Project Monorepo</a>.</p><blockquote>Making large scale refactorings across all related packages can be done very quickly if every package is maintained in one single repository. By contrast changing an API which affects all packages spread across multiple repositories, means making a separate commit in everyone of those affected repositories.</blockquote><blockquote>- Markus Oberlehner from “<a href="https://medium.com/@maoberlehner/monorepos-in-the-wild-33c6eb246cb9">Monorepos in the Wild</a>”</blockquote><p>This is especially valid for this project because these “refactorings” are mutations in common packages relied upon by many gRPC service definitions. Having all the code in one place helps to make changes in one place, instead of across many repositories.</p><pre>ibotta_schemas                &lt;- root github repository<br>├── README.md<br>└── packages                  &lt;- &quot;sub-repos&quot; inside the monorepo<br>    ├── my_grpc_service_1<br>    ├── my_grpc_service_2<br>    └── ib_core</pre><p>In a non-monorepo environment, each sub-folder below packages would be its own GitHub repository, with its own versioning and build/deployment pipeline. The downside to that approach, as discussed above, is managing dependencies, releases and builds across many repositories.</p><h4>Lerna for Monorepo Management</h4><p>To manage versioning and releasing in packages within the monorepo, we are using the powerful tool, lerna.</p><p>lerna does a great job at independently versioning our the “sub-repos” in our monorepo. For instance, consider a dependency graph where there are two services that both depend on messages in ib_core .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*YwUlnYIDhp0UUva3Ocw8Vw.png" /><figcaption>Both gRPC services depend on the Protocol Buffers messages defined in ib_core</figcaption></figure><p>At their base state for this example, all of the packages are at version 1.0.0.</p><pre># code example here: <a href="https://git.io/vhC1Q">https://git.io/vhC1Q</a></pre><pre>packages<br>├── ib_core                 @1.0.0<br>├── my_grpc_service_1       @1.0.0<br>└── my_grpc_service_2       @1.0.0</pre><p>When backwards-compatible changes are made in my_grpc_service_1 , it’s the only packages that needs a new release.</p><pre># code change made: <a href="https://git.io/vhCMI">https://git.io/vhCMI</a><br># release of my_grpc_service_1: <a href="https://git.io/vhCMY">https://git.io/vhCMY</a></pre><pre>packages<br>├── ib_core                 @1.0.0<br>├── my_grpc_service_1       @1.1.0 &lt;- release<br>└── my_grpc_service_2       @1.0.0</pre><p>However, when ib_core changes, all three packages need a release. One for the core package updates and a release each for the dependent gRPC service definitions.</p><pre># code changes made: <a href="https://git.io/vhCMW">https://git.io/vhCMW</a><br># releases of all three packages: <a href="https://git.io/vhCMu">https://git.io/vhCMu</a></pre><pre>packages<br>├── ib_core                 @1.1.0 &lt;- release<br>├── my_grpc_service_1       @1.2.0 &lt;- release<br>└── my_grpc_service_2       @1.1.0 &lt;- release</pre><p>lerna manages the versioning and release process for us with a user-friendly CLI tool. For instance, when all three packages needed a release, this is the output from running <a href="https://github.com/lerna/lerna#publish">lerna publish</a> :</p><pre>&gt; lerna publish</pre><pre>lerna info version 2.11.0<br>lerna info versioning independent<br>lerna info Checking for updated packages...<br>lerna info Comparing with my_grpc_service_1-protofiles@1.1.0.<br>lerna info Checking for prereleased packages...<br>? Select a new version for ib_core-protofiles (currently 1.0.0) Minor (1.1.0)<br>? Select a new version for my_grpc_service_1-protofiles (currently 1.1.0) Minor (1.2.0)<br>? Select a new version for my_grpc_service_2-protofiles (currently 1.0.0) Minor (1.1.0)</pre><pre>Changes:<br> - ib_core-protofiles: 1.0.0 =&gt; 1.1.0 (private)<br> - my_grpc_service_1-protofiles: 1.1.0 =&gt; 1.2.0 (private)<br> - my_grpc_service_2-protofiles: 1.0.0 =&gt; 1.1.0 (private)</pre><pre>? Are you sure you want to publish the above changes? Yes</pre><p>lerna updates the version (tracked in each “sub-repo”s package.json file) and creates <a href="https://git-scm.com/book/en/v2/Git-Basics-Tagging">git tags</a> on that commit.</p><pre>commit 6ef8f4618c6423d138b3b73e5a3f4f34528744df (HEAD -&gt; master, tag: my_grpc_service_2-protofiles@1.1.0, tag: my_grpc_service_1-protofiles@1.2.0, tag: ib_core-protofiles@1.1.0, origin/master, origin/HEAD)<br>Author: Ben Limmer &lt;hello@benlimmer.com&gt;<br>Date:   Fri Jun 1 11:39:08 2018 -0700</pre><pre>Publish</pre><pre>     - ib_core-protofiles@1.1.0<br>     - my_grpc_service_1-protofiles@1.2.0<br>     - my_grpc_service_2-protofiles@1.1.0</pre><p>The example above had only one core package but, in reality, we have many more core packages that our services can use, creating a dependency graph that looks more like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*BU07Nnx_izoGn-1cmMHxoA.png" /><figcaption>A slightly more complex message dependency graph</figcaption></figure><p>lerna easily manages these dependencies and the versioning/release process as the schema mutates. This powerful, independent versioning allows for rapid development of core packages and gRPC services alike.</p><h3>Building and Packaging Artifacts</h3><p>The other challenge in developing our gRPC pipeline was the build and deployment of <strong>language-specific artifacts</strong> (<a href="https://github.com/rubygems/rubygems"><strong>gems</strong></a> for Ruby, <a href="https://docs.oracle.com/javase/tutorial/deployment/jar/basicsindex.html"><strong>jars</strong></a> for Java, <a href="https://packaging.python.org/glossary/#term-egg"><strong>eggs</strong></a> for Python, <a href="https://docs.npmjs.com/getting-started/packages"><strong>packages</strong></a> for node, etc.)</p><p>The protoc compiler tool does a great job at taking .proto files and turning them into the appropriate language-specific files (.rb files, .java files, .py files, .js files, etc.), but it doesn’t handle packaging up the artifacts for consumption by the services that use them.</p><p>To solve this problem, we use the excellent <a href="https://github.com/namely/docker-protoc">docker-protoc</a> project from <a href="https://medium.com/u/cd081741c451">Namely Labs</a> and a custom script to handle packaging/publishing the built artifacts.</p><h4>docker-protoc</h4><p>The docker-protoc container encapsulates the <a href="https://github.com/namely/docker-protoc/blob/master/all/Dockerfile">multitude of dependencies</a> required to build language-specific files from .proto source files. Using this container provides us with a reliable, consistent interface for the compilation step.</p><p>Additionally, their container enables <a href="https://en.wikipedia.org/wiki/Lint_(software)">linting</a> of our .proto files via <a href="https://github.com/ckaznocha/protoc-gen-lint">protoc-gen-lint</a> and generation of documentation via <a href="https://github.com/pseudomuto/protoc-gen-doc#">protoc-gen-doc</a> .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Shyrj2XcW-1D9njV1hYLFw.png" /><figcaption>Code comments in .proto source files are used to generate documentation in HTML or Markdown</figcaption></figure><p>If you haven’t read their post, “<a href="https://medium.com/namely-labs/how-we-build-grpc-services-at-namely-52a3ae9e7c35">How we build gRPC Services at Namely</a>”, I highly recommend taking a look. This post was hugely inspirational to us when solving this problem.</p><h4><strong>Invoking the </strong><strong>docker-protoc Container with the Correct Includes</strong></h4><p>The protoc compiler needs access to all .proto files that are include -ed in your messages. From our example above, our gRPC service required a core package like this:</p><pre>import &quot;ibotta_pb/system/entity.proto&quot;;</pre><p>If you don’t explicitly include a reference to that file, you’ll see the protoc compiler fail with an error.</p><pre>ibotta_pb/system/entity.proto: File not found.<br>ibotta_pb/my_grpc_service_1/messages.proto:<br> Import &quot;ibotta_pb/system/entity.proto&quot; was not found or had errors.</pre><p>To resolve this problem, we leverage the way that lerna uses npm to link up dependent packages. From our previous example where my_grpc_service_1 depends on ib_core , this is the folder structure.</p><pre>my_grpc_service_1<br>└── node_modules<br>    └── ib_core-protofiles -&gt; ../../ib_core<br>└── src</pre><p>Notice that lerna uses a <a href="https://en.wikipedia.org/wiki/Symbolic_link">symlink</a> in our monorepo to the ib_core-protofiles it’s dependent on. So, in our script, we iterate the node_modules directory and pass through any package to the docker-protoc compilation run as a -i include.</p><p>Our docker run command looks like this.</p><pre>docker run --rm                             \<br>  $dependency_mounts                        \ mount dependent pkgs<br>  -v $PACKAGE_DIR:/defs                     \ .proto files compiled<br>  namely/protoc-all:1.11                    \ label is gRPC version<br>     -i src/main/proto $dependency_includes \ node_modules includes<br>     -d src/main/proto                      \ location of .proto&#39;s<br>     -o $BUILD_PATH                         \ output location<br>     -l $BUILD_LANG                         \ ruby, node, python etc<br>     --with-docs</pre><p>$dependency_includes with the example above would expand to a string like this.</p><pre>-i my_grpc_service/node_modules/ib_core/src/main/proto</pre><p>And $dependency_mounts expands like this.</p><pre>-v $PROJECT_ROOT/packages/ib_core:ib_core</pre><p>We have to mount through the symlinked dependencies since Docker <a href="https://stackoverflow.com/questions/31881904/docker-follow-symlink-outside-context">struggles with understanding symlinks</a>.</p><p>By gathering, mounting-through and including the dependencies, the protoc compiler can produce the requested language-specific files.</p><pre>build<br>└── ruby<br>    └── ibotta_pb<br>        └── my_grpc_service_1<br>            └── messages_pb.rb</pre><p>Note that even though we included a reference to the imported packages, they are not copied into the resulting build files. We’ll handle this problem below.</p><h4><strong>Packaging the Files into Artifacts</strong></h4><p>Once we have the language specific artifacts, we need to package them up per the language and use-case standards. For this example, we’ll use Ruby as an example, but this same idea is used for all the languages we support.</p><p>For Ruby, our first step is to move the built files into a lib directory, per the <a href="https://guides.rubygems.org/patterns/">Rubygem standards</a>. Our build directory now looks like this.</p><pre>build<br>└── ruby<br>    └── lib<br>        └── ibotta_pb<br>            └── my_grpc_service_1<br>                └── messages_pb.rb</pre><p>Now we need to generate a .<a href="https://guides.rubygems.org/specification-reference/">gemspec file</a> for our service. To make this more manageable, we utilize a tool called <a href="https://gomplate.hairyhenderson.ca/">gomplate</a> , a simple wrapper on top of <a href="https://golang.org/pkg/text/template/">Go templates</a>. This allows us to fill in the proper variables for each package we build.</p><pre>Gem::Specification.new do |spec|<br>  spec.name          = &#39;ibotta_pb-{{ getenv &quot;ARTIFACT_NAME&quot; }}&#39;<br>  spec.version       = &#39;{{ getenv &quot;ARTIFACT_VERSION&quot; }}&#39;<br>  spec.authors       = [&#39;Ibotta&#39;]<br>  <br>  # etc.<br>  spec.add_dependency &#39;google-protobuf&#39;, &#39;~&gt; 3&#39;<br>  spec.add_dependency &#39;grpc&#39;, &#39;~&gt; {{ getenv &quot;GRPC_VERSION&quot; }}&#39;<br>  <br>  {{ if (datasourceExists &quot;dependencies&quot;) }}<br>  # Protobuf Base Dependencies<br>  {{- range $row := ( datasource &quot;dependencies&quot; ) }}<br>  spec.add_dependency &#39;ibotta_pb-{{ index $row 0 }}&#39;, &#39;&gt;= {{ index $row 1 }}&#39;, &#39;&lt; {{ index $row 2 }}&#39; {{ &quot;\n&quot; }}<br>  {{- end }}<br>  {{- end }}<br>end</pre><p>The datasource portion of the template above is how the consuming Ruby service pulls down the dependent base-packages at runtime. Our build script creates a basic CSV of any dependencies (from the node_modules directory).</p><pre>// dependency name, symlinked version, next major version<br>ib_core, 1.1.0, 2</pre><p>Since it’s a bit tough to read, here’s how the rendered template would look with our previous example.</p><pre>Gem::Specification.new do |spec|<br>  spec.name          = &#39;ibotta_pb-my_grpc_service_1&#39;<br>  spec.version       = &#39;1.1.0&#39;<br>  spec.authors       = [&#39;Ibotta&#39;]<br>  <br>  # etc.</pre><pre>  spec.add_dependency &#39;google-protobuf&#39;, &#39;~&gt; 3&#39;  <br>  spec.add_dependency &#39;grpc&#39;, &#39;~&gt; 1.11&#39;</pre><pre>  # Protobuf Base Dependencies<br>  spec.add_dependency &#39;ibotta_pb-ib_core&#39;, &#39;&gt;= 1.1.0&#39;, &#39;&lt; 2&#39;<br>end</pre><p>This consuming service pulls down the ib_core Ruby package to use at runtime. Since the protoc compiler does not deep-copy dependencies into the resultant build, we need to provide those built files at runtime (or compile-time for compiled languages).</p><p>We pass these common parameters ARTIFACT_NAME , ARTIFACT_VERSION , etc. to each of our templates so that each language can produce the appropriate file (build.gradle, setup.py, etc.)</p><p>Now our build folder looks like this.</p><pre>build<br>└── ruby<br>    ├── ibotta_pb-my_grpc_service_1.gemspec<br>    └── lib<br>        └── ibotta_pb<br>            └── my_grpc_service_1<br>                └── messages_pb.rb</pre><p>The final step is to build the gem and publish it to our Artifactory. Our script runs gem build and gem publish to do this.</p><p>Our script has switches for each language type we support in the pipeline. We follow the same pattern describe above for each supported language.</p><h3>Impact on Ibotta Technologists</h3><p>We’re finding Protocol Buffers and gRPC to be extremely powerful tools for us at Ibotta, particularly as we continue our move to a microservice-style architecture.</p><p>By creating this pipeline, a technologist can use our <a href="http://yeoman.io/learning/">Yeoman Generator</a> to quickly generate the necessary files to import common proto dependencies and publish the language-specific artifacts for their use-case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KHgRhQL7kcVYNaWde6SnPg.png" /><figcaption>Our Yeoman Generator creates a new service in seconds</figcaption></figure><p>These conventions allow our technologists to focus on solving for their business-case right away, a huge efficiency improvement compared to our initial solution.</p><h3>Lessons Learned</h3><p>Other than the benefits to the technologist users of the pipeline, there are a few overall lessons we learned from tackling this project.</p><h4>Protocol Buffers Artifacts are a First-Class Dependency</h4><p>Protocol Buffers messages allow for backwards-compatible schema evolution. Nevertheless, they should be published and released according to <a href="https://semver.org/">Semantic Versioning</a>. Using an artifact store like Artifactory and language-specific dependency managers (npm, bundler, etc.) in the consuming services makes handling mutations in the schema more transparent and observable.</p><h4>Naming is Hard</h4><p>Naming is often one of the hardest problems in programming. As I eluded to above, we have several base packages that share our common Protocol Buffers messages. As part of this project, we did a <a href="https://www.usability.gov/how-to-and-tools/methods/card-sorting.html">Card Sorting exercise</a> to take inventory of our existing shared messages and separated them into four base packages. We tried to be aware of <a href="https://en.wikipedia.org/wiki/Conway%27s_law">Conway’s Law</a> when separating the packages, but we know we likely won’t get it perfect the first time.</p><p>To hedge our bets with getting the naming and organization correct, we opted to use a single namespace for Protocol Buffer messages and services, ibotta_pb . This gives us flexibility to change the containing package without rewriting all services using shared messages. Take some time when writing your initial Protocol Buffers messages and monorepo packages, but know that there will always be downsides to the convention you choose. Leave yourself room to adapt as your problem domain changes.</p><h4>(Probably) Don’t Use Bash</h4><p>When we started this project, we didn’t foresee packaging of artifacts being this complex, and wrote this pipeline largely in a bash ‘deploy’ script. In hindsight, a more testable and widely-understood language like Ruby would have been a much better choice.</p><p>We will likely rewrite our script in the coming months, but at least the complex problems are solved in Bash for now and we can translate to another, more robust language.</p><p>If you have any questions, feel free to use the comment thread below! We’re happy to share our experience with you.</p><h4>We’re Hiring!</h4><p>If these kinds of projects and challenges sound interesting to you, Ibotta is hiring! Check out our <a href="https://ibotta.com/careers">jobs page</a> for more information.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5265c5118c9d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/building-ibotta/building-a-scaleable-protocol-buffers-grpc-artifact-pipeline-5265c5118c9d">Building a Scaleable Protocol Buffers/gRPC Artifact Pipeline</a> was originally published in <a href="https://medium.com/building-ibotta">Building Ibotta</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Encouraging Development Best Practices with Gamification]]></title>
            <link>https://medium.com/building-ibotta/encouraging-development-best-practices-with-gamification-ffdea7b0712?source=rss-53181e6bb53b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ffdea7b0712</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[gamification]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Ben Limmer]]></dc:creator>
            <pubDate>Wed, 23 May 2018 20:01:01 GMT</pubDate>
            <atom:updated>2018-05-23T20:01:01.030Z</atom:updated>
            <content:encoded><![CDATA[<p>Over the last twelve months, the Technology department at <a href="https://ibotta.com/">Ibotta</a> grew by over 100 people. Along with this growth, we’ve started breaking down our monolithic Ruby on Rails application into a series of <a href="https://www.martinfowler.com/articles/microservices.html">microservices</a>, which caused a rapid increase in the number of GitHub projects, languages and frameworks our squads use.</p><p>To keep our <strong>technologists</strong> (engineers, data scientists and analysts) focused on business logic, two cross-functional squads were created focusing on introducing conventions, reducing boilerplate and making common use-cases work out-of-the-box with little configuration.</p><p>These squads started making great progress on “Paving the Road to Production” by introducing:</p><ul><li><a href="http://yeoman.io/">Yeoman Generators</a> for building new apps in our common languages and frameworks</li><li>Pipelines to provision, build and deploy services to our AWS accounts and Kubernetes clusters</li><li>Tools to encrypt and manage secrets (check out <a href="https://github.com/Ibotta/sopstool">sopstool</a>)</li><li>Standardized libraries for logging, metrics and configuration</li></ul><p>However, we had a difficult time documenting and communicating the available tools and best-practices as they evolved. Internal blog posts, Slack announcements, Confluence wiki documentation, and in-person training were tried, but they didn’t provide a long-term benefit.</p><p>We needed a simple way to let technologists know about opportunities to improve their services based on our standard best-practices.</p><h3><a href="https://www.merriam-webster.com/dictionary/gamification">gamification</a> | noun | gam·i·fi·ca·tion</h3><blockquote>the process of adding games or gamelike elements to something (such as a task) so as to encourage participation</blockquote><p>To encourage adoption of best practices and common toolsets, we gamified the experience. We introduced an Ibotta Scorecard that simply summarized how aligned with our best-practices each service is.</p><p>Services leveraging all of the best-practices and tools get a badge that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*_erC8hdpfwfBiv4ALtHnfA.png" /><figcaption>Nice work — you’re aligned with the best-practices!</figcaption></figure><p>And services with room for improvement get a badge that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*KhPhC_t2hCPONnuKzp5rqA.png" /><figcaption>It’s possible this service isn’t being actively worked on. This is a great candidate for some maintenance work.</figcaption></figure><p>The ability to see a simple letter-grade for all of our services is <strong>extremely powerful</strong> and allows us to wrap up a plethora of information about a service’s health in one simple badge. Technologists can then dive into a Confluence page that explains the score and learn how to change their project to receive a higher score.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lqTryTYpJZozN2bByBJAxQ.png" /><figcaption>This service is doing a great job, but needs a CODEOWNERS file in their GitHub repository so that Pull Requests can be reviewed by Subject Matter Experts.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*r1rJzc7RB9qWH31ZvGAYhg.png" /><figcaption>The technologist can even get more detailed information about the check, like why it’s important. This codification of importance helps to document and ingrain the Ibotta Team values.</figcaption></figure><p>Better yet, we can assign varying points to each check to weight the most important signals for a service’s health. For instance, a failing security check reduces a service’s score much more significantly than a code-style check.</p><h3>How We Built It</h3><p>When considering how to build this tool, we wanted to make sure that the tool was:</p><ul><li><strong>Scalable</strong> as we add many more services</li><li><strong>Extensible</strong> so other Subject Matter Experts can codify best practices in the tool</li></ul><h3>The Pipeline</h3><p>The Kubernetes-native, event-driven scripting tool <a href="https://brigade.sh/">Brigade</a> is a great option to tackle the <strong>scalability</strong> requirement of this project. It leverages our Kubernetes cluster to run our scoring logic and fans-out jobs for scoring each repository, so it scales well as we add more services.</p><p>One of Brigade’s many advantages is that it <a href="https://github.com/Azure/brigade/blob/11621e514532e0b89de5dec00d0cda258ca36ab4/docs/topics/javascript.md">defines the pipeline</a> using a standard Node 8 script. For the scorecard we have three high-level tasks:</p><pre>const repos = await identifyMicroserviceRepos();<br>await scoreMicroserviceRepos();<br>await publishScorecardsToConfluence();</pre><p>If you’re not familiar with Node, the process is:</p><ol><li>Identify all the projects for scoring; then</li><li>Score all of those identified projects; then</li><li>Upload that info to Confluence</li></ol><p>Here’s an overview diagram of how the pipeline works. We’ll discuss each of the steps in detail in the sections below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*g6pCciY6t5KVhrq1t0JW_w.png" /><figcaption>A visual representation of our Brigade Pipeline</figcaption></figure><h4>Triggering the Pipeline</h4><p>We utilize a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/">Kubernetes Cron Job</a> to trigger our pipeline at a set interval. There’s not much to it, we simply trigger our pipeline via an internally exposed <a href="https://github.com/Azure/brigade/blob/11621e514532e0b89de5dec00d0cda258ca36ab4/docs/topics/gateways.md">Brigade Gateway</a>.</p><h4>Identifying Projects</h4><p>To identify projects to be scored, we introduced a simple plain-text file in each project’s git repository that we identify using <a href="https://developer.github.com/v3/search/#search-code">GitHub’s Code Search API</a>.</p><pre>// Each project to be scored has the file at the root of their repo</pre><pre>my_project<br>└── .ibotta<br>    └── SERVICE_IDENTIFIER &lt;- a simple text file</pre><pre>// And we identify it using a scoped code search<br>// (this example uses the @octokit/rest package for node)</pre><pre>const projects = await githubClient.search.code({<br>  q: &#39;org:Ibotta path:.ibotta filename:SERVICE_IDENTIFIER&#39;<br>});</pre><p>We automatically create the SERVICE_IDENTIFIER file when you generate your service using our Yeoman Generators, so you automatically get a score for your new service.</p><h4>Project Scoring</h4><p>Once we know which projects to score, we utilize a <a href="https://github.com/Azure/brigade/blob/11621e514532e0b89de5dec00d0cda258ca36ab4/docs/topics/javascript.md#the-static-runalljob-promiseresult-method">Brigade Group</a> to fan-out and score each of our projects in parallel. This means that each identified repository gets its own pod that runs checks on that single repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*q9YPQxs3gslI5ezhnTRITA.png" /><figcaption>After the projects are identified, a pod is created for each project to be scored in parallel</figcaption></figure><p>Within each pod, there are a set of checks that may or may not execute on each project. Some checks are valid for all projects, such as enabling <a href="https://travis-ci.com/">Travis CI</a>, <a href="http://codeclimate.com/">CodeClimate</a> and <a href="https://help.github.com/articles/about-protected-branches/">protecting your default branch</a> from force-pushes. Other checks are specific to a given language or framework, such as enabling <a href="https://github.com/nodesecurity/nsp">nsp</a> security checks for Node projects or <a href="https://github.com/presidentbeef/brakeman">Brakeman</a> for Ruby.</p><p>Each of these checks return a standard Score object that has metadata about the check, how many points were possible and how many points the project earned during scoring. These common Score objects are then parsed (using <a href="http://ejs.co/">ejs</a>) into a Confluence page containing a badge and all of information the technologist needs. These are written into a plain-text file in Brigade Shared Storage to be uploaded to Confluence after all projects are scored.</p><p>The benefit of using this standardized Score interface is that we have an <strong>extensible</strong> platform for Subject Matter Experts (SMEs) to introduce new scoring logic. We utilize an in-repo Yeoman Generator to assist SMEs in creating new Scoring Methods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*MYh77oUWpj_j_1grfe17Tg.png" /><figcaption>An example session with our Yeoman Generator for Scoring Methods. Note that a source and test file are created. Lots of inline help is generated in the source and test files so SMEs can write their business logic.</figcaption></figure><h4>Uploading Scores to Confluence</h4><p>The last step is to utilize the <a href="https://developer.atlassian.com/server/confluence/confluence-server-rest-api/">Confluence API</a> to write pages for each of the generated files in Brigade Shared Storage. Since everything’s already formatted correctly, it’s as simple as iterating the files and publishing them to our Confluence wiki.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*EWzUJ46nVDjaMW9TN3hzLw.png" /><figcaption>It’s easy to see that one of our services there needs some attention but, on the whole, we’re doing a good job!</figcaption></figure><h3>Results</h3><p>Thus far the scorecard project has proved to be a fun, effective way to emit information about the health of our services at Ibotta as we grow. It rolls up a plethora of information about each project and helps us to identify opportunities for maintenance work after services are in production.</p><p>In the month after launching this tool, we’ve seen technologists respond in a really positive way to the scorecard badges on their repositories.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*gO9gOE7_TV-yl5szF463jw.png" /><figcaption>People get excited to see their services score an A+</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*exUXYLuliYo-G5oBz3_P4g.png" /><figcaption>The badges drive healthy competition</figcaption></figure><p>We will continue leveraging the scorecard platform in the future to document and encourage best-practices among our developers. We’re already seeing Pull Requests from other squads adding scoring criteria and the best practices for their areas of focus, which is exactly what we were hoping for.</p><p>Perhaps most excitingly, the majority of our services have grades in the “A” letter-grade range! This means that we’re effectively driving the importance of opting into the tools and best-practices of the Ibotta Technology organization with our gamified scorecard.</p><h3>Additional Resources</h3><p>If this idea seems interesting for your organization, here are a few resources to take a look at.</p><h4>Brigade</h4><p><a href="https://brigade.sh/">Brigade</a> has proven to be an extremely powerful tool for us. I want to thank <a href="https://github.com/technosophos">Matt Butcher</a> and <a href="https://github.com/Azure/brigade/graphs/contributors">all the other contributors</a> to Brigade for being so willing to collaborate on the project. Drop by on the <a href="http://slack.k8s.io/">Kubernetes Slack</a> in the #brigade room to chat with these great folks.</p><p>Additionally, check out their <a href="https://brigade.sh/">marketing page</a> and <a href="https://github.com/Azure/brigade/tree/master/docs">their docs</a> for more information on Brigade.</p><h4>Internal Tools / Road Paving Teams</h4><p>Ibotta’s <a href="https://medium.com/u/6eaedef1e304">Matt Reynolds</a> has a great talk called <a href="https://www.slideshare.net/MatthewReynolds5/paving-the-road-to-production">“Paving the Road to Production: Why You Need an Internal Tools Team”</a> that goes into more detail on the mission of our Internal Tools squads.</p><h4>Ibotta</h4><p>If these kinds of projects and challenges sound interesting to you, Ibotta is hiring! Check out our <a href="https://grnh.se/f64y5m">jobs page</a> for more information.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffdea7b0712" width="1" height="1" alt=""><hr><p><a href="https://medium.com/building-ibotta/encouraging-development-best-practices-with-gamification-ffdea7b0712">Encouraging Development Best Practices with Gamification</a> was originally published in <a href="https://medium.com/building-ibotta">Building Ibotta</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>