diff --git a/services/gitlab/gitlab-coverage-redirect.service.js b/services/gitlab/gitlab-coverage-redirect.service.js new file mode 100644 index 0000000000000..d58e0191345d0 --- /dev/null +++ b/services/gitlab/gitlab-coverage-redirect.service.js @@ -0,0 +1,13 @@ +import { redirector } from '../index.js' + +export default redirector({ + category: 'coverage', + route: { + base: 'gitlab/coverage', + pattern: ':user/:repo/:branch', + }, + transformPath: ({ user, repo }) => + `/gitlab/pipeline-coverage/${user}/${repo}`, + transformQueryParams: ({ branch }) => ({ branch }), + dateAdded: new Date('2022-09-25'), +}) diff --git a/services/gitlab/gitlab-coverage-redirect.tester.js b/services/gitlab/gitlab-coverage-redirect.tester.js new file mode 100644 index 0000000000000..c82a2e67041a2 --- /dev/null +++ b/services/gitlab/gitlab-coverage-redirect.tester.js @@ -0,0 +1,22 @@ +import { createServiceTester } from '../tester.js' +export const t = await createServiceTester() + +t.create('Coverage redirect (with branch)') + .get('/gitlab-org/gitlab-runner/master.json') + .expectRedirect( + '/gitlab/pipeline-coverage/gitlab-org/gitlab-runner.json?branch=master' + ) + +t.create('Coverage redirect (with branch and job_name)') + .get('/gitlab-org/gitlab-runner/master.json?job_name=test coverage report') + .expectRedirect( + '/gitlab/pipeline-coverage/gitlab-org/gitlab-runner.json?branch=master&job_name=test%20coverage%20report' + ) + +t.create('Coverage redirect (with branch and gitlab_url)') + .get( + '/gitlab-org/gitlab-runner/master.json?gitlab_url=https://gitlab.gnome.org' + ) + .expectRedirect( + '/gitlab/pipeline-coverage/gitlab-org/gitlab-runner.json?branch=master&gitlab_url=https%3a%2f%2fgitlab.gnome.org' + ) diff --git a/services/gitlab/gitlab-coverage.service.js b/services/gitlab/gitlab-pipeline-coverage.service.js similarity index 78% rename from services/gitlab/gitlab-coverage.service.js rename to services/gitlab/gitlab-pipeline-coverage.service.js index a39354c996558..3267e8e4eb23b 100644 --- a/services/gitlab/gitlab-coverage.service.js +++ b/services/gitlab/gitlab-pipeline-coverage.service.js @@ -13,6 +13,7 @@ const schema = Joi.object({ const queryParamSchema = Joi.object({ gitlab_url: optionalUrl, job_name: Joi.string(), + branch: Joi.string(), }).required() const moreDocs = ` @@ -37,50 +38,44 @@ Also make sure you have set up code covrage parsing as described