-
Notifications
You must be signed in to change notification settings - Fork 33
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
CR: check CR with specberus and check approvals with GH API #575
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3b08783
CR: check CR with specberus and check approvals with GH API
deniak 4653d0e
GH token in parameter
deniak 8afb76a
check if the document was already published before looking for the ap…
deniak b9c2221
fix jscs errors
deniak c232daa
remove unused vars
deniak 770fd83
support editorial parameter + send that parameter to the backend when…
deniak dd33182
fixing styling issue
deniak 945a6a8
provide more information in case there's an error
deniak 71e3482
send implementation report and due date to the backend
deniak fb5a7c4
missing parenthesis
deniak 89cc24a
sort issues by last updated
deniak e25caaf
fix missing metadata + bug on the use of immutable lists
deniak bfb1d46
transition repo: case insensitive check + close GH issue if approvals…
deniak bd7ec5f
CS
deniak 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
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,90 @@ | ||
'use strict'; | ||
|
||
var List = require('immutable').List; | ||
var Octokat = require('octokat'); | ||
|
||
/** | ||
* @exports lib/transition-checker | ||
*/ | ||
|
||
var TransitionChecker = {}; | ||
|
||
/** | ||
* @returns {Promise.<List.<String>>} | ||
*/ | ||
|
||
TransitionChecker.check = function (profile, latestVersion, previousVersion, isEditorial, isUpdate) { | ||
return new Promise(function (resolve, reject) { | ||
var errors = new List(); | ||
|
||
if (profile === 'WD' || profile === 'WG-NOTE' || isUpdate) { | ||
resolve({ errors: errors, requiresCfE: false }); | ||
} | ||
else if (profile === 'CR') { | ||
if (previousVersion.includes('/WD-') || (previousVersion.includes('/CR-') && !isEditorial)) { | ||
var octo = new Octokat({ | ||
token: global.GH_TOKEN | ||
}); | ||
var repo = octo.repos('w3c', 'transitions'); | ||
|
||
var shortname = latestVersion.match(new RegExp(/.*\/([^/]+)\/$/))[1]; | ||
var directorApproval = 'transition approved.'; | ||
var commApproval = 'draft transition approved.'; | ||
var directorApprovalFound = false; | ||
var commApprovalFound = false; | ||
|
||
repo.issues.fetch( | ||
{ | ||
labels: 'Awaiting publication', | ||
state: 'open', | ||
sort: 'updated', | ||
per_page: 100 // TODO: get all the issues, not just the first 100 | ||
}) | ||
.then((content) => { | ||
for (var issue of content.items) { | ||
if (issue.title.endsWith(' ' + shortname)) { | ||
repo.issues(issue.number).comments.fetch() | ||
.then((comments) => { | ||
for (var comment of comments.items) { | ||
if (comment.body.toLowerCase().startsWith(directorApproval)) { | ||
// Director's approval | ||
octo.teams(global.GH_DIRECTOR_TEAM_ID).members(comment.user.login).fetch((err) => { | ||
if (!err) directorApprovalFound = true; | ||
}); | ||
} | ||
else if (comment.body.toLowerCase().startsWith(commApproval)) { | ||
// Comm's approval | ||
octo.teams(global.GH_COMM_TEAM_ID).members(comment.user.login).fetch((err) => { | ||
if (!err) commApprovalFound = true; | ||
}); | ||
} | ||
} | ||
if (!directorApprovalFound) errors = errors.push('Director\'s approval not found.'); | ||
if (!commApprovalFound) errors = errors.push('Communication team\'s approval not found.'); | ||
if (directorApprovalFound && commApprovalFound) { | ||
// Close issue | ||
repo.issues(issue.number).update({ state: 'closed' }); | ||
} | ||
return resolve({ errors: errors, requiresCfE: true }); | ||
}); | ||
} | ||
else { | ||
// Issue not found | ||
return reject(new Error('Issue not found on the github repository w3c/transitions.')); | ||
} | ||
} | ||
}) | ||
.catch(function (error) { | ||
return reject(new Error('An error occured while looking for the transition issue: ' + error)); | ||
}); | ||
} | ||
else if (previousVersion.includes('/CR-') && isEditorial) { | ||
return resolve({ errors: errors, requiresCfE: false }); | ||
} | ||
} | ||
else | ||
reject(new Error('Only WD, CR and Notes are allowed!')); | ||
}); | ||
}; | ||
|
||
module.exports = TransitionChecker; |
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
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.
About this regex: are we sure that all latest version URLs end with a slash?
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.
Yes, that's a requirement from pubrules these days.