November 21, 2023

Topics: Coding

Link to tech demo video on YouTube

Note

This is an article about my first ever merged pull request on an open source product. See Coding for more background on my coding experiences and my journey to consider myself a "programmer" instead of just a "coder".

I'm taking this journey because I like to make useful products, learn interesting things, solve challenging puzzles, and maybe someday make some money doing it.

TLDR

I programmed an automation tool that increases developer productivity and increases the reliability of the Taskwarrior to-do task management software by assuring that developers are all collaborating on the same version of programming language.

Background

TaskWarrior is a task list or to-do application for the command line. TaskWarrior has a module being integrated called TaskChampion. Although TaskWarrior is primarily written in C++, TaskChampion is written in the Rust programming language. The source code is hosted in a repository on the Github version control system. As of 2023-11-21, TaskWarrior has 89 sponsors, ~3,600 stars, 140 contributors, ~2,900 OS-X downloads per year, and over 14,000 downloads from Github itself.

Software development requires collaborating developers to use the same version of the coding environment, supporting software libraries, etc. in order to assure that the code the developers writes performs, as expected, no matter who is running it or where. When developers use different versions of the same software to write code, it can introduce bugs, or fail completely. With so many developers collaborating on TaskWarrior, it is important to keep them coordinated and aligned on which development software versions to use.

Therefore, keeping everyone on the same page is critical to writing software that performs as the user and other developers expect. This can be accomplished in a variety of ways, both automated and manually. This is especially the case with collaborating developers on Open Source Software, and in this case, TaskWarrior. One solution specific to collaborating with other developers on the Task Champion repository, a child repository of Task Warrior, is to manually update the version of the software environment to be used, wherever it is used.

In the Rust programming language, this is expressed as the Minimum Supported Rust Version or MSRV for short. The MSRV is specified in a variety of files, specifically configuration files which aid in the continuous integration ("CI") and software compilation process. This makes sure that all components of that software that gets compiled into a user-executable binary file are using the same version of Rust and therefore compatible with each other.

Problem

Manually updating and maintaining the MSRV in a variety of places can be cumbersome, time consuming, and error prone. As a result, software may end up not using the correct version of Rust, may not compile properly, and even if it is updated correctly, may require significant time to update every time it needs to be updated.

Solution

Using automation to update files that specify the MSRV whenever the MSRV changes, developers can better be aligned on what version of Rust they should be using. Using the existing xtask command line automation tool , a repo within the parent TaskChampion repository (which is a child of the TaskWarrior repository), I implemented new functionality that will automatically update the MSRV to a specified version number for all files specified within the program's source code. For example, running xtask MSRV 1.65 will look in all specified files for a specific text pattern, and if an existing version is found and is different than the one specified in the command, it will update the MSRV to 1.65.

Impact

By automating the process of keeping the MSRV consistent across all configuration files:

How

The xtask MSRV program has a const slice of (string, string) tuples that specify:

  1. the relative path to a file that should have its MSRV updated, and
  2. regex that specifies the string to look for within the file containing the version number to be updated.

This slice is than looped over to find and open the file, whose contents is iterated over line by line, and evaluated for a match to the specified regex. If a match is found, and it is different than the MSRV specified at the command line, then an update is made to the line, and the remainder of the file is evaluated. The file is then saved and closed. This recurs for all files specified in the slice until all files have been evaluated. When a file is successfully updated, a note will be printed to the command line.

Specifying no version number, or an invalid version number (according to simple numeric value checks), will result in an error and no updates will be made. Similarly, if a specified file does not exist, the MSRV pattern is not found, or the found MSRV is not different to the one specified as an argument at the command line, then no updates will be made.

Known Limitations

There are several known limitation to xtask MSRV that, given the scope, time, and anticipated usage of the tool, are considered to be acceptable. These include but may not be limited to:

Alternative Solutions

There may be other solutions to solving the coordination of version numbers problem. The default solution is to conduct manual updates. A proposed but potentially incomplete solution is to specify the MSRV in Rust's cargo.toml configuration file, implicitly indicating to a potential developer the MSRV to be used. This solution would still require the manual updating of each relevant configuration file.

Further Development

To improve on this functionality, a developer could implement function to search the entire repo's contents for files with specific MSRV patterns, instead of specifying specific files within the repo. Additionally, better version identification, perhaps with serialized data with serde might yield better accuracy and lower false positives or false negatives.

Conclusion

Automatically updating the MSRV to enhance the productivity of developers and reduce potential bugs should result in higher velocity development of Taskwarrior. Extending the functionality of xtask MSRV could include include versioning of other types of software and libraries - not just rust. The functionality could also be applied to documentation of software.


What I've learned from this project

As I was working through the project I kept a list of items I want to keep in mind for future projects:

Thanks

I was getting guidance (mostly via hints and directional nudges) from @djmitch who coordinated with and assigned the project to me. Thank you for letting me contribute!