Cutting CI from about 15 minutes to a few by measuring steps and sharding tests
The author maintains a Spring Boot (Kotlin) API repository where the Build and Test GitHub Actions workflow took about 16 minutes per pull request, of which tests took about 6 minutes. Measuring the steps showed the Gradle cache was empty on every run, because setup-gradle saves its cache only on runs from the default branch and this workflow ran only on pull_request. Adding a push trigger for the develop branch let a cache be created that later pull request runs could restore.
Three runners were compared by running the same commit at the same time: ubuntu-latest took 650 and 609 seconds, Blacksmith 2vCPU took 473 and 414 seconds, and Blacksmith 4vCPU took 380 seconds on its second run, while its first run waited for a runner because the repository had not been added to the Blacksmith GitHub app. The author chose 2vCPU, since on the tests 4vCPU was only 24 seconds faster and costs twice as much per minute. The tests were then split into three shard[1] jobs run through a matrix[2], and the Swagger check moved to a separate job without a database.
After the merge, pull request runs with the restored cache took 2 minutes 40 seconds and 3 minutes 47 seconds, against a median of 14 minutes 43 seconds before the change across 202 successful runs over seven weeks. A release pull request took 6 minutes 32 seconds, and the change's own pull request, which had no cache, took 5 minutes 51 seconds. The author says these are early figures, with only three cached runs, and that the tests themselves are not faster.
Repository Blacksmith github.com
A CI/CD service that runs GitHub Actions workflows on faster runners with quicker caches and Docker builds.
Product Blacksmith blacksmith.sh
A CI/CD service that runs GitHub Actions workflows on faster runners with quicker caches and Docker builds.
Links from the post and discussion
Sources
-
JPZenn JA
15分かかっていたCIを数分に — 内訳を測り、ランナーは同じコミットで並べて比べ、テストを3シャードに分けた





