Use artifact relative URLs to fetch Knapsack and Flaky tests metadata
Our CI uses the Knapsack gem to split tests and run them in parallel, considering the running time of each individual spec test. In order to have accurate timings, we save the execution metadata in a remote S3, which we use to retrieve on new builds.
When a new pipeline is triggered, we trigger the retrieve-tests-metadata
which downloads from this remote S3, the test metadata generated from master
. It is then saved as an artifact which is consumed by the next steps.
When in master, we have an additional last step: update-tests-metadata
, which will execute scripts/merge-reports
and merge all knapsack reports and push it back to S3.
All of this can be seen here: .gitlab/ci/test-metadata.gitlab-ci.yml
Considering https://about.gitlab.com/handbook/engineering/#dogfooding-antipatterns we shouldn't be using an external S3 for that, but our own artifacts. I believe when we implemented this solution, it didn't have the needed capabilities. Now it does:
We can use this relative URL: https://docs.gitlab.com/ee/user/project/pipelines/job_artifacts.html#downloading-the-latest-artifacts
here is one example how to retrieve latest knapsack report from master: https://gitlab.com/gitlab-org/gitlab/-/jobs/artifacts/master/raw/knapsack/report-master.json?job=update-tests-metadata
The same idea can be used for our rspec_flaky
usage. It relies on the same jobs and the same S3 and pattern.