Workers Builds: integrated CI/CD built on the Workers platform
During Cloudflare's Birthday Week in 2024, they launched Workers Builds in open beta, an integrated Continuous Integration and Delivery (CI/CD) workflow for building and deploying applications onto the Workers platform. The system is designed to bridge the gap between developer experiences for Workers and Pages, allowing users to connect a GitHub or GitLab repository to a Worker, with Cloudflare automatically building and deploying changes each time a commit is pushed. The design problem was how to pick up a commit from GitHub or GitLab and start a containerized job that can clone the repo, build the project, and deploy a Worker. The solution involved creating two systems: a configuration plane for users to connect a Worker to a repo, and a build management system to run and monitor builds. The Workers Builds system uses various Cloudflare technologies such as Workers, Durable Objects, Hyperdrive, Workers Logs, and Smart Placement. The Client Worker implements a RESTful API and connects to a PostgreSQL database for storing build configurations. The Build Management Worker consists of two Durable Object classes: A Scheduler class to manage the scheduling of builds, and a BuildBuddy class to manage individual builds. The system also leverages alarms in the Build Buddy DO to check that a build has a healthy startup and to terminate any builds that run longer than 20 minutes. Smart Placement with location hints is used to reduce latency costs, while Workers Logs are utilized for aggregating and searching operational logs from Workers. Coming soon to Workers Builds is build caching, which can speed up customer builds by avoiding the need to redownload dependencies or rebuild projects from scratch. The testing story includes unit tests, cross-worker integration tests, and integration tests on the Client Worker using SELF.fetch() from cloudflare:test. The conclusion emphasizes that by using Workers and Durable Objects, a complex and distributed system can be built easily, with opportunities to build more applications on the Developer Platform as it continues to mature and expand product offerings for various use cases.
Company
Cloudflare
Date published
Oct. 31, 2024
Author(s)
Serena Shah-Simpson, Jacob Hands, Natalie Rogers
Word count
2817
Hacker News points
None found.
Language
English