dockergitlabgitlab-ci-runnerdocker-for-windows

Local Gitlab runner doesn’t restore cache, but shared runners do


I’m trying to compile and test a C++ project and use ccache to speed up my build time.

My .gitlab-ci.yml allows caching just fine with the Gitlab Shared Runners, but when I run the same pipeline with my runner the job reports creating the cache and successfully extracting it on the following run but no files are added to the cache paths.

build:
  stage: build
  cache:
    key: "$CI_COMMIT_REF_SLUG"
    paths:
      - ccache/
  artifacts:
    paths:
      - build/app/wg-ui
      - build/lib/libproject-lib.so*
      - build/tests/tests
  script:
    - echo "Starting build"
    - ls
    - ls ccache
    - mkdir -p build && cd build
    - qmake ../
    - make -j$(nproc) -Oline CXX="ccache ${CXX}"

Here is the runners section of my config.toml

[[runners]]
  name = "Laptop-Runner"
  url = "https://gitlab.com/"
  token = "{REDACTED}"
  executor = "docker"
  [runners.docker]
    tls_verify = false
    image = "alpine:latest"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    cache_dir = ""
    shm_size = 0
    pull_policy = "if-not-present"
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]

Is there a configuration step I’ve missed? Do I need to do anything with my config.toml?

Update

Rather than use Docker for Windows that I was using before, I decided to set up a VM and run Docker and the Gitlab-Runner from there.

Using the exact same .gitlab-ci.yml and config.toml caching worked perfectly as expected; So I'm assuming that the issue is either with my Docker configuration or with the Windows implementation of the Gitlab Runner.


Solution

  • I know that this is a really old question, but it still shows up in google results. The issue is that there is a known bug with the Windows Docker executor and a difference between windows and linux file paths. The only current fix is to use a custom version of the gitlab-runner, or use a different host.

    Here is a forum post discussing it: https://forum.gitlab.com/t/windows-docker-executor-deletes-cache-zip-before-cache-is-restored/29259/5

    And here is the gitlab issue referencing it: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4091