Use configuration from repo file `.github/github-bot.yml`
This commit is contained in:
parent
38d8fce885
commit
499f20f723
|
@ -1,22 +1,13 @@
|
||||||
project-board:
|
|
||||||
name: 'Pipeline for QA'
|
|
||||||
contributor-column-name: 'CONTRIBUTOR'
|
|
||||||
review-column-name: 'REVIEW'
|
|
||||||
test-column-name: 'TO TEST'
|
|
||||||
|
|
||||||
bounty-project-board:
|
bounty-project-board:
|
||||||
name: 'Status SOB Swarm'
|
name: 'Status SOB Swarm'
|
||||||
awaiting-approval-label-name: 'bounty-awaiting-approval'
|
awaiting-approval-label-name: 'bounty-awaiting-approval'
|
||||||
bounty-label-name: 'bounty'
|
bounty-label-name: 'bounty'
|
||||||
awaiting-approval-column-name: 'bounty-awaiting-approval'
|
awaiting-approval-column-name: 'bounty-awaiting-approval'
|
||||||
|
owner: 'andytudhope'
|
||||||
|
|
||||||
welcome-bot:
|
welcome-bot:
|
||||||
message: 'Thanks for making your first PR here!'
|
message: 'Thanks for making your first PR here!'
|
||||||
|
|
||||||
automated-tests:
|
|
||||||
repo-full-name: 'status-im/status-react'
|
|
||||||
job-full-name: 'end-to-end-tests/status-app-end-to-end-tests'
|
|
||||||
|
|
||||||
slack:
|
slack:
|
||||||
notification:
|
notification:
|
||||||
room: 'status-probot'
|
room: 'status-probot'
|
||||||
|
|
|
@ -11,11 +11,12 @@
|
||||||
// Author:
|
// Author:
|
||||||
// PombeirP
|
// PombeirP
|
||||||
|
|
||||||
// const getConfig = require('probot-config')
|
const createScheduler = require('probot-scheduler')
|
||||||
|
const getConfig = require('probot-config')
|
||||||
|
const Slack = require('probot-slack-status')
|
||||||
|
|
||||||
const defaultConfig = require('../lib/config')
|
const defaultConfig = require('../lib/config')
|
||||||
const gitHubHelpers = require('../lib/github-helpers')
|
const gitHubHelpers = require('../lib/github-helpers')
|
||||||
const createScheduler = require('probot-scheduler')
|
|
||||||
const Slack = require('probot-slack-status')
|
|
||||||
const slackHelper = require('../lib/slack')
|
const slackHelper = require('../lib/slack')
|
||||||
|
|
||||||
let slackClient = null
|
let slackClient = null
|
||||||
|
@ -42,16 +43,15 @@ async function getProjectFromName (github, ownerName, repoName, projectBoardName
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkOpenPullRequests (robot, context) {
|
async function checkOpenPullRequests (robot, context) {
|
||||||
const github = context.github
|
const { github, payload } = context
|
||||||
const repo = context.payload.repository
|
const repo = payload.repository
|
||||||
const ownerName = repo.owner.login
|
const ownerName = repo.owner.login
|
||||||
const repoName = repo.name
|
const repoName = repo.name
|
||||||
|
const config = await getConfig(context, 'github-bot.yml', defaultConfig(robot, '.github/github-bot.yml'))
|
||||||
// const config = await getConfig(context, 'github-bot.yml', defaultConfig(robot, '.github/github-bot.yml'))
|
const projectBoardConfig = config ? config['project-board'] : null
|
||||||
const config = defaultConfig(robot, '.github/github-bot.yml')
|
|
||||||
const projectBoardConfig = config['project-board']
|
|
||||||
|
|
||||||
if (!projectBoardConfig) {
|
if (!projectBoardConfig) {
|
||||||
|
robot.log.debug(`Project board not configured in repo ${ownerName}/${repoName}, ignoring`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ async function checkOpenPullRequests (robot, context) {
|
||||||
)
|
)
|
||||||
|
|
||||||
// And make sure they are assigned to the correct project column
|
// And make sure they are assigned to the correct project column
|
||||||
for (var pullRequest of allPullRequests) {
|
for (const pullRequest of allPullRequests) {
|
||||||
try {
|
try {
|
||||||
await assignPullRequestToCorrectColumn(github, robot, repo, pullRequest, contributorColumn, reviewColumn, testColumn, config.slack.notification.room)
|
await assignPullRequestToCorrectColumn(github, robot, repo, pullRequest, contributorColumn, reviewColumn, testColumn, config.slack.notification.room)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -10,8 +10,9 @@
|
||||||
// Author:
|
// Author:
|
||||||
// PombeirP
|
// PombeirP
|
||||||
|
|
||||||
// const getConfig = require('probot-config')
|
|
||||||
const defaultConfig = require('../lib/config')
|
const defaultConfig = require('../lib/config')
|
||||||
|
|
||||||
|
const getConfig = require('probot-config')
|
||||||
const Slack = require('probot-slack-status')
|
const Slack = require('probot-slack-status')
|
||||||
|
|
||||||
let slackClient = null
|
let slackClient = null
|
||||||
|
@ -34,13 +35,12 @@ module.exports = (robot) => {
|
||||||
|
|
||||||
async function assignPullRequestToReview (context, robot) {
|
async function assignPullRequestToReview (context, robot) {
|
||||||
const { github, payload } = context
|
const { github, payload } = context
|
||||||
// const config = await getConfig(context, 'github-bot.yml', defaultConfig(robot, '.github/github-bot.yml'))
|
const config = await getConfig(context, 'github-bot.yml', defaultConfig(robot, '.github/github-bot.yml'))
|
||||||
const config = defaultConfig(robot, '.github/github-bot.yml')
|
|
||||||
const ownerName = payload.repository.owner.login
|
const ownerName = payload.repository.owner.login
|
||||||
const repoName = payload.repository.name
|
const repoName = payload.repository.name
|
||||||
const prNumber = payload.pull_request.number
|
const prNumber = payload.pull_request.number
|
||||||
|
|
||||||
const projectBoardConfig = config['project-board']
|
const projectBoardConfig = config ? config['project-board'] : null
|
||||||
if (!projectBoardConfig) {
|
if (!projectBoardConfig) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,11 @@
|
||||||
// Author:
|
// Author:
|
||||||
// PombeirP
|
// PombeirP
|
||||||
|
|
||||||
// const getConfig = require('probot-config')
|
|
||||||
const slackHelper = require('../lib/slack')
|
const slackHelper = require('../lib/slack')
|
||||||
const gitHubHelpers = require('../lib/github-helpers')
|
const gitHubHelpers = require('../lib/github-helpers')
|
||||||
const defaultConfig = require('../lib/config')
|
const defaultConfig = require('../lib/config')
|
||||||
|
|
||||||
|
const getConfig = require('probot-config')
|
||||||
const Slack = require('probot-slack-status')
|
const Slack = require('probot-slack-status')
|
||||||
|
|
||||||
let slackClient = null
|
let slackClient = null
|
||||||
|
@ -45,9 +46,8 @@ async function assignIssueToBountyAwaitingForApproval (context, robot, assign) {
|
||||||
const { github, payload } = context
|
const { github, payload } = context
|
||||||
const ownerName = payload.repository.owner.login
|
const ownerName = payload.repository.owner.login
|
||||||
const repoName = payload.repository.name
|
const repoName = payload.repository.name
|
||||||
// const config = await getConfig(context, 'github-bot.yml', defaultConfig(robot, '.github/github-bot.yml'))
|
const config = await getConfig(context, 'github-bot.yml', defaultConfig(robot, '.github/github-bot.yml'))
|
||||||
const config = defaultConfig(robot, '.github/github-bot.yml')
|
const projectBoardConfig = config ? config['bounty-project-board'] : null
|
||||||
const projectBoardConfig = config['bounty-project-board']
|
|
||||||
|
|
||||||
if (!projectBoardConfig) {
|
if (!projectBoardConfig) {
|
||||||
return
|
return
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
// Max Tyrrell (ImFeelingDucky/mac/yung_mac)
|
// Max Tyrrell (ImFeelingDucky/mac/yung_mac)
|
||||||
|
|
||||||
const Slack = require('probot-slack-status')
|
const Slack = require('probot-slack-status')
|
||||||
|
const getConfig = require('probot-config')
|
||||||
|
|
||||||
const defaultConfig = require('../lib/config')
|
const defaultConfig = require('../lib/config')
|
||||||
const slackHelper = require('../lib/slack')
|
const slackHelper = require('../lib/slack')
|
||||||
|
|
||||||
|
@ -37,14 +39,14 @@ async function notifyCollaborators (context, robot, slackClient, getSlackMention
|
||||||
const { github, payload } = context
|
const { github, payload } = context
|
||||||
const ownerName = payload.repository.owner.login
|
const ownerName = payload.repository.owner.login
|
||||||
const repoName = payload.repository.name
|
const repoName = payload.repository.name
|
||||||
const config = defaultConfig(robot, '.github/github-bot.yml')
|
const config = await getConfig(context, 'github-bot.yml', defaultConfig(robot, '.github/github-bot.yml'))
|
||||||
const projectBoardConfig = config['bounty-project-board']
|
const bountyProjectBoardConfig = config['bounty-project-board']
|
||||||
|
|
||||||
if (!projectBoardConfig) {
|
if (!bountyProjectBoardConfig) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const watchedLabelName = projectBoardConfig['awaiting-approval-label-name']
|
const watchedLabelName = bountyProjectBoardConfig['awaiting-approval-label-name']
|
||||||
if (payload.label.name !== watchedLabelName) {
|
if (payload.label.name !== watchedLabelName) {
|
||||||
robot.log.debug(`bountyAwaitingApprovalSlackPing - ${payload.label.name} doesn't match watched ${watchedLabelName} label. Ignoring`)
|
robot.log.debug(`bountyAwaitingApprovalSlackPing - ${payload.label.name} doesn't match watched ${watchedLabelName} label. Ignoring`)
|
||||||
return null
|
return null
|
||||||
|
|
|
@ -10,10 +10,11 @@
|
||||||
// Author:
|
// Author:
|
||||||
// PombeirP
|
// PombeirP
|
||||||
|
|
||||||
// const getConfig = require('probot-config')
|
const getConfig = require('probot-config')
|
||||||
const defaultConfig = require('../lib/config')
|
|
||||||
const Slack = require('probot-slack-status')
|
const Slack = require('probot-slack-status')
|
||||||
|
|
||||||
|
const defaultConfig = require('../lib/config')
|
||||||
|
|
||||||
let slackClient = null
|
let slackClient = null
|
||||||
|
|
||||||
module.exports = (robot) => {
|
module.exports = (robot) => {
|
||||||
|
@ -34,13 +35,12 @@ module.exports = (robot) => {
|
||||||
|
|
||||||
async function greetNewContributor (context, robot) {
|
async function greetNewContributor (context, robot) {
|
||||||
const { github, payload } = context
|
const { github, payload } = context
|
||||||
// const config = await getConfig(context, 'github-bot.yml', defaultConfig(robot, '.github/github-bot.yml'))
|
const config = await getConfig(context, 'github-bot.yml', defaultConfig(robot, '.github/github-bot.yml'))
|
||||||
const config = defaultConfig(robot, '.github/github-bot.yml')
|
|
||||||
const ownerName = payload.repository.owner.login
|
const ownerName = payload.repository.owner.login
|
||||||
const repoName = payload.repository.name
|
const repoName = payload.repository.name
|
||||||
const prNumber = payload.pull_request.number
|
const prNumber = payload.pull_request.number
|
||||||
|
|
||||||
const welcomeBotConfig = config['welcome-bot']
|
const welcomeBotConfig = config ? config['welcome-bot'] : null
|
||||||
if (!welcomeBotConfig) {
|
if (!welcomeBotConfig) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,35 +10,38 @@
|
||||||
// Author:
|
// Author:
|
||||||
// PombeirP
|
// PombeirP
|
||||||
|
|
||||||
const defaultConfig = require('../lib/config')
|
const getConfig = require('probot-config')
|
||||||
const gitHubHelpers = require('../lib/github-helpers')
|
|
||||||
const jenkins = require('jenkins')({ baseUrl: process.env.JENKINS_URL, crumbIssuer: true, promisify: true })
|
const jenkins = require('jenkins')({ baseUrl: process.env.JENKINS_URL, crumbIssuer: true, promisify: true })
|
||||||
const HashMap = require('hashmap')
|
const HashMap = require('hashmap')
|
||||||
|
|
||||||
|
const defaultConfig = require('../lib/config')
|
||||||
|
const gitHubHelpers = require('../lib/github-helpers')
|
||||||
|
|
||||||
const pendingPullRequests = new HashMap()
|
const pendingPullRequests = new HashMap()
|
||||||
|
|
||||||
module.exports = (robot) => {
|
module.exports = (robot) => {
|
||||||
const config = defaultConfig(robot, '.github/github-bot.yml')
|
|
||||||
const projectBoardConfig = config['project-board']
|
|
||||||
const automatedTestsConfig = config['automated-tests']
|
|
||||||
|
|
||||||
if (!process.env.JENKINS_URL) {
|
if (!process.env.JENKINS_URL) {
|
||||||
robot.log.info('trigger-automation-test-build - Jenkins is not configured, not loading script')
|
robot.log.info('trigger-automation-test-build - Jenkins is not configured, not loading script')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (projectBoardConfig && automatedTestsConfig) {
|
setInterval(checkPendingPullRequests, 5 * 1000 * 60, robot)
|
||||||
setInterval(checkPendingPullRequests, 5 * 1000 * 60, robot)
|
registerForRelevantCardEvents(robot)
|
||||||
registerForRelevantCardEvents(robot, { projectBoardConfig: projectBoardConfig, automatedTestingConfig: automatedTestsConfig })
|
}
|
||||||
|
|
||||||
|
function registerForRelevantCardEvents (robot) {
|
||||||
|
robot.on('project_card.created', context => processChangedProjectCard(robot, context))
|
||||||
|
robot.on('project_card.moved', context => processChangedProjectCard(robot, context))
|
||||||
|
}
|
||||||
|
|
||||||
|
async function processChangedProjectCard (robot, context) {
|
||||||
|
const config = await getConfig(context, 'github-bot.yml', defaultConfig(robot, '.github/github-bot.yml'))
|
||||||
|
const projectBoardConfig = config ? config['project-board'] : null
|
||||||
|
const automatedTestsConfig = config ? config['automated-tests'] : null
|
||||||
|
if (!projectBoardConfig || !automatedTestsConfig) {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function registerForRelevantCardEvents (robot, config) {
|
|
||||||
robot.on('project_card.created', context => processChangedProjectCard(robot, context, config))
|
|
||||||
robot.on('project_card.moved', context => processChangedProjectCard(robot, context, config))
|
|
||||||
}
|
|
||||||
|
|
||||||
async function processChangedProjectCard (robot, context, config) {
|
|
||||||
const { github, payload } = context
|
const { github, payload } = context
|
||||||
|
|
||||||
if (payload.project_card.note) {
|
if (payload.project_card.note) {
|
||||||
|
@ -46,13 +49,12 @@ async function processChangedProjectCard (robot, context, config) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const { projectBoardConfig, automatedTestingConfig } = config
|
|
||||||
const projectBoardName = projectBoardConfig['name']
|
const projectBoardName = projectBoardConfig['name']
|
||||||
const testColumnName = projectBoardConfig['test-column-name']
|
const testColumnName = projectBoardConfig['test-column-name']
|
||||||
const repo = payload.repository
|
const repo = payload.repository
|
||||||
|
|
||||||
if (repo.full_name !== automatedTestingConfig['repo-full-name']) {
|
if (repo.full_name !== automatedTestsConfig['repo-full-name']) {
|
||||||
robot.log.trace(`trigger-automation-test-build - Pull request project doesn't match watched repo, exiting`, repo.full_name, automatedTestingConfig['repo-full-name'])
|
robot.log.trace(`trigger-automation-test-build - Pull request project doesn't match watched repo, exiting`, repo.full_name, automatedTestsConfig['repo-full-name'])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +93,7 @@ async function processChangedProjectCard (robot, context, config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const prNumber = last(payload.project_card.content_url.split('/'), -1)
|
const prNumber = last(payload.project_card.content_url.split('/'), -1)
|
||||||
const fullJobName = automatedTestingConfig['job-full-name']
|
const fullJobName = automatedTestsConfig['job-full-name']
|
||||||
|
|
||||||
await processPullRequest(github, robot, repo.owner.login, repo.name, prNumber, fullJobName)
|
await processPullRequest(github, robot, repo.owner.login, repo.name, prNumber, fullJobName)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue