Skip to content
This repository was archived by the owner on Dec 2, 2024. It is now read-only.
This repository was archived by the owner on Dec 2, 2024. It is now read-only.

Dependency caching for test execution #17

@simoneborgio

Description

@simoneborgio

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions