Skip to content

Commit

Permalink
Merge branch 'master' into twitch-social
Browse files Browse the repository at this point in the history
  • Loading branch information
PyvesB authored Feb 14, 2021
2 parents f4276d3 + bf8c86f commit 6def7af
Show file tree
Hide file tree
Showing 26 changed files with 2,032 additions and 1,563 deletions.
4 changes: 3 additions & 1 deletion .github/actions/draft-release/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ touch temp-changes.txt
echo "## $RELEASE_NAME"
echo ""
git log "$LAST_TAG"..HEAD --no-merges --oneline --pretty="format:- %s" --perl-regexp --author='^((?!dependabot).*)$'
echo $'\n'
echo $'\n- Dependency updates\n'
} >> temp-changes.txt
BASE_URL="https:\/\/github.com\/badges\/shields\/issues\/"
sed -r -i "s/\((\#)([0-9]+)\)$/\[\1\2\]\($BASE_URL\2\)/g" temp-changes.txt

# Write the changelog
sed -i "${INSERT_POINT} r temp-changes.txt" CHANGELOG.md
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ There are three places to get help:
used by developers or which are widely used by developers.
- The left-hand side of a badge should not advertise. It should be a lowercase _noun_
succinctly describing the meaning of the right-hand side.
- Except for badges using the `social` style, logos should be _turned off by
- Except for badges using the `social` style, logos and links should be _turned off by
default_.
- Badges should not obtain data from undocumented or reverse-engineered API endpoints.
- Badges should not obtain data by scraping web pages - these are likely to break frequently.
Expand Down
6 changes: 4 additions & 2 deletions frontend/components/usage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,10 @@ export default function Usage({ baseUrl }: { baseUrl: string }): JSX.Element {
<QueryParam
documentation={
<span>
Specify what clicking on the left/right of a badge should do
(esp. for social badge style)
Specify what clicking on the left/right of a badge should do.
Note that this only works when integrating your badge in an
<StyledCode>&lt;object&gt;</StyledCode> HTML tag, but not an
<StyledCode>&lt;img&gt;</StyledCode> tag or a markup language.
</span>
}
key="link"
Expand Down
3,025 changes: 1,528 additions & 1,497 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
"pretty-bytes": "^5.5.0",
"priorityqueuejs": "^2.0.0",
"prom-client": "^13.1.0",
"query-string": "^6.13.8",
"query-string": "^6.14.0",
"request": "~2.88.2",
"semver": "~7.3.4",
"simple-icons": "4.8.0",
"simple-icons": "4.10.0",
"webextension-store-meta": "^1.0.3",
"xmldom": "~0.4.0",
"xpath": "~0.0.32"
Expand Down Expand Up @@ -151,7 +151,7 @@
"@types/node": "^14.14.25",
"@types/react-helmet": "^6.1.0",
"@types/react-modal": "^3.10.6",
"@types/react-select": "^4.0.12",
"@types/react-select": "^4.0.13",
"@types/styled-components": "5.1.7",
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
Expand All @@ -161,7 +161,7 @@
"caller": "^1.0.1",
"chai": "^4.3.0",
"chai-as-promised": "^7.1.1",
"chai-datetime": "^1.7.0",
"chai-datetime": "^1.8.0",
"chai-string": "^1.4.0",
"child-process-promise": "^2.2.1",
"clipboard-copy": "^4.0.1",
Expand All @@ -170,7 +170,7 @@
"danger": "^10.6.1",
"danger-plugin-no-test-shortcuts": "^2.0.0",
"deepmerge": "^4.2.2",
"eslint": "^7.18.0",
"eslint": "^7.19.0",
"eslint-config-prettier": "^7.2.0",
"eslint-config-standard": "^16.0.2",
"eslint-config-standard-jsx": "^10.0.0",
Expand All @@ -182,13 +182,13 @@
"eslint-plugin-mocha": "^8.0.0",
"eslint-plugin-no-extension-in-require": "^0.2.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-promise": "^4.3.1",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^2.5.1",
"eslint-plugin-sort-class-members": "^1.9.0",
"fetch-ponyfill": "^7.1.0",
"form-data": "^3.0.0",
"gatsby": "2.31.1",
"gatsby": "2.32.3",
"gatsby-plugin-catch-links": "^2.3.10",
"gatsby-plugin-page-creator": "^2.10.0",
"gatsby-plugin-react-helmet": "^3.3.9",
Expand All @@ -211,7 +211,7 @@
"mocha-env-reporter": "^4.0.0",
"mocha-junit-reporter": "^2.0.0",
"mocha-yaml-loader": "^1.0.3",
"nock": "13.0.6",
"nock": "13.0.7",
"node-mocks-http": "^1.10.1",
"nodemon": "^2.0.7",
"npm-run-all": "^4.1.5",
Expand All @@ -221,11 +221,11 @@
"prettier": "2.2.1",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-error-overlay": "^6.0.8",
"react-error-overlay": "^6.0.9",
"react-helmet": "^6.1.0",
"react-modal": "^3.12.1",
"react-pose": "^4.0.10",
"react-select": "^4.0.2",
"react-select": "^4.1.0",
"read-all-stdin-sync": "^1.0.5",
"redis-server": "^1.2.2",
"require-hacker": "^3.0.1",
Expand Down
9 changes: 0 additions & 9 deletions services/dependabot/dependabot.service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict'

const url = require('url')
const Joi = require('joi')
const { BaseJsonService } = require('..')

Expand Down Expand Up @@ -46,19 +45,11 @@ module.exports = class DependabotSemverCompatibility extends BaseJsonService {
})
}

