Skip to content

Commit

Permalink
Merge branch 'master' into text-to-label-message
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmelnikow authored Oct 16, 2020
2 parents 356a9a4 + e1bd160 commit 064c198
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 150 deletions.
33 changes: 3 additions & 30 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,33 +86,6 @@ services_steps: &services_steps
- store_test_results:
path: junit

run_package_tests: &run_package_tests
when: always
command: |
# https://discuss.circleci.com/t/switch-nodejs-version-on-machine-executor-solved/26675/3
set +e
export NVM_DIR="/opt/circleci/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install $NODE_VERSION
nvm use $NODE_VERSION
node --version
# install the shields.io dependencies
npm ci
# run the package tests
npm run test:package
npm run check-types:package
# delete the sheilds.io dependencies
rm -rf node_modules/
# run a smoke test (render a badge with the CLI)
# with only the package dependencies installed
cd badge-maker
npm link
badge cactus grown :green @flat
package_steps: &package_steps
steps:
- checkout
Expand All @@ -132,31 +105,31 @@ package_steps: &package_steps
# https://nodejs.org/en/about/releases/

- run:
<<: *run_package_tests
environment:
mocha_reporter: mocha-junit-reporter
MOCHA_FILE: junit/badge-maker/v10/results.xml
NODE_VERSION: v10
CYPRESS_INSTALL_BINARY: 0
name: Run package tests on Node 10
command: scripts/run_package_tests.sh

- run:
<<: *run_package_tests
environment:
mocha_reporter: mocha-junit-reporter
MOCHA_FILE: junit/badge-maker/v12/results.xml
NODE_VERSION: v12
CYPRESS_INSTALL_BINARY: 0
name: Run package tests on Node 12
command: scripts/run_package_tests.sh

- run:
<<: *run_package_tests
environment:
mocha_reporter: mocha-junit-reporter
MOCHA_FILE: junit/badge-maker/v14/results.xml
NODE_VERSION: v14
CYPRESS_INSTALL_BINARY: 0
name: Run package tests on Node 14
command: scripts/run_package_tests.sh

- store_test_results:
path: junit
Expand Down
35 changes: 35 additions & 0 deletions scripts/run_package_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# https://discuss.circleci.com/t/switch-nodejs-version-on-machine-executor-solved/26675/3

# Start off less strict to work around various nvm errors.
set -e
export NVM_DIR="/opt/circleci/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"
nvm install $NODE_VERSION
nvm use $NODE_VERSION

# Stricter.
set -euo pipefail
node --version

# Install the shields.io dependencies.
if [[ "$NODE_VERSION" == "v10" ]]; then
# Avoid a depcheck error.
npm ci --ignore-scripts
else
npm ci
fi

# Run the package tests.
npm run test:package
npm run check-types:package

# Delete the shields.io dependencies.
rm -rf node_modules/

# Run a smoke test (render a badge with the CLI) with only the package
# dependencies installed.
cd badge-maker
npm link
badge cactus grown :green @flat
5 changes: 1 addition & 4 deletions services/issuestats/issuestats.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ const { deprecatedService } = require('..')

