4

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.

2 Answers 2

2

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

1
  • I had to do a double take when I opened the Gitlab issue. I wrote that!
    – VBwhatnow
    Commented May 10 at 8:49
0

You have no cache configured on your runner apart from the Docker cache, as your [runners.cache] section is empty.

From https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runnersdocker-section:

The Docker executor has 2 levels of caching: a global one (like any other executor) and a local cache based on Docker volumes. This configuration flag acts only on the local one which disables the use of automatically created (not mapped to a host directory) cache volumes. In other words, it only prevents creating a container that holds temporary files of builds, it does not disable the cache if the Runner is configured in distributed cache mode.

Refer to https://docs.gitlab.com/runner/configuration/autoscale.html#distributed-runners-caching for distributed cache mode.

1
  • 4
    The [runners.cache] section is only for distributed runners, I don't want to upload my cache to an S3 or GCS instance. I only want to do local caching as this is just for some experimentation. The paragraph that you linked talks about local caches based on Docker volumes which is already defined by default as volumes = ["/cache"]
    – VBwhatnow
    Commented Mar 26, 2019 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.