Caching beginner need some help

Martin V_ March 25, 2020

I am new to caching topics, but I need to do something here and I thought maybe u can help me out with some things :)

My bitbucket-pipeline.yml:

definitions:
steps:
- step: &Codestyle-step
name: Codestyle
size: 2x
caches:
- composer
- docker
script:
- login
- docker-compose build php
- docker-compose run --rm -w /var/www/html php composer install --no-interaction --no-progress
- docker run --network=betafashion --rm -e "COMPOSER_ALLOW_SUPERUSER=1" -e "ENABLE_XDEBUG=1" --env-file=repo/.env-test -v "`pwd`/repo:/var/www/html" --memory=2G quay.io/betafashion/runtime-php composer check-code-style
services:
- docker
- step: &Test-step
name: Test
size: 2x
script:
- login
- docker-compose up -d database
- docker-compose build php
- docker-compose run --rm -w /var/www/html php composer install --no-interaction --no-progress
- docker run --network=betafashion --rm -e "COMPOSER_ALLOW_SUPERUSER=1" -e "ENABLE_XDEBUG=1" --env-file=repo/.env-test -v "`pwd`/repo:/var/www/html" --memory=2G quay.io/betafashion/runtime-php composer run-tests
services:
- docker
services:
docker:
memory: 4096

image:
name: quay.io/betafashion/ci-eb:latest
username: $DOCKER_USER
password: $DOCKER_PASSWORD

pipelines:
pull-requests:
'**':
- parallel:
- step: *Codestyle-step
- step: *Test-step

As u see on every commit in a pull-reguest code-style-checks and tests will run in parallel.
Both using kind of the same environment (just tests needs a database to run integration tests).
I see some potential to cache things here, but don't have a clue to do it.
1. both steps (Test & Codestyle) are building the "php" container and

2. doing "composer install". composer install in both cases will install all vendors. It is also important, because github has a limitation of how many things you can clone from their.

I think all of this can be cached if nothing changed (so no vendors or in the php container).
Can u help out with that or isn't it so easy like in my imagination :)?


Kind regards,

Martin

1 answer

0 votes
Devon Mather March 28, 2020

+1 👍🏻

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events