-
-
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.
Deprecate [Continuousphp] service (#5942)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
- Loading branch information
1 parent
1361500
commit 87d8028
Showing
3 changed files
with
21 additions
and
102 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,13 @@ | ||
'use strict' | ||
|
||
const Joi = require('joi') | ||
const { isBuildStatus, renderBuildStatusBadge } = require('../build-status') | ||
const { BaseJsonService } = require('..') | ||
const { deprecatedService } = require('..') | ||
|
||
const schema = Joi.object({ | ||
status: Joi.alternatives().try(isBuildStatus, Joi.equal('unknown')), | ||
}).required() | ||
|
||
const statusMap = { | ||
unstable: 'yellow', | ||
running: 'blue', | ||
} | ||
|
||
module.exports = class ContinuousPhp extends BaseJsonService { | ||
static category = 'build' | ||
static route = { | ||
module.exports = deprecatedService({ | ||
category: 'build', | ||
route: { | ||
base: 'continuousphp', | ||
pattern: ':provider/:user/:repo/:branch*', | ||
} | ||
|
||
static examples = [ | ||
{ | ||
title: 'continuousphp', | ||
pattern: ':provider/:user/:repo', | ||
namedParams: { | ||
provider: 'git-hub', | ||
user: 'doctrine', | ||
repo: 'dbal', | ||
}, | ||
staticPreview: renderBuildStatusBadge({ status: 'passing' }), | ||
}, | ||
{ | ||
title: 'continuousphp', | ||
pattern: ':provider/:user/:repo/:branch', | ||
namedParams: { | ||
provider: 'git-hub', | ||
user: 'doctrine', | ||
repo: 'dbal', | ||
branch: 'master', | ||
}, | ||
staticPreview: renderBuildStatusBadge({ status: 'passing' }), | ||
}, | ||
] | ||
|
||
static defaultBadgeData = { label: 'continuousphp' } | ||
|
||
static render({ status }) { | ||
const badge = renderBuildStatusBadge({ label: 'build', status }) | ||
const customColor = statusMap[status] | ||
if (customColor) { | ||
badge.color = customColor | ||
} | ||
return badge | ||
} | ||
|
||
async fetch({ provider, user, repo, branch }) { | ||
const url = `https://status.continuousphp.com/${provider}/${user}/${repo}/status-info` | ||
return this._requestJson({ | ||
schema, | ||
url, | ||
options: { qs: { branch } }, | ||
errorMessages: { | ||
404: 'project not found', | ||
}, | ||
}) | ||
} | ||
|
||
async handle({ provider, user, repo, branch }) { | ||
const json = await this.fetch({ provider, user, repo, branch }) | ||
return this.constructor.render({ status: json.status }) | ||
} | ||
} | ||
pattern: ':various+', | ||
}, | ||
label: 'continuousphp', | ||
dateAdded: new Date('2020-12-12'), | ||
}) |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
'use strict' | ||
|
||
const Joi = require('joi') | ||
const { isBuildStatus } = require('../build-status') | ||
const t = (module.exports = require('../tester').createServiceTester()) | ||
const { ServiceTester } = require('../tester') | ||
|
||
t.create('build status on default branch') | ||
const t = (module.exports = new ServiceTester({ | ||
id: 'continuousphp', | ||
title: 'Continuousphp', | ||
})) | ||
|
||
t.create('no longer available (previously build status on default branch)') | ||
.get('/git-hub/doctrine/dbal.json') | ||
.expectBadge({ | ||
label: 'build', | ||
message: Joi.alternatives().try(isBuildStatus, Joi.equal('unknown')), | ||
label: 'continuousphp', | ||
message: 'no longer available', | ||
}) | ||
|
||
t.create('build status on named branch') | ||
t.create('no longer available (previously build status on named branch)') | ||
.get('/git-hub/doctrine/dbal/develop.json') | ||
.expectBadge({ | ||
label: 'build', | ||
message: Joi.alternatives().try(isBuildStatus, Joi.equal('unknown')), | ||
label: 'continuousphp', | ||
message: 'no longer available', | ||
}) | ||
|
||
t.create('unknown repo') | ||
.get('/git-hub/this-repo/does-not-exist.json') | ||
.expectBadge({ label: 'continuousphp', message: 'project not found' }) |