-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract examples from new-style services #1582
Merged
paulmelnikow
merged 7 commits into
badges:master
from
paulmelnikow:base-service-examples
Mar 30, 2018
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bbe0129
Extract examples from new-style services
paulmelnikow 6574cc3
Clean lint
paulmelnikow 7922038
Add a test
paulmelnikow 3c85819
Merge branch 'master' into base-service-examples
paulmelnikow 59516f9
Avoid duplication in service loading + refactor
paulmelnikow 3187809
Merge branch 'master' into base-service-examples
paulmelnikow 15e1712
Avoid duplication in URLs, rename uri -> url in BaseService
paulmelnikow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,3 +89,4 @@ typings/ | |
# Temporary build artifacts. | ||
/build | ||
.next | ||
badge-examples.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
const { expect } = require('chai'); | ||
|
||
const allBadgeExamples = require('./all-badge-examples'); | ||
|
||
describe('The badge examples', function () { | ||
it('should include AppVeyor, which is added automatically', function () { | ||
const { examples } = allBadgeExamples.getCategory('build'); | ||
|
||
const appVeyorBuildExamples = examples.filter(ex => ex.title.includes('AppVeyor')) | ||
.filter(ex => ! ex.title.includes('tests')); | ||
|
||
expect(appVeyorBuildExamples).to.deep.equal([ | ||
{ | ||
title: 'AppVeyor', | ||
previewUri: '/appveyor/ci/gruntjs/grunt.svg', | ||
exampleUri: undefined, | ||
documentation: undefined, | ||
}, | ||
{ | ||
title: 'AppVeyor branch', | ||
previewUri: '/appveyor/ci/gruntjs/grunt/master.svg', | ||
exampleUri: undefined, | ||
documentation: undefined, | ||
}, | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
const allBadgeExamples = require('./all-badge-examples'); | ||
|
||
process.stdout.write(JSON.stringify(allBadgeExamples)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
const glob = require('glob'); | ||
|
||
// Match modules with the same name as their containing directory. | ||
// e.g. services/appveyor/appveyor.js | ||
const serviceRegex = /\/services\/(.*)\/\1\.js$/; | ||
|
||
function loadServiceClasses() { | ||
// New-style services | ||
return glob.sync(`${__dirname}/**/*.js`) | ||
.filter(path => serviceRegex.test(path)) | ||
.map(path => require(path)) | ||
} | ||
|
||
function loadTesters() { | ||
return glob.sync(`${__dirname}/**/*.tester.js`) | ||
.map(name => require(name)); | ||
} | ||
|
||
module.exports = { | ||
loadServiceClasses, | ||
loadTesters, | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think its worth having another test here which just iterates over all examples (rather than just the appveyor ones) and runs
prepareExample()
on each one. It doesn't have to assert anything other than an error wasn't thrown. That way we'll get a failure on the server tests if an invalid example (without apreviewUri
) is added in a PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that's a good idea, though I think this is already happening when this file is
require
d, on account of the call toloadExamples()
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one step ahead of me :)