Skip to content

CCACHE_WORK_DIR doesn't expand correctly

Here is an example pipeline that was executed from a dummypackage-forked project and includes pipeline definitions from a patched branch. The console output from the build-before-script section gives:

$ mkdir -p ${WORKING_DIR} ${CCACHE_WORK_DIR} # collapsed multi-line command
++ mkdir -p /builds/hustle-ci/dummypackage/debian/output '${CI_PROJECT_DIR}/debian/output/.ccache'
++ pwd
/builds/hustle-ci/dummypackage
++ ls -alR
.:
total 72
drwxrwxrwx. 3 root root 4096 Aug 22 09:57 $CI_PROJECT_DIR
drwxrwxrwx. 8 root root 4096 Aug 22 09:57 .
drwxrwxrwx. 4 root root 4096 Aug 22 09:57 ..
drwxrwxrwx. 6 root root 4096 Aug 22 09:57 .git
drwxrwxrwx. 5 root root 4096 Aug 22 09:57 debian
drwxrwxrwx. 3 root root 4096 Aug 22 09:57 dummypackage
-rw-rw-rw-. 1 root root  775 Aug 22 09:57 setup.py
drwxrwxrwx. 2 root root 4096 Aug 22 09:57 tests

...

++ mv '$CI_PROJECT_DIR/debian/output/.ccache' /builds/hustle-ci/dummypackage/../.ccache
++ pwd
/builds/hustle-ci/dummypackage
++ ls -alR
.:
total 64
drwxrwxrwx. 3 root root 4096 Aug 22 12:37 $CI_PROJECT_DIR
drwxrwxrwx. 7 root root 4096 Aug 22 12:37 .
drwxrwxrwx. 5 root root 4096 Aug 22 12:37 ..
drwxrwxrwx. 6 root root 4096 Aug 22 12:36 .git
drwxrwxrwx. 5 root root 4096 Aug 22 12:37 debian
drwxrwxrwx. 3 root root 4096 Aug 22 12:36 dummypackage
-rw-rw-rw-. 1 root root  775 Aug 22 12:36 setup.py
drwxrwxrwx. 2 root root 4096 Aug 22 12:36 tests

...

++ gbp pull --ignore-branch --pristine-tar --track-missing
gbp:info: Fetching from default remote for each branch
gbp:info: Found detached head at 'f7dcc3130874fe5ffda0c1ba1f5ac8474f3525fd'
gbp:info: Branch 'master' is already up to date.
gbp:info: Branch 'upstream' is already up to date.
gbp:info: Branch 'pristine-tar' is already up to date.

In this case that $CI_PROJECT_DIR directory remains in the ${CI_PROJECT_DIR} along with some of its subdirectories. However, since git will ignore empty directory tree, the pipeline will pass as we have right now, but it can be a potential problem.

For example, commit 24a1d323 in closed MR !150 (closed) was to brace all the variables, and this will leave two folders, $CI_PROJECT_DIR and ${CI_PROJECT_DIR}, in the ${CI_PROJECT_DIR} directory. This time, the .ccache directory inside ${CI_PROJECT_DIR} will be moved upward by mv '${CI_PROJECT_DIR}/debian/output/.ccache' /builds/hustle-ci/dummypackage/../.ccache, but the .ccache directory extracted to $CI_PROJECT_DIR (downloaded from cache) won't. Since now there are uncommitted files appearing in the git working dir, the following gbp command will fail with:

++ gbp pull --ignore-branch --pristine-tar --track-missing
gbp:info: Fetching from default remote for each branch
gbp:info: Found detached head at 'f7dcc3130874fe5ffda0c1ba1f5ac8474f3525fd'
gbp:error: You have uncommitted changes in your source tree:
gbp:error: HEAD detached at f7dcc31
Untracked files:
  (use "git add <file>..." to include in what will be committed)
	$CI_PROJECT_DIR/

nothing added to commit but untracked files present (use "git add" to track)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information