module.exports = deprecatedService({
category: 'issue-tracking',
route: {
base: 'issuestats',
format: '(?:.*?)',
},
route: { base: 'issuestats', pattern: ':various+' },
label: 'issue stats',
dateAdded: new Date('2018-09-01'),
})
72 changes: 26 additions & 46 deletions services/wordpress/wordpress-downloads.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,34 +48,24 @@ function DownloadsForExtensionType(extensionType) {
const { capt, exampleSlug } = extensionData[extensionType]

return class WordpressDownloads extends BaseWordpress {
static get name() {
return `Wordpress${capt}Downloads`
}
static name = `Wordpress${capt}Downloads`

static get category() {
return 'downloads'
}
static category = 'downloads'

static get route() {
return {
base: `wordpress/${extensionType}`,
pattern: ':interval(dd|dw|dm|dy|dt)/:slug',
}
static route = {
base: `wordpress/${extensionType}`,
pattern: ':interval(dd|dw|dm|dy|dt)/:slug',
}

static get examples() {
return [
{
title: `WordPress ${capt} Downloads`,
namedParams: { interval: 'dm', slug: exampleSlug },
staticPreview: this.render({ interval: 'dm', downloads: 200000 }),
},
]
}
static examples = [
{
title: `WordPress ${capt} Downloads`,
namedParams: { interval: 'dm', slug: exampleSlug },
staticPreview: this.render({ interval: 'dm', downloads: 200000 }),
},
]

static get defaultBadgeData() {
return { label: 'downloads' }
}
static defaultBadgeData = { label: 'downloads' }

static render({ interval, downloads }) {
const { messageSuffix } = intervalMap[interval]
Expand Down Expand Up @@ -129,34 +119,24 @@ function InstallsForExtensionType(extensionType) {
const { capt, exampleSlug } = extensionData[extensionType]

return class WordpressInstalls extends BaseWordpress {
static get name() {
return `Wordpress${capt}Installs`
}
static name = `Wordpress${capt}Installs`

static get category() {
return 'downloads'
}
static category = 'downloads'

static get route() {
return {
base: `wordpress/${extensionType}/installs`,
pattern: ':slug',
}
static route = {
base: `wordpress/${extensionType}/installs`,
pattern: ':slug',
}

static get examples() {
return [
{
title: `WordPress ${capt} Active Installs`,
namedParams: { slug: exampleSlug },
staticPreview: this.render({ installCount: 300000 }),
},
]
}
static examples = [
{
title: `WordPress ${capt} Active Installs`,
namedParams: { slug: exampleSlug },
staticPreview: this.render({ installCount: 300000 }),
},
]

static get defaultBadgeData() {
return { label: 'active installs' }
}
static defaultBadgeData = { label: 'active installs' }

static render({ installCount }) {
return {
Expand Down
78 changes: 31 additions & 47 deletions services/wordpress/wordpress-rating.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,32 @@ const extensionData = {
}

class WordpressRatingBase extends BaseWordpress {
static get category() {
return 'rating'
}
static category = 'rating'

static get defaultBadgeData() {
return { label: 'rating' }
}
static defaultBadgeData = { label: 'rating' }
}

function RatingForExtensionType(extensionType) {
const { capt, exampleSlug } = extensionData[extensionType]

return class WordpressRating extends WordpressRatingBase {
static get name() {
return `Wordpress${capt}Rating`
}
static name = `Wordpress${capt}Rating`

static get route() {
return {
base: `wordpress/${extensionType}/rating`,
pattern: ':slug',
}
static route = {
base: `wordpress/${extensionType}/rating`,
pattern: ':slug',
}

static get examples() {
return [
{
title: `WordPress ${capt} Rating`,
namedParams: { slug: exampleSlug },
staticPreview: this.render({
rating: 80,
numRatings: 100,
}),
},
]
}
static examples = [
{
title: `WordPress ${capt} Rating`,
namedParams: { slug: exampleSlug },
staticPreview: this.render({
rating: 80,
numRatings: 100,
}),
},
]

static render({ rating, numRatings }) {
const scaledAndRounded = ((rating / 100) * 5).toFixed(1)
Expand All @@ -75,30 +65,24 @@ function StarsForExtensionType(extensionType) {
const { capt, exampleSlug } = extensionData[extensionType]

return class WordpressStars extends WordpressRatingBase {
static get name() {
return `Wordpress${capt}Stars`
}
static name = `Wordpress${capt}Stars`

static get route() {
return {
base: `wordpress/${extensionType}`,
pattern: '(stars|r)/:slug',
}
static route = {
base: `wordpress/${extensionType}`,
pattern: '(stars|r)/:slug',
}

static get examples() {
return [
{
title: `WordPress ${capt} Rating`,
pattern: 'stars/:slug',
namedParams: { slug: exampleSlug },
staticPreview: this.render({
rating: 80,
}),
documentation: 'There is an alias <code>/r/:slug.svg</code> as well.',
},
]
}
static examples = [
{
title: `WordPress ${capt} Rating`,
pattern: 'stars/:slug',
namedParams: { slug: exampleSlug },
staticPreview: this.render({
rating: 80,
}),
documentation: 'There is an alias <code>/r/:slug.svg</code> as well.',
},
]

static render({ rating }) {
const scaled = (rating / 100) * 5
Expand Down
36 changes: 13 additions & 23 deletions services/wordpress/wordpress-version.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,24 @@ function VersionForExtensionType(extensionType) {
}[extensionType]

return class WordpressVersion extends BaseWordpress {
static get name() {
return `Wordpress${capt}Version`
}
static name = `Wordpress${capt}Version`

static get category() {
return 'version'
}
static category = 'version'

static get route() {
return {
base: `wordpress/${extensionType}/v`,
pattern: ':slug',
}
static route = {
base: `wordpress/${extensionType}/v`,
pattern: ':slug',
}

static get examples() {
return [
{
title: `WordPress ${capt} Version`,
namedParams: { slug: exampleSlug },
staticPreview: this.render({ version: 2.5 }),
},
]
}
static examples = [
{
title: `WordPress ${capt} Version`,
namedParams: { slug: exampleSlug },
staticPreview: this.render({ version: 2.5 }),
},
]

static get defaultBadgeData() {
return { label: extensionType }
}
static defaultBadgeData = { label: extensionType }

static render({ version }) {
return {
Expand Down

0 comments on commit 064c198

Please sign in to comment.