GolangCI-Test creates a simple way to run concurrent tests on multiple instances while using standard Go built-in tools. This approach should hopefully enable minimum maintenance, but at the same time maximum flexibility.
Warning
If you somehow end up on this repo, please wait a few days before using it. It goes through a lot of changes, and it's not ready for production use yet.
go install github.com/mflotynski/golangci-test
Use cache per branch to store the package splits between jobs.
cache:
key: "$CI_COMMIT_REF_NAME"
paths:
- .golangci-test-splits.json
The first pipeline per branch may be slower because it won't balance the packages based on their tests' execution time. It will split them evenly instead. If all your tests are short, this should probably be a good enough solution.
If not, then you may try to avoid this by using a global cache generated by the main branch only. All branches will pull this file. Obviously, feature branches will usually have more or less tests than the main branch, so the splits may still not be optimal. Yet, if you tend to have small feature branches, this should be a good solution.
New packages with tests (not existing in main branch) will be distributed evenly between the instances.
cache:
paths:
- .golangci-test-splits.json
policy: pull