Skip to content

Commit

Permalink
Deprecate [Continuousphp] service (#5942)
Browse files Browse the repository at this point in the history
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
  • Loading branch information
PyvesB and repo-ranger[bot] authored Dec 14, 2020
1 parent 1361500 commit 87d8028
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 102 deletions.
79 changes: 9 additions & 70 deletions services/continuousphp/continuousphp.service.js
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'),
})
19 changes: 0 additions & 19 deletions services/continuousphp/continuousphp.spec.js

This file was deleted.

25 changes: 12 additions & 13 deletions services/continuousphp/continuousphp.tester.js
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' })

0 comments on commit 87d8028

Please sign in to comment.