Dependency caching for test execution
simoneborgio opened this issue · 0 comments
simoneborgio commented
Test phase is really slow using the plugin, mainly because I'm unable to cache Maven dependencies.
I'm currently working on this pipeline:
kind: pipeline
type: docker
name: default
steps:
- name: test
image: quay.io/testcontainers/dind-drone-plugin
environment:
CI_WORKSPACE: "/drone/src"
settings:
# This image will run the cmd with your build steps
build_image: maven:3-openjdk-17-slim
# This specifies the command that should be executed to perform build, test and
# integration tests. Not to be confused with Drone's `command`:
cmd: sleep 5 && mvn clean test
prefetch_images:
- "maven:3-openjdk-17-slim"
# volumes:
# - name: maven-repo
# path: /root/.m2
volumes:
- name: dockersock
path: /var/run
- name: build
image: maven:3-openjdk-17-slim
commands:
- mvn clean package -DskipTests
volumes:
- name: maven-repo
path: /root/.m2
# Specify docker:dind as a service
services:
- name: docker
image: docker:dind
privileged: true
volumes:
- name: dockersock
path: /var/run
volumes:
- name: dockersock
temp: { }
- name: maven-repo
host:
path: /home/administrator/drone/cache/maven-repo
maven-repo
volume is used as cache for Maven dependencies. It works fine in the build
step, but AFAIK it is not possible to use the same approach in test
(see the commented lines below prefetch_images
).
Moreover, test
step downloads the maven:3-openjdk-17-slim image every time it is executed.
The result is test
step is taking 11 minutes, while the actual build
step only requires 22 seconds.
Is it possible to cache dependencies and use them in a test step with dind or is there another best-practice to improve this performance?