DVLA Engineering

Welcome to the Driver and Vehicle Licencing engineering site which contains technical posts and information about our open-source projects.

Toggling Ruby scenarios in Drone using secrets

TiL how to toggle Ruby scenarios to be run using CI pipeline secrets Scenario In a relatively niche scenario, we have functionality that is being temporarily removed while new code is being developed. While we still want to keep our current scenarios for function X to use them again when it’s reintroduced, if they are left to run in our pipeline, every build will fail until it is reintroduced again....

November 7, 2024 · 4 min · 707 words · Leighton Taylor

TiL: The difference between exec and system in Ruby

Ruby provides a few different ways to execute commands against the underlying kernel programmatically, but they all work slightly differently. The simplest way to execute a command againts the shell is to surround it in backticks. For example, the following will run the command date and return whatever was output to $stdout. current_date = `date` However, there are also more explict methods you can call. In particular, there is exec and system which look like they do the same thing at a quick glance....

September 23, 2024 · 2 min · 425 words · George Bell

TiL: Doing multiple replacements with gsub in Ruby

gsub is great. It lets you replace characters in a string. All you have to do is give it a regex that will match whatever it is you want to replace and the string that you’d like to replace each match with. For example, if you wanted to replace the time of 18:00 with something a bit more human-readable, you could do the following: 'As always, tea time is at 18:00....

July 30, 2024 · 2 min · 245 words · George Bell

Non-Blocking Ruby Methods

There are lot of options for concurrency in Ruby, from spawning child processes to using threads, ractors and Async. Each have their merits and drawbacks, but one of the simplest and most effective ways to run code concurrently is to use Fibers. In my use-case, I want to do some work and, in the background, perform some network requests. Network I/O is blocking, so I want to make sure I’m doing productive work on the main thread while I wait for the network requests to complete....

July 26, 2024 · 4 min · 681 words · Nigel Brookes-Thomas

TiL: Adding numerous tags to ParallelTests in cucumber elegantly

Trying to run tests in parallel in your CI/CD pipeline is tricky at the best of times, but what if you have tests which should only be run in a certain environment and not as part of the CI build stage? It is fairly simple to just tag a feature file with a unique tag that can then be passed to the bundle exec rake command in the functional-tests step, as an environment variable....

July 2, 2024 · 3 min · 580 words · Tomos Griffiths