-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into jenkins-version
- Loading branch information
Showing
46 changed files
with
2,074 additions
and
621 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict' | ||
|
||
const Joi = require('joi') | ||
const { NotFound } = require('..') | ||
|
||
const keywords = ['codeclimate'] | ||
|
||
const repoSchema = Joi.object({ | ||
data: Joi.array() | ||
.max(1) | ||
.items( | ||
Joi.object({ | ||
id: Joi.string().required(), | ||
relationships: Joi.object({ | ||
latest_default_branch_snapshot: Joi.object({ | ||
data: Joi.object({ | ||
id: Joi.string().required(), | ||
}).allow(null), | ||
}).required(), | ||
latest_default_branch_test_report: Joi.object({ | ||
data: Joi.object({ | ||
id: Joi.string().required(), | ||
}).allow(null), | ||
}).required(), | ||
}).required(), | ||
}) | ||
) | ||
.required(), | ||
}).required() | ||
|
||
async function fetchRepo(serviceInstance, { user, repo }) { | ||
const { | ||
data: [repoInfo], | ||
} = await serviceInstance._requestJson({ | ||
schema: repoSchema, | ||
url: 'https://api.codeclimate.com/v1/repos', | ||
options: { qs: { github_slug: `${user}/${repo}` } }, | ||
}) | ||
if (repoInfo === undefined) { | ||
throw new NotFound({ prettyMessage: 'repo not found' }) | ||
} | ||
return repoInfo | ||
} | ||
|
||
module.exports = { | ||
keywords, | ||
fetchRepo, | ||
} |
39 changes: 39 additions & 0 deletions
39
services/codeclimate/codeclimate-coverage-redirector.service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict' | ||
|
||
const { redirector } = require('..') | ||
|
||
module.exports = [ | ||
// http://github.com/badges/shields/issues/1387 | ||
// https://github.com/badges/shields/pull/3320#issuecomment-483795000 | ||
redirector({ | ||
name: 'CodeclimateCoveragePercentageRedirect', | ||
category: 'coverage', | ||
route: { | ||
base: 'codeclimate', | ||
pattern: ':which(c|coverage-percentage)/:user/:repo', | ||
}, | ||
transformPath: ({ user, repo }) => `/codeclimate/coverage/${user}/${repo}`, | ||
dateAdded: new Date('2019-04-15'), | ||
}), | ||
redirector({ | ||
name: 'CodeclimateCoverageLetterRedirect', | ||
category: 'coverage', | ||
route: { | ||
base: 'codeclimate/c-letter', | ||
pattern: ':user/:repo', | ||
}, | ||
transformPath: ({ user, repo }) => | ||
`/codeclimate/coverage-letter/${user}/${repo}`, | ||
dateAdded: new Date('2019-04-15'), | ||
}), | ||
redirector({ | ||
name: 'CodeclimateTopLevelCoverageRedirect', | ||
category: 'coverage', | ||
route: { | ||
base: 'codeclimate', | ||
pattern: ':user/:repo', | ||
}, | ||
transformPath: ({ user, repo }) => `/codeclimate/coverage/${user}/${repo}`, | ||
dateAdded: new Date('2019-04-15'), | ||
}), | ||
] |
37 changes: 37 additions & 0 deletions
37
services/codeclimate/codeclimate-coverage-redirector.tester.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict' | ||
|
||
const { ServiceTester } = require('../tester') | ||
|
||
const t = (module.exports = new ServiceTester({ | ||
id: 'CodeclimateCoverageRedirector', | ||
title: 'Code Climate Coverage Redirector', | ||
pathPrefix: '/codeclimate', | ||
})) | ||
|
||
t.create('Top-level coverage shortcut') | ||
.get('/jekyll/jekyll.svg', { | ||
followRedirect: false, | ||
}) | ||
.expectStatus(301) | ||
.expectHeader('Location', '/codeclimate/coverage/jekyll/jekyll.svg') | ||
|
||
t.create('Coverage shortcut') | ||
.get('/c/jekyll/jekyll.svg', { | ||
followRedirect: false, | ||
}) | ||
.expectStatus(301) | ||
.expectHeader('Location', '/codeclimate/coverage/jekyll/jekyll.svg') | ||
|
||
t.create('Coverage letter shortcut') | ||
.get('/c-letter/jekyll/jekyll.svg', { | ||
followRedirect: false, | ||
}) | ||
.expectStatus(301) | ||
.expectHeader('Location', '/codeclimate/coverage-letter/jekyll/jekyll.svg') | ||
|
||
t.create('Coverage percentage shortcut') | ||
.get('/coverage-percentage/jekyll/jekyll.svg', { | ||
followRedirect: false, | ||
}) | ||
.expectStatus(301) | ||
.expectHeader('Location', '/codeclimate/coverage/jekyll/jekyll.svg') |
Oops, something went wrong.