A pipeline that downloads the same eighty packages on every push is spending most of its allowance on the network, and the fix is four lines.
pipelines:
default:
- step:
image: php:7.2-cli
caches:
- composer
script:
- composer install --no-interaction --prefer-dist
- vendor/bin/phpunit
definitions:
caches:
composer: ~/.composer/cache
The named composer cache is predefined; the definitions block is only needed for a custom path, which is worth knowing because most examples show both. The cache is keyed per branch with a fallback to the default branch, so a new feature branch inherits rather than starting cold. It is also uploaded after every successful step, which on a large node_modules can cost more time than it saves — measure before caching something big.