Skip to content

Commit

Permalink
Merge pull request #12705 from MinaProtocol/change-gate-users
Browse files Browse the repository at this point in the history
Removes some gate folks, adds @deepthiskumar
  • Loading branch information
lk86 authored Mar 29, 2023
2 parents 905b4a0 + 8017c34 commit dfc3a21
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
11 changes: 11 additions & 0 deletions frontend/ci-build-me/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,14 @@ gcloud functions deploy githubWebhookHandler \
```

This deploys to https://us-central1-o1labs-192920.cloudfunctions.net/githubWebhookHandler

## Update Branch Protection Rules

In order to gate a new branch with this mechanism, github needs to see this job run (but generally we don't actually run a job here,
just block on its existence). This means that if months pass between changes, github will stop showing the buildkite/mina-pr-gating job
in their UI and therefore you cannot block new branches on it.

To fix this, run the PR gating job manually in the builkite UI here: https://buildkite.com/o-1-labs-2/mina-pr-gating

Just running the job once will re-populate it in github's dropdown menus so that you can add the gate to a new branch.
This does not require a redeploy unless you're also intending to change the mechanism of activation or the list of users with this power.
37 changes: 12 additions & 25 deletions frontend/ci-build-me/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ const getRequest = async (url) => {

const handler = async (event, req) => {
const buildkiteTrigger = {};
if (event == "issue_comment") {
// PR Gating Lifting section
if (
// PR Gating Lifting section
if (
// we are creating the comment
req.body.action == "created" &&
// and this is actually a pull request
Expand All @@ -77,10 +76,10 @@ const handler = async (event, req) => {
) {
// TODO #7711: Actually look at @MinaProtocol/stakeholder-reviewers team instead of hardcoding the users here
if (
req.body.sender.login == "es92" ||
req.body.sender.login == "aneesharaines" ||
req.body.sender.login == "bkase" ||
req.body.sender.login == "imeckler"
req.body.sender.login == "deepthiskumar" ||
req.body.sender.login == "mrmr1993"
) {
const prData = await getRequest(req.body.issue.pull_request.url);
const buildkite = await runBuild(
Expand All @@ -91,11 +90,11 @@ const handler = async (event, req) => {
"mina-pr-gating",
{ PR_GATE: "lifted" }
);
return [buildkite, null];
return buildkite;
} else {
return [
"comment author is not (publically) a member of the core team",
"comment author is not (publically) a member of the core team",
"comment author is not authorized to approve for mainnet",
"comment author is not authorized to approve for mainnet",
];
}
}
Expand Down Expand Up @@ -127,10 +126,7 @@ const handler = async (event, req) => {
"mina",
{}
);
const circle = await runCircleBuild({
pull_request: prData.data,
});
return [buildkite, circle];
return buildkite;
} else {
// NB: Users that are 'privately' a member of the org will not be able to trigger CI jobs
return [
Expand All @@ -139,9 +135,8 @@ const handler = async (event, req) => {
];
}
}
}
return [null, null];
};
return null;
};

/**
* HTTP Cloud Function for GitHub Webhook events.
Expand Down Expand Up @@ -169,24 +164,16 @@ exports.githubWebhookHandler = async (req, res) => {
github.validateWebhook(req);

const githubEvent = req.headers["x-github-event"];
const [buildkite, circle] = await handler(githubEvent, req);
const buildkite = await handler(githubEvent, req);
if (buildkite && buildkite.web_url) {
console.info(`Triggered buildkite build at ${buildkite.web_url}`);
} else {
console.error(`Failed to trigger buildkite build for some reason:`);
console.error(buildkite);
}

if (circle && circle.number) {
console.info(`Triggered circle build #${circle.number}`);
} else {
console.error(`Failed to trigger circle build for some reason:`);
console.error(circle);
}

res.status(200);
console.info(`HTTP 200: ${githubEvent} event`);
res.send({ buildkite, circle } || {});
res.send({ buildkite } || {});
} catch (e) {
if (e instanceof HTTPError) {
res.status(e.statusCode).send(e.message);
Expand Down

0 comments on commit dfc3a21

Please sign in to comment.