Compare commits
1 Commits
ec6edf598c
...
3754638793
| Author | SHA1 | Date | |
|---|---|---|---|
| 3754638793 |
@@ -16,7 +16,16 @@ export default async function() {
|
|||||||
const comments = (await getComments(repo, {
|
const comments = (await getComments(repo, {
|
||||||
body: /build failed/i,
|
body: /build failed/i,
|
||||||
actor: 'elasticmachine',
|
actor: 'elasticmachine',
|
||||||
})).filter(comment => !history.get(comment.id));
|
})).filter(comment => true /*!history.get(comment.id)*/);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
comments
|
||||||
|
.map(comment => {
|
||||||
|
history.add(comment); // temp
|
||||||
|
return comment.number;
|
||||||
|
})
|
||||||
|
.join(',')
|
||||||
|
);
|
||||||
|
|
||||||
// read pull data, filter out any closed pulls
|
// read pull data, filter out any closed pulls
|
||||||
const pulls = (await Promise.all(
|
const pulls = (await Promise.all(
|
||||||
@@ -27,25 +36,37 @@ export default async function() {
|
|||||||
})
|
})
|
||||||
)).filter(Boolean);
|
)).filter(Boolean);
|
||||||
|
|
||||||
const records = (await Promise.all(
|
const commits = await Promise.all(pulls.map(pull => getCommits(repo, pull.number, true)));
|
||||||
pulls.map(async ({ pull, comment }) => {
|
|
||||||
const commit = await getCommits(repo, pull.number, true);
|
|
||||||
const buildStatus = await getCommitStatus(repo, commit.sha);
|
|
||||||
// do nothing if the build has not started, or is pending or successful
|
|
||||||
if (!buildStatus || buildStatus.state === 'pending' || buildStatus.state === 'success')
|
|
||||||
return false;
|
|
||||||
return { comment, pull, commit, buildStatus };
|
|
||||||
})
|
|
||||||
)).filter(Boolean);
|
|
||||||
|
|
||||||
console.log(records);
|
const buildStatus = await getCommitStatus(repo, commits[1].sha);
|
||||||
|
|
||||||
|
console.log(buildStatus);
|
||||||
process.exit();
|
process.exit();
|
||||||
|
|
||||||
|
Promise.resolve()
|
||||||
|
|
||||||
|
.then(commit =>
|
||||||
|
// get the status of the commit
|
||||||
|
repo.commits(commit.sha).statuses.fetch()
|
||||||
|
)
|
||||||
|
.then(statuses => {
|
||||||
|
if (statuses.lastPage) return statuses.lastPage.fetch();
|
||||||
|
return statuses;
|
||||||
|
})
|
||||||
|
.then(({ items }) => {
|
||||||
|
const buildStatus = items.find(item => item.context === 'kibana-ci');
|
||||||
|
// status will be one of: error, failure, pending, success
|
||||||
|
// we should skip the retest if the state is pending or success
|
||||||
|
console.log(`PR state: ${buildStatus.state}`);
|
||||||
|
return buildStatus;
|
||||||
|
})
|
||||||
|
.catch(err => console.error(err));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
TODO:
|
TODO:
|
||||||
|
|
||||||
- [x] keep track of seen comment ids, only process new ones
|
- [ ] keep track of seen comment ids, only process new ones
|
||||||
- [x] check the pr's status and only retest if no longer "Pending"
|
- [x] check the pr's status and only retest if no longer "Pending"
|
||||||
- [ ] add a retest comment
|
- [ ] add a retest comment
|
||||||
- POST /repos/:owner/:repo/issues/:number/comments
|
- POST /repos/:owner/:repo/issues/:number/comments
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export default async function getEvents(repo, { body, actor } = {}) {
|
export default async function getEvents(repo, { body, actor } = {}) {
|
||||||
|
return cache;
|
||||||
const { items: events } = await repo.events.fetch();
|
const { items: events } = await repo.events.fetch();
|
||||||
|
|
||||||
return events
|
return events
|
||||||
@@ -21,3 +22,67 @@ export default async function getEvents(repo, { body, actor } = {}) {
|
|||||||
})
|
})
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cache = [ { id: '8438445273',
|
||||||
|
number: 23819,
|
||||||
|
owner: 'mattapperson',
|
||||||
|
labels: [ ':Beats', 'beats-cm' ],
|
||||||
|
comment_id: 430790622,
|
||||||
|
comment_author: 'elasticmachine',
|
||||||
|
comment_body: '## :broken_heart: Build Failed\n* [continuous-integration/kibana-ci/pull-request](https://kibana-ci.elastic.co/job/elastic-kibana-pull-request/5174/)\n\n' },
|
||||||
|
{ id: '8438364880',
|
||||||
|
number: 24158,
|
||||||
|
owner: 'joshdover',
|
||||||
|
labels: [],
|
||||||
|
comment_id: 430786140,
|
||||||
|
comment_author: 'elasticmachine',
|
||||||
|
comment_body: '## :broken_heart: Build Failed\n* [continuous-integration/kibana-ci/pull-request](https://kibana-ci.elastic.co/job/elastic-kibana-pull-request/5153/)\n\n' },
|
||||||
|
{ id: '8438241644',
|
||||||
|
number: 24104,
|
||||||
|
owner: 'graphaelli',
|
||||||
|
labels: [],
|
||||||
|
comment_id: 430777985,
|
||||||
|
comment_author: 'elasticmachine',
|
||||||
|
comment_body: '## :broken_heart: Build Failed\n* [continuous-integration/kibana-ci/pull-request](https://kibana-ci.elastic.co/job/elastic-kibana-pull-request/5150/)\n\n' },
|
||||||
|
{ id: '8438206753',
|
||||||
|
number: 24158,
|
||||||
|
owner: 'joshdover',
|
||||||
|
labels: [],
|
||||||
|
comment_id: 430775791,
|
||||||
|
comment_author: 'elasticmachine',
|
||||||
|
comment_body: '## :broken_heart: Build Failed\n* [continuous-integration/kibana-ci/pull-request](https://kibana-ci.elastic.co/job/elastic-kibana-pull-request/5147/)\n\n' },
|
||||||
|
{ id: '8438199856',
|
||||||
|
number: 23819,
|
||||||
|
owner: 'mattapperson',
|
||||||
|
labels: [ ':Beats', 'beats-cm' ],
|
||||||
|
comment_id: 430775402,
|
||||||
|
comment_author: 'elasticmachine',
|
||||||
|
comment_body: '## :broken_heart: Build Failed\n* [continuous-integration/kibana-ci/pull-request](https://kibana-ci.elastic.co/job/elastic-kibana-pull-request/5165/)\n\n' },
|
||||||
|
{ id: '8438188563',
|
||||||
|
number: 23648,
|
||||||
|
owner: 'jbudz',
|
||||||
|
labels: [ ':Operations' ],
|
||||||
|
comment_id: 430774756,
|
||||||
|
comment_author: 'elasticmachine',
|
||||||
|
comment_body: '## :broken_heart: Build Failed\n* [continuous-integration/kibana-ci/pull-request](https://kibana-ci.elastic.co/job/elastic-kibana-pull-request/5144/)\n\n' },
|
||||||
|
{ id: '8438183173',
|
||||||
|
number: 24038,
|
||||||
|
owner: 'cqliu1',
|
||||||
|
labels: [ ':Canvas', ':Home', 'review', 'v6.5.0', 'v7.0.0' ],
|
||||||
|
comment_id: 430774424,
|
||||||
|
comment_author: 'elasticmachine',
|
||||||
|
comment_body: '## :broken_heart: Build Failed\n* [continuous-integration/kibana-ci/pull-request](https://kibana-ci.elastic.co/job/elastic-kibana-pull-request/5145/)\n\n' },
|
||||||
|
{ id: '8438163617',
|
||||||
|
number: 24100,
|
||||||
|
owner: 'jakelandis',
|
||||||
|
labels: [ 'v6.5.0', 'v7.0.0' ],
|
||||||
|
comment_id: 430773251,
|
||||||
|
comment_author: 'elasticmachine',
|
||||||
|
comment_body: '## :broken_heart: Build Failed\n* [continuous-integration/kibana-ci/pull-request](https://kibana-ci.elastic.co/job/elastic-kibana-pull-request/5142/)\n\n' },
|
||||||
|
{ id: '8438139342',
|
||||||
|
number: 24153,
|
||||||
|
owner: 'cchaos',
|
||||||
|
labels: [ 'backport' ],
|
||||||
|
comment_id: 430771841,
|
||||||
|
comment_author: 'elasticmachine',
|
||||||
|
comment_body: '## :broken_heart: Build Failed\n* [continuous-integration/kibana-ci/pull-request](https://kibana-ci.elastic.co/job/elastic-kibana-pull-request/5143/)\n\n' } ];
|
||||||
@@ -9,6 +9,7 @@ function getBuildStatus({ items: statuses }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default async function getCommitStatus(repo, sha) {
|
export default async function getCommitStatus(repo, sha) {
|
||||||
|
return cache
|
||||||
const statuses = await repo.commits(sha).statuses.fetch();
|
const statuses = await repo.commits(sha).statuses.fetch();
|
||||||
|
|
||||||
const buildStatus = await (async stats => {
|
const buildStatus = await (async stats => {
|
||||||
@@ -20,3 +21,7 @@ export default async function getCommitStatus(repo, sha) {
|
|||||||
|
|
||||||
return buildStatus;
|
return buildStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cache = { id: 5666338700,
|
||||||
|
url: 'https://api.github.com/repos/elastic/kibana/statuses/5f948924cc4fe34c7b9399e685927e93a18d7450',
|
||||||
|
state: 'pending' };
|
||||||
@@ -3,7 +3,7 @@ function formatCommit(commit) {
|
|||||||
sha: commit.sha,
|
sha: commit.sha,
|
||||||
owner: commit.committer.login,
|
owner: commit.committer.login,
|
||||||
message: commit.commit.message,
|
message: commit.commit.message,
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatCommits(commits, lastOnly) {
|
function formatCommits(commits, lastOnly) {
|
||||||
@@ -12,6 +12,7 @@ function formatCommits(commits, lastOnly) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default async function getCommits(repo, id, lastOnly = true) {
|
export default async function getCommits(repo, id, lastOnly = true) {
|
||||||
|
return cache;
|
||||||
const commits = await repo.pulls(id).commits.fetch();
|
const commits = await repo.pulls(id).commits.fetch();
|
||||||
|
|
||||||
if (commits.lastPage) {
|
if (commits.lastPage) {
|
||||||
@@ -21,3 +22,7 @@ export default async function getCommits(repo, id, lastOnly = true) {
|
|||||||
|
|
||||||
return formatCommits(commits.items, lastOnly);
|
return formatCommits(commits.items, lastOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cache = { sha: '5f948924cc4fe34c7b9399e685927e93a18d7450',
|
||||||
|
owner: 'mattapperson',
|
||||||
|
message: 'Merge branch \'feature/x-pack/management/beats\' of github.com:elastic/kibana into feature/x-pack/management/beats' };
|
||||||
@@ -1,11 +1,15 @@
|
|||||||
export default async function getPull(repo, id) {
|
export default async function getPull(repo, id) {
|
||||||
|
return cache;
|
||||||
const pull = await repo.pulls(id).fetch();
|
const pull = await repo.pulls(id).fetch();
|
||||||
return {
|
return {
|
||||||
id: pull.id,
|
id: pull.id,
|
||||||
url: pull.url,
|
url: pull.url,
|
||||||
number: pull.number,
|
number: pull.number,
|
||||||
state: pull.state,
|
state: pull.state,
|
||||||
title: pull.title,
|
|
||||||
labels: pull.labels.map(label => label.name),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cache = { id: 220387229,
|
||||||
|
url: 'https://api.github.com/repos/elastic/kibana/pulls/23819',
|
||||||
|
number: 23819,
|
||||||
|
state: 'open' };
|
||||||
Reference in New Issue
Block a user