_getLink({ packageManager, dependencyName }) {
const qs = new url.URLSearchParams(
this._getQuery({ packageManager, dependencyName })
)
return `https://dependabot.com/compatibility-score.html?${qs.toString()}`
}

async handle({ packageManager, dependencyName }) {
const json = await this.fetch({ packageManager, dependencyName })
return {
color: json.colour,
message: json.status,
link: this._getLink({ packageManager, dependencyName }),
}
}
}
13 changes: 4 additions & 9 deletions services/dependabot/dependabot.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@
const { isIntegerPercentage } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())

t.create('semver stability (valid)')
.get('/bundler/puma.json')
.expectBadge({
label: 'semver stability',
message: isIntegerPercentage,
link: [
'https://dependabot.com/compatibility-score.html?package-manager=bundler&dependency-name=puma&version-scheme=semver',
],
})
t.create('semver stability (valid)').get('/bundler/puma.json').expectBadge({
label: 'semver stability',
message: isIntegerPercentage,
})

t.create('semver stability (invalid error)')
.get('/invalid-manager/puma.json')
Expand Down
25 changes: 5 additions & 20 deletions services/flathub/flathub.service.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict'

const Joi = require('joi')
const { InvalidResponse, NotFound } = require('..')
const { renderVersionBadge } = require('../version')
const { BaseJsonService } = require('..')

Expand All @@ -25,24 +24,10 @@ module.exports = class Flathub extends BaseJsonService {
static defaultBadgeData = { label: 'flathub' }

async handle({ packageName }) {
try {
const data = await this._requestJson({
schema,
url: `https://flathub.org/api/v1/apps/${encodeURIComponent(
packageName
)}`,
})
return renderVersionBadge({ version: data.currentReleaseVersion })
} catch (error) {
if (error instanceof InvalidResponse) {
// Note the 'not found' response from Flathub is:
// status code = 200,
// body = empty
throw new NotFound({
prettyMessage: `${packageName} not found`,
})
}
throw error
}
const data = await this._requestJson({
schema,
url: `https://flathub.org/api/v1/apps/${encodeURIComponent(packageName)}`,
})
return renderVersionBadge({ version: data.currentReleaseVersion })
}
}
2 changes: 1 addition & 1 deletion services/flathub/flathub.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ t.create('Flathub (valid)')

t.create('Flathub (not found)')
.get('/not.a.package.json')
.expectBadge({ label: 'flathub', message: 'not.a.package not found' })
.expectBadge({ label: 'flathub', message: 'not found' })
1 change: 0 additions & 1 deletion services/github/github-milestone-detail.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ module.exports = class GithubMilestoneDetail extends GithubAuthV3Service {
label: `${milestone.title} ${label}`,
message: metric(milestoneMetric),
color,
link: [`https://github.com/${user}/${repo}/milestone/${number}`],
}
}

Expand Down
5 changes: 0 additions & 5 deletions services/github/github-milestone-detail.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,34 @@ t.create('Milestone Open Issues')
.expectBadge({
label: 'openWithOneOpenIssue open issues',
message: isMetric,
link: [`https://github.com/MacroPower/milestone-test/milestone/1`],
})

t.create('Milestone Closed Issues')
.get('/issues-closed/MacroPower/milestone-test/3.json')
.expectBadge({
label: 'closedWithOneClosedIssue closed issues',
message: isMetric,
link: [`https://github.com/MacroPower/milestone-test/milestone/3`],
})

t.create('Milestone Total Issues')
.get('/issues-total/MacroPower/milestone-test/2.json')
.expectBadge({
label: 'openWithOneOpenOneClosedIssue issues',
message: isMetric,
link: [`https://github.com/MacroPower/milestone-test/milestone/2`],
})

