drone-cache icon indicating copy to clipboard operation
drone-cache copied to clipboard

If one of the mounted folder not exists, rebuild will failed.

Open wagaru opened this issue 4 years ago • 3 comments

I will do unit test on feature branch & master branch, and e2e test only for master branch.

For unit test, I need to run composer install, it will generate vendor/* For e2e test, I need to run npm install, it will generate node_modules/*

I want to cache this two folders, vendor & node_modules However, if it is a feature branch commit, it wont run e2e test, so there will be no node_modules to cache. And the final rebuild cache step will failed. My local folder /tmp/cache will still empty after rebuild.

螢幕快照 2020-07-21 上午11 02 14

Here is my example .drone.yml

- name: restore-cache
  pull: if-not-exists
  image: meltwater/drone-cache
  volumes:
  - name: cache
    path: /tmp/cache
  settings:
    backend: filesystem
    restore: true
    cache_key: volume
    archive_format: gzip
    mount:
    - vendor
    - node_modules

- name: unitTest
  image: php
  commands:
    - composer install
    - ./vendor/bin/phpunit
  when:
    branch:
    - feature/*
    - master

- name: e2eTest
  image: node
  commands:
    - npm install
    - npm run test
  when:
    branch:
    - master

- name: rebuild-cache
  pull: if-not-exists
  image: meltwater/drone-cache
  volumes:
  - name: cache
    path: /tmp/cache
  settings:
    backend: filesystem
    rebuild: true
    cache_key: volume
    archive_format: gzip
    mount:
    - vendor
    - node_modules
volumes:
- name: cache
  host:
    path: /tmp/cache

wagaru avatar Jul 21 '20 03:07 wagaru

Hi @wagaru I have the same issue

framled avatar Jul 21 '20 21:07 framled

@wagaru @framled Just to make sure that I understood you correctly. If one of the given two paths is NOT accessible, you still want task to succeed?

We can consider this as improvement, we have a similar issue to create separate archives for each given path. That being said, this is easily solvable by separating caching task per path if the given path is optional.

kakkoyun avatar Jul 30 '20 15:07 kakkoyun

@wagaru @framled Just to make sure that I understood you correctly. If one of the given two paths is NOT accessible, you still want task to succeed?

We can consider this as improvement, we have a similar issue to create separate archives for each given path. That being said, this is easily solvable by separating caching task per path if the given path is optional.

In my case, yes! The task should be successed, and still have the cache for exists folder.

wagaru avatar Jul 31 '20 06:07 wagaru