diff options
author | Sami Hiltunen <shiltunen@gitlab.com> | 2022-05-18 17:31:34 +0300 |
---|---|---|
committer | Sami Hiltunen <shiltunen@gitlab.com> | 2022-05-25 10:30:04 +0300 |
commit | 7c1222dbae4da48c95bd5f1e9177b165c89bd569 (patch) | |
tree | d1ca77c3c60e5210dfac8e7c320fb352f63f9f5c | |
parent | fd3b0c83d669f3f5cd82c9da3df8d611a606a404 (diff) |
Remove unnecessary dependencies on the build stage
The testing stage doesn't actually depend on any of the build stage's
artifacts. It only uses the cache which the build stage writes. The
caches are only expired if the relevant files changes like go.sum or
the Gemfile.lock. These caches merely speed up the testing jobs when
they are present. As such, we can remove the build dependency from the
test jobs. Most of the time, the files that make up the cache key are
not changed and thus the both the build step and the test step end up
using the cache. This speeds up the general case by running the steps
in parallel and making test failures visible earlier.
In the rarer case where the cache keys are changed, the test steps will
end up performing some extra work that the cache avoids. This seems like
a fair trade-off to speed up the general case.
There are three exceptions to this though:
'test:coverage' fails without the cache in place as it fails with permission
errors creating the directory for the test coverage report.
'verify' fails with a timeout if the cache is not in place.
'gosec_sast' depends on some files from the cache being moved into the right
place.
As the above jobs fail without the cache, the dependencies are still left
in place for them.
-rw-r--r-- | .gitlab-ci.yml | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3cac1a579..9670c783a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -67,7 +67,7 @@ include: policy: pull .test_template: &test_definition - needs: [ build ] + needs: [] stage: test cache: - *cache_deps_configuration @@ -180,7 +180,7 @@ test: test:coverage: <<: *test_definition - needs: [ build ] + needs: [ build ] # this job fails with permission errors if the caches from the build step are not in place script: # We need to explicitly build all prerequisites so that we can run tests unprivileged. - make -j$(nproc) build prepare-tests $(pwd)/_build/tools/gocover-cobertura @@ -250,7 +250,7 @@ test:praefect_smoke: - ./_build/bin/praefect -config config.praefect.toml sql-migrate verify: - needs: [ build ] + needs: [ build ] # this job timeouts if the caches are not in place from the build step stage: test cache: - *cache_deps_configuration @@ -266,7 +266,7 @@ verify: when: on_failure dbschema: - needs: [ build ] + needs: [] stage: test cache: - *cache_deps_configuration |