Making your build faster with go 1.10 on CircleCI 2.0
Did you update to go 1.10? DId you update to CircleCI 2.0 ?
A month ago, go 1.10 released. It includes awesome feature, build cache.
The go build -asmflags, -gcflags, -gccgoflags, and -ldflags options now apply by default only to the packages listed…golang.org
On the other hand, CircleCI 1.0 EOL announced on August 31, 2018.
TL;DR: After August 31, 2018, CircleCI 1.0 will no longer be available for Linux and macOS users. You can find guides…circleci.com
You should migrate 1.0 to 2.0.
On my production code, build time faster 4x by updating go 1.10 and CircleCI 2.0.
- use CircleCI build cache
- use dep
- use test cache
use CircleCI build cache
In CircleCI 2.0, you can save and restore cache any path in your repositories at your any timing.
dep is dependency management tool for Go. Currently dep may defact standard. dep download dependency libraries to vendor directory. So, with CircleCI build cache you can skip download step efficiently.
here is example circle.yml:
download-libraries phase only executed first push per branch, or Gopkg.lock changed.
use test cache
To enable go 1.10 test cache needs just technique. CircleCI build cache write only once.
The cache for a specific key is immutable and cannot be changed once written. NOTE: If the cache for the given key already exists it won’t be modified, and job execution will proceed to the next step.
On restore cache, use CIRCLE_PREVIOUS_BUILD_NUM environment variable. it restore previous build cache. And save_cache phase, you use CIRCLE_BUILD_NUM environment variable.
On CircleCI 1.0 and go 1.9
On CircleCI 2.0 and go 1.10 (no test cache)
On CircleCI 2.0 and go 1.10 (with test cache via rebuild)