t.create('Milestone Progress')
.get('/progress/MacroPower/milestone-test/2.json')
.expectBadge({
label: 'openWithOneOpenOneClosedIssue',
message: isMetricOverMetric,
link: [`https://github.com/MacroPower/milestone-test/milestone/2`],
})

t.create('Milestone Progress (Percent)')
.get('/progress-percent/MacroPower/milestone-test/2.json')
.expectBadge({
label: 'openWithOneOpenOneClosedIssue',
message: isIntegerPercentage,
link: [`https://github.com/MacroPower/milestone-test/milestone/2`],
})

t.create('Milestones (repo or milestone not found)')
Expand Down
1 change: 0 additions & 1 deletion services/github/github-milestone.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ module.exports = class GithubMilestone extends GithubAuthV3Service {
label: `${label} milestones`,
message: metric(milestoneLength),
color,
link: [`https://github.com/${user}/${repo}/milestones`],
}
}

Expand Down
3 changes: 0 additions & 3 deletions services/github/github-milestone.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,20 @@ t.create('All Milestones')
.expectBadge({
label: 'milestones',
message: isMetric,
link: [`https://github.com/MacroPower/milestone-test/milestones`],
})

t.create('Open Milestones')
.get('/open/MacroPower/milestone-test.json')
.expectBadge({
label: 'active milestones',
message: isMetric,
link: [`https://github.com/MacroPower/milestone-test/milestones`],
})

t.create('Closed Milestones')
.get('/closed/MacroPower/milestone-test.json')
.expectBadge({
label: 'completed milestones',
message: isMetric,
link: [`https://github.com/MacroPower/milestone-test/milestones`],
})

t.create('Milestones (repo not found)')
Expand Down
2 changes: 1 addition & 1 deletion services/pypi/pypi-django-versions.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Joi = require('joi')
const t = (module.exports = require('../tester').createServiceTester())

const isPipeSeparatedDjangoVersions = Joi.string().regex(
/^([0-9]+\.[0-9]+(?: \| )?)+$/
/^([1-9]\.[0-9]+(?: \| )?)+$/
)

t.create('supported django versions (valid, package version in request)')
Expand Down
2 changes: 1 addition & 1 deletion services/pypi/pypi-python-versions.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Joi = require('joi')
const t = (module.exports = require('../tester').createServiceTester())

const isPipeSeparatedPythonVersions = Joi.string().regex(
/^([0-9]+\.[0-9]+(?: \| )?)+$/
/^([1-9]\.[0-9]+(?: \| )?)+$/
)

t.create('python versions (valid, package version in request)')
Expand Down
61 changes: 61 additions & 0 deletions services/testspace/testspace-base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
'use strict'

const Joi = require('joi')
const { nonNegativeInteger } = require('../validators')
const { BaseJsonService, NotFound } = require('..')

// https://help.testspace.com/docs/reference/web-api#list-results
// case_counts|array|The contained cases [passed, failed, na, errored]|counters of result
// session_* fields are for manual runs
// There are instances where the api returns a 200 status code with an empty array
// notably in cases where a space id is used
const schema = Joi.array()
.items(
Joi.object({
case_counts: Joi.array()
.items(nonNegativeInteger)
.min(4)
.max(4)
.required(),
})
)
.required()

// https://help.testspace.com/docs/dashboard/overview-navigate
// Org is owner/account
// Project is generally a repository
// Space is a container, often a branch
module.exports = class TestspaceBase extends BaseJsonService {
static category = 'build'
static defaultBadgeData = { label: 'tests' }

async fetch({ org, project, space }) {
// https://help.testspace.com/docs/reference/web-api#list-results
const url = `https://${org}.testspace.com/api/projects/${encodeURIComponent(
project
)}/spaces/${space}/results`
return this._requestJson({
schema,
url,
errorMessages: {
403: 'org not found or not authorized',
404: 'org, project, or space not found',
},
})
}

transformCaseCounts(json) {
if (json.length === 0) {
throw new NotFound({ prettyMessage: 'space not found or results purged' })
}

const [
{
case_counts: [passed, failed, skipped, errored],
},
] = json
const total = passed + failed + skipped + errored

return { passed, failed, skipped, errored, total }
}
}
13 changes: 13 additions & 0 deletions services/testspace/testspace-base.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict'

const { expect } = require('chai')
const { NotFound } = require('..')
const TestspaceBase = require('./testspace-base')

describe('TestspaceBase', function () {
it('throws NotFound when response is missing space results', function () {
expect(() => TestspaceBase.prototype.transformCaseCounts([]))
.to.throw(NotFound)
.with.property('prettyMessage', 'space not found or results purged')
})
})
Loading

0 comments on commit 6def7af

Please sign in to comment.