Skip to content

CI: Improve caching, speed up jobs, fix cache key, limit bundler-audit to schedules

georg requested to merge ci-improve-caching-speedup-jobs into master

This MR contains the following four commits:

CI: Fix and improve APT caching, to speed up CI jobs

Up until now, the APT caching didn't work correctly in all cases. This commit fixes the problems, and, at the same time, improves the handling: It checks first, if the APT cache directory does exist. Only if it doesn't, it creates the necessary directories and updates the APT package lists. This prevents unneeded runs of 'apt-get update'.

Additionally, this ensures, that in almost all cases, packages don't need to get downloaded, but instead, they're available already in the local filesystem, just waiting to be installed.

Combining both steps leads to reduced run times per CI job by ~ 10%.

--

CI: bundler-audit: Use ruby2.5, don't run global 'before_script'

--

CI: Fix cache key: Use project path slug, remove branch name

Before, we were using the project path, containing '/', which is not allowed in GitLab CI cache keys. Fix this via using the project path slug, which replaces special chars with '-'.

Additionally, we were using a cache key consisting of project path, CI job name and branch name. However, this lead to a inconsistent cache behavior: Force pushing a branch, which is quite common during development, would somehow reset the cache, making it empty / non existent in fact, leading to longer CI job runtimes. It seems GitLab takes the commit SHA into account while checking for the cache, if using this pattern.

To overcome this, don't explicitly set the branch name in the cache key, but instead rely only on the project path and job name. This also works if force pushing a branch, as some tests confirmed.

--

CI: Run bundler:audit job only if triggered via a schedule

Currently, bundler:audit is run anytime a branch is pushed. That's a waste of resources and unneeded. Therefore, soon, this job will be run via a pipeline once a week. Accordingly, this commit lays the groundwork so that the job is only run, if triggered via a pipeline.

Relates #283 (closed)

Edited by georg

Merge request reports