Files
shields/services/appveyor/appveyor-base.js
Caleb Cartwright e626d64b4e convert some service classes to static props, run [ansible apm appveyor] (#5496)
* refactor(ansible): convert to static props

* refactor(apm): convert to static props

* refactor(appveyor): convert to static props

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2020-09-09 22:57:47 +00:00

45 lines
1.1 KiB
JavaScript

'use strict'
const Joi = require('@hapi/joi')
const { nonNegativeInteger } = require('../validators')
const { isBuildStatus } = require('../build-status')
const { BaseJsonService } = require('..')
const schema = Joi.object({
build: Joi.object({
status: isBuildStatus,
jobs: Joi.array()
.items({
name: Joi.string().allow('').required(),
status: isBuildStatus,
testsCount: nonNegativeInteger,
passedTestsCount: nonNegativeInteger,
failedTestsCount: nonNegativeInteger,
})
.required(),
}),
}).required()
module.exports = class AppVeyorBase extends BaseJsonService {
static category = 'build'
async fetch({ user, repo, branch }) {
let url = `https://ci.appveyor.com/api/projects/${user}/${repo}`
if (branch != null) {
url += `/branch/${branch}`
}
return this._requestJson({
schema,
url,
errorMessages: { 404: 'project not found or access denied' },
})
}
static buildRoute(base) {
return {
base,
pattern: ':user/:repo/:branch*',
}
}
}