convert some service classes to static props, run [archlinux aur azuredevops] (#5500)
* refactor(archlinux): convert to static props * refactor(aur): convert to static props * refactor(azuredevops): convert to static props * tests: fix AzDO Coverage service test Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
@@ -9,34 +9,25 @@ const schema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class ArchLinux extends BaseJsonService {
|
||||
static get category() {
|
||||
return 'version'
|
||||
static category = 'version'
|
||||
static route = {
|
||||
base: 'archlinux/v',
|
||||
pattern: ':repository/:architecture/:packageName',
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'archlinux/v',
|
||||
pattern: ':repository/:architecture/:packageName',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Arch Linux package',
|
||||
namedParams: {
|
||||
architecture: 'x86_64',
|
||||
repository: 'core',
|
||||
packageName: 'pacman',
|
||||
},
|
||||
staticPreview: renderVersionBadge({ version: '5.1.3' }),
|
||||
static examples = [
|
||||
{
|
||||
title: 'Arch Linux package',
|
||||
namedParams: {
|
||||
architecture: 'x86_64',
|
||||
repository: 'core',
|
||||
packageName: 'pacman',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: renderVersionBadge({ version: '5.1.3' }),
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'arch linux' }
|
||||
}
|
||||
static defaultBadgeData = { label: 'arch linux' }
|
||||
|
||||
async handle({ repository, architecture, packageName }) {
|
||||
const data = await this._requestJson({
|
||||
|
||||
@@ -25,9 +25,7 @@ const aurSchema = Joi.object({
|
||||
}).required()
|
||||
|
||||
class BaseAurService extends BaseJsonService {
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'aur' }
|
||||
}
|
||||
static defaultBadgeData = { label: 'aur' }
|
||||
|
||||
static _validate(data, schema) {
|
||||
if (data.resultcount === 0) {
|
||||
@@ -51,30 +49,18 @@ class BaseAurService extends BaseJsonService {
|
||||
}
|
||||
|
||||
class AurLicense extends BaseAurService {
|
||||
static get category() {
|
||||
return 'license'
|
||||
}
|
||||
static category = 'license'
|
||||
static route = { base: 'aur/license', pattern: ':packageName' }
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'aur/license',
|
||||
pattern: ':packageName',
|
||||
}
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'AUR license',
|
||||
namedParams: { packageName: 'android-studio' },
|
||||
staticPreview: this.render({ license: 'Apache' }),
|
||||
},
|
||||
]
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'AUR license',
|
||||
namedParams: { packageName: 'android-studio' },
|
||||
staticPreview: this.render({ license: 'Apache' }),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'license' }
|
||||
}
|
||||
static defaultBadgeData = { label: 'license' }
|
||||
|
||||
static render({ license }) {
|
||||
return { message: license, color: 'blue' }
|
||||
@@ -97,30 +83,19 @@ class AurLicense extends BaseAurService {
|
||||
}
|
||||
|
||||
class AurVotes extends BaseAurService {
|
||||
static get category() {
|
||||
return 'rating'
|
||||
}
|
||||
static category = 'rating'
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'aur/votes',
|
||||
pattern: ':packageName',
|
||||
}
|
||||
}
|
||||
static route = { base: 'aur/votes', pattern: ':packageName' }
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'AUR votes',
|
||||
namedParams: { packageName: 'dropbox' },
|
||||
staticPreview: this.render({ votes: '2280' }),
|
||||
},
|
||||
]
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'AUR votes',
|
||||
namedParams: { packageName: 'dropbox' },
|
||||
staticPreview: this.render({ votes: '2280' }),
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'votes' }
|
||||
}
|
||||
static defaultBadgeData = { label: 'votes' }
|
||||
|
||||
static render({ votes }) {
|
||||
return {
|
||||
@@ -136,26 +111,17 @@ class AurVotes extends BaseAurService {
|
||||
}
|
||||
|
||||
class AurVersion extends BaseAurService {
|
||||
static get category() {
|
||||
return 'version'
|
||||
}
|
||||
static category = 'version'
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'aur/version',
|
||||
pattern: ':packageName',
|
||||
}
|
||||
}
|
||||
static route = { base: 'aur/version', pattern: ':packageName' }
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'AUR version',
|
||||
namedParams: { packageName: 'visual-studio-code-bin' },
|
||||
staticPreview: this.render({ version: '1.34.0-2', outOfDate: null }),
|
||||
},
|
||||
]
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'AUR version',
|
||||
namedParams: { packageName: 'visual-studio-code-bin' },
|
||||
staticPreview: this.render({ version: '1.34.0-2', outOfDate: null }),
|
||||
},
|
||||
]
|
||||
|
||||
static render({ version, outOfDate }) {
|
||||
const color = outOfDate === null ? 'blue' : 'orange'
|
||||
@@ -172,30 +138,19 @@ class AurVersion extends BaseAurService {
|
||||
}
|
||||
|
||||
class AurMaintainer extends BaseAurService {
|
||||
static get category() {
|
||||
return 'other'
|
||||
}
|
||||
static category = 'other'
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'aur/maintainer',
|
||||
pattern: ':packageName',
|
||||
}
|
||||
}
|
||||
static route = { base: 'aur/maintainer', pattern: ':packageName' }
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'AUR maintainer',
|
||||
namedParams: { packageName: 'google-chrome' },
|
||||
staticPreview: this.render({ maintainer: 'luzifer' }),
|
||||
},
|
||||
]
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'AUR maintainer',
|
||||
namedParams: { packageName: 'google-chrome' },
|
||||
staticPreview: this.render({ maintainer: 'luzifer' }),
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'maintainer', color: 'blue' }
|
||||
}
|
||||
static defaultBadgeData = { label: 'maintainer', color: 'blue' }
|
||||
|
||||
static render({ maintainer }) {
|
||||
return { message: maintainer }
|
||||
|
||||
@@ -34,76 +34,70 @@ const documentation = `
|
||||
`
|
||||
|
||||
module.exports = class AzureDevOpsBuild extends BaseSvgScrapingService {
|
||||
static get category() {
|
||||
return 'build'
|
||||
static category = 'build'
|
||||
|
||||
static route = {
|
||||
base: 'azure-devops/build',
|
||||
pattern: ':organization/:projectId/:definitionId/:branch*',
|
||||
queryParamSchema,
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'azure-devops/build',
|
||||
pattern: ':organization/:projectId/:definitionId/:branch*',
|
||||
queryParamSchema,
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Azure DevOps builds',
|
||||
pattern: ':organization/:projectId/:definitionId',
|
||||
namedParams: {
|
||||
organization: 'totodem',
|
||||
projectId: '8cf3ec0e-d0c2-4fcd-8206-ad204f254a96',
|
||||
definitionId: '2',
|
||||
},
|
||||
staticPreview: renderBuildStatusBadge({ status: 'succeeded' }),
|
||||
keywords,
|
||||
documentation,
|
||||
static examples = [
|
||||
{
|
||||
title: 'Azure DevOps builds',
|
||||
pattern: ':organization/:projectId/:definitionId',
|
||||
namedParams: {
|
||||
organization: 'totodem',
|
||||
projectId: '8cf3ec0e-d0c2-4fcd-8206-ad204f254a96',
|
||||
definitionId: '2',
|
||||
},
|
||||
{
|
||||
title: 'Azure DevOps builds (branch)',
|
||||
pattern: ':organization/:projectId/:definitionId/:branch',
|
||||
namedParams: {
|
||||
organization: 'totodem',
|
||||
projectId: '8cf3ec0e-d0c2-4fcd-8206-ad204f254a96',
|
||||
definitionId: '2',
|
||||
branch: 'master',
|
||||
},
|
||||
staticPreview: renderBuildStatusBadge({ status: 'succeeded' }),
|
||||
keywords,
|
||||
documentation,
|
||||
staticPreview: renderBuildStatusBadge({ status: 'succeeded' }),
|
||||
keywords,
|
||||
documentation,
|
||||
},
|
||||
{
|
||||
title: 'Azure DevOps builds (branch)',
|
||||
pattern: ':organization/:projectId/:definitionId/:branch',
|
||||
namedParams: {
|
||||
organization: 'totodem',
|
||||
projectId: '8cf3ec0e-d0c2-4fcd-8206-ad204f254a96',
|
||||
definitionId: '2',
|
||||
branch: 'master',
|
||||
},
|
||||
{
|
||||
title: 'Azure DevOps builds (stage)',
|
||||
namedParams: {
|
||||
organization: 'totodem',
|
||||
projectId: '8cf3ec0e-d0c2-4fcd-8206-ad204f254a96',
|
||||
definitionId: '5',
|
||||
},
|
||||
queryParams: {
|
||||
stage: 'Successful Stage',
|
||||
},
|
||||
staticPreview: renderBuildStatusBadge({ status: 'succeeded' }),
|
||||
keywords,
|
||||
documentation,
|
||||
staticPreview: renderBuildStatusBadge({ status: 'succeeded' }),
|
||||
keywords,
|
||||
documentation,
|
||||
},
|
||||
{
|
||||
title: 'Azure DevOps builds (stage)',
|
||||
namedParams: {
|
||||
organization: 'totodem',
|
||||
projectId: '8cf3ec0e-d0c2-4fcd-8206-ad204f254a96',
|
||||
definitionId: '5',
|
||||
},
|
||||
{
|
||||
title: 'Azure DevOps builds (job)',
|
||||
namedParams: {
|
||||
organization: 'totodem',
|
||||
projectId: '8cf3ec0e-d0c2-4fcd-8206-ad204f254a96',
|
||||
definitionId: '5',
|
||||
},
|
||||
queryParams: {
|
||||
stage: 'Successful Stage',
|
||||
job: 'Successful Job',
|
||||
},
|
||||
staticPreview: renderBuildStatusBadge({ status: 'succeeded' }),
|
||||
keywords,
|
||||
documentation,
|
||||
queryParams: {
|
||||
stage: 'Successful Stage',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: renderBuildStatusBadge({ status: 'succeeded' }),
|
||||
keywords,
|
||||
documentation,
|
||||
},
|
||||
{
|
||||
title: 'Azure DevOps builds (job)',
|
||||
namedParams: {
|
||||
organization: 'totodem',
|
||||
projectId: '8cf3ec0e-d0c2-4fcd-8206-ad204f254a96',
|
||||
definitionId: '5',
|
||||
},
|
||||
queryParams: {
|
||||
stage: 'Successful Stage',
|
||||
job: 'Successful Job',
|
||||
},
|
||||
staticPreview: renderBuildStatusBadge({ status: 'succeeded' }),
|
||||
keywords,
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
|
||||
async handle(
|
||||
{ organization, projectId, definitionId, branch },
|
||||
|
||||
@@ -47,50 +47,42 @@ const buildCodeCoverageSchema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class AzureDevOpsCoverage extends AzureDevOpsBase {
|
||||
static get category() {
|
||||
return 'coverage'
|
||||
static category = 'coverage'
|
||||
|
||||
static route = {
|
||||
base: 'azure-devops/coverage',
|
||||
pattern: ':organization/:project/:definitionId/:branch*',
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'azure-devops/coverage',
|
||||
pattern: ':organization/:project/:definitionId/:branch*',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Azure DevOps coverage',
|
||||
pattern: ':organization/:project/:definitionId',
|
||||
namedParams: {
|
||||
organization: 'swellaby',
|
||||
project: 'opensource',
|
||||
definitionId: '25',
|
||||
},
|
||||
staticPreview: this.render({ coverage: 100 }),
|
||||
keywords,
|
||||
documentation,
|
||||
static examples = [
|
||||
{
|
||||
title: 'Azure DevOps coverage',
|
||||
pattern: ':organization/:project/:definitionId',
|
||||
namedParams: {
|
||||
organization: 'swellaby',
|
||||
project: 'opensource',
|
||||
definitionId: '25',
|
||||
},
|
||||
{
|
||||
title: 'Azure DevOps coverage (branch)',
|
||||
pattern: ':organization/:project/:definitionId/:branch',
|
||||
namedParams: {
|
||||
organization: 'swellaby',
|
||||
project: 'opensource',
|
||||
definitionId: '25',
|
||||
branch: 'master',
|
||||
},
|
||||
staticPreview: this.render({ coverage: 100 }),
|
||||
keywords,
|
||||
documentation,
|
||||
staticPreview: this.render({ coverage: 100 }),
|
||||
keywords,
|
||||
documentation,
|
||||
},
|
||||
{
|
||||
title: 'Azure DevOps coverage (branch)',
|
||||
pattern: ':organization/:project/:definitionId/:branch',
|
||||
namedParams: {
|
||||
organization: 'swellaby',
|
||||
project: 'opensource',
|
||||
definitionId: '25',
|
||||
branch: 'master',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: this.render({ coverage: 100 }),
|
||||
keywords,
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'coverage' }
|
||||
}
|
||||
static defaultBadgeData = { label: 'coverage' }
|
||||
|
||||
static render({ coverage }) {
|
||||
return {
|
||||
|
||||
@@ -5,7 +5,7 @@ const t = (module.exports = require('../tester').createServiceTester())
|
||||
|
||||
const org = 'swellaby'
|
||||
const project = 'opensource'
|
||||
const linuxDefinitionId = 21
|
||||
const linuxDefinitionId = 25
|
||||
const macDefinitionId = 26
|
||||
const windowsDefinitionId = 24
|
||||
const nonExistentDefinitionId = 234421
|
||||
|
||||
@@ -23,39 +23,29 @@ const documentation = `
|
||||
`
|
||||
|
||||
module.exports = class AzureDevOpsRelease extends BaseSvgScrapingService {
|
||||
static get category() {
|
||||
return 'build'
|
||||
static category = 'build'
|
||||
|
||||
static route = {
|
||||
base: 'azure-devops/release',
|
||||
pattern: ':organization/:projectId/:definitionId/:environmentId',
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'azure-devops/release',
|
||||
pattern: ':organization/:projectId/:definitionId/:environmentId',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Azure DevOps releases',
|
||||
namedParams: {
|
||||
organization: 'totodem',
|
||||
projectId: '8cf3ec0e-d0c2-4fcd-8206-ad204f254a96',
|
||||
definitionId: '1',
|
||||
environmentId: '1',
|
||||
},
|
||||
staticPreview: renderBuildStatusBadge({ status: 'succeeded' }),
|
||||
keywords,
|
||||
documentation,
|
||||
static examples = [
|
||||
{
|
||||
title: 'Azure DevOps releases',
|
||||
namedParams: {
|
||||
organization: 'totodem',
|
||||
projectId: '8cf3ec0e-d0c2-4fcd-8206-ad204f254a96',
|
||||
definitionId: '1',
|
||||
environmentId: '1',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: renderBuildStatusBadge({ status: 'succeeded' }),
|
||||
keywords,
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'deployment',
|
||||
}
|
||||
}
|
||||
static defaultBadgeData = { label: 'deployment' }
|
||||
|
||||
async handle({ organization, projectId, definitionId, environmentId }) {
|
||||
// Microsoft documentation: ?
|
||||
|
||||
@@ -62,103 +62,95 @@ const buildTestResultSummarySchema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class AzureDevOpsTests extends AzureDevOpsBase {
|
||||
static get category() {
|
||||
return 'build'
|
||||
static category = 'build'
|
||||
|
||||
static route = {
|
||||
base: 'azure-devops/tests',
|
||||
pattern: ':organization/:project/:definitionId/:branch*',
|
||||
queryParamSchema: testResultQueryParamSchema,
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'azure-devops/tests',
|
||||
pattern: ':organization/:project/:definitionId/:branch*',
|
||||
queryParamSchema: testResultQueryParamSchema,
|
||||
}
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'Azure DevOps tests',
|
||||
pattern: ':organization/:project/:definitionId',
|
||||
namedParams: {
|
||||
organization: 'azuredevops-powershell',
|
||||
project: 'azuredevops-powershell',
|
||||
definitionId: '1',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
passed: 20,
|
||||
failed: 1,
|
||||
skipped: 1,
|
||||
total: 22,
|
||||
}),
|
||||
...commonAttrs,
|
||||
},
|
||||
{
|
||||
title: 'Azure DevOps tests (branch)',
|
||||
pattern: ':organization/:project/:definitionId/:branch',
|
||||
namedParams: {
|
||||
organization: 'azuredevops-powershell',
|
||||
project: 'azuredevops-powershell',
|
||||
definitionId: '1',
|
||||
branch: 'master',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
passed: 20,
|
||||
failed: 1,
|
||||
skipped: 1,
|
||||
total: 22,
|
||||
}),
|
||||
...commonAttrs,
|
||||
},
|
||||
{
|
||||
title: 'Azure DevOps tests (compact)',
|
||||
pattern: ':organization/:project/:definitionId',
|
||||
namedParams: {
|
||||
organization: 'azuredevops-powershell',
|
||||
project: 'azuredevops-powershell',
|
||||
definitionId: '1',
|
||||
},
|
||||
queryParams: {
|
||||
compact_message: null,
|
||||
},
|
||||
staticPreview: this.render({
|
||||
passed: 20,
|
||||
failed: 1,
|
||||
skipped: 1,
|
||||
total: 22,
|
||||
isCompact: true,
|
||||
}),
|
||||
...commonAttrs,
|
||||
},
|
||||
{
|
||||
title: 'Azure DevOps tests with custom labels',
|
||||
pattern: ':organization/:project/:definitionId',
|
||||
namedParams: {
|
||||
organization: 'azuredevops-powershell',
|
||||
project: 'azuredevops-powershell',
|
||||
definitionId: '1',
|
||||
},
|
||||
queryParams: {
|
||||
passed_label: 'good',
|
||||
failed_label: 'bad',
|
||||
skipped_label: 'n/a',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
passed: 20,
|
||||
failed: 1,
|
||||
skipped: 1,
|
||||
total: 22,
|
||||
passedLabel: 'good',
|
||||
failedLabel: 'bad',
|
||||
skippedLabel: 'n/a',
|
||||
}),
|
||||
...commonAttrs,
|
||||
},
|
||||
]
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Azure DevOps tests',
|
||||
pattern: ':organization/:project/:definitionId',
|
||||
namedParams: {
|
||||
organization: 'azuredevops-powershell',
|
||||
project: 'azuredevops-powershell',
|
||||
definitionId: '1',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
passed: 20,
|
||||
failed: 1,
|
||||
skipped: 1,
|
||||
total: 22,
|
||||
}),
|
||||
...commonAttrs,
|
||||
},
|
||||
{
|
||||
title: 'Azure DevOps tests (branch)',
|
||||
pattern: ':organization/:project/:definitionId/:branch',
|
||||
namedParams: {
|
||||
organization: 'azuredevops-powershell',
|
||||
project: 'azuredevops-powershell',
|
||||
definitionId: '1',
|
||||
branch: 'master',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
passed: 20,
|
||||
failed: 1,
|
||||
skipped: 1,
|
||||
total: 22,
|
||||
}),
|
||||
...commonAttrs,
|
||||
},
|
||||
{
|
||||
title: 'Azure DevOps tests (compact)',
|
||||
pattern: ':organization/:project/:definitionId',
|
||||
namedParams: {
|
||||
organization: 'azuredevops-powershell',
|
||||
project: 'azuredevops-powershell',
|
||||
definitionId: '1',
|
||||
},
|
||||
queryParams: {
|
||||
compact_message: null,
|
||||
},
|
||||
staticPreview: this.render({
|
||||
passed: 20,
|
||||
failed: 1,
|
||||
skipped: 1,
|
||||
total: 22,
|
||||
isCompact: true,
|
||||
}),
|
||||
...commonAttrs,
|
||||
},
|
||||
{
|
||||
title: 'Azure DevOps tests with custom labels',
|
||||
pattern: ':organization/:project/:definitionId',
|
||||
namedParams: {
|
||||
organization: 'azuredevops-powershell',
|
||||
project: 'azuredevops-powershell',
|
||||
definitionId: '1',
|
||||
},
|
||||
queryParams: {
|
||||
passed_label: 'good',
|
||||
failed_label: 'bad',
|
||||
skipped_label: 'n/a',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
passed: 20,
|
||||
failed: 1,
|
||||
skipped: 1,
|
||||
total: 22,
|
||||
passedLabel: 'good',
|
||||
failedLabel: 'bad',
|
||||
skippedLabel: 'n/a',
|
||||
}),
|
||||
...commonAttrs,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'tests' }
|
||||
}
|
||||
static defaultBadgeData = { label: 'tests' }
|
||||
|
||||
static render({
|
||||
passed,
|
||||
|
||||
Reference in New Issue
Block a user