зеркало из https://github.com/electron/trop.git
fix: ensure git found on trop runner (#304)
This commit is contained in:
Родитель
c8c9cf4e33
Коммит
439152f4a5
|
@ -0,0 +1,2 @@
|
|||
# Heroku-24 stack doesn't include git by default.
|
||||
git-all
|
12
app.json
12
app.json
|
@ -11,15 +11,15 @@
|
|||
"required": true
|
||||
}
|
||||
},
|
||||
"formation": {
|
||||
},
|
||||
"addons": [
|
||||
|
||||
],
|
||||
"formation": {},
|
||||
"addons": [],
|
||||
"buildpacks": [
|
||||
{
|
||||
"url": "heroku-community/apt"
|
||||
},
|
||||
{
|
||||
"url": "heroku/nodejs"
|
||||
}
|
||||
],
|
||||
"stack": "heroku-22"
|
||||
"stack": "heroku-24"
|
||||
}
|
||||
|
|
|
@ -27,3 +27,6 @@ export const BACKPORT_REQUESTED_LABEL =
|
|||
|
||||
export const DEFAULT_BACKPORT_REVIEW_TEAM =
|
||||
process.env.DEFAULT_BACKPORT_REVIEW_TEAM;
|
||||
|
||||
export const VALID_BACKPORT_CHECK_NAME =
|
||||
process.env.BACKPORT_REQUESTED_LABEL || 'Valid Backport';
|
||||
|
|
31
src/index.ts
31
src/index.ts
|
@ -11,7 +11,12 @@ import {
|
|||
labelExistsOnPR,
|
||||
removeLabel,
|
||||
} from './utils/label-utils';
|
||||
import { CHECK_PREFIX, NO_BACKPORT_LABEL, SKIP_CHECK_LABEL } from './constants';
|
||||
import {
|
||||
CHECK_PREFIX,
|
||||
NO_BACKPORT_LABEL,
|
||||
SKIP_CHECK_LABEL,
|
||||
VALID_BACKPORT_CHECK_NAME,
|
||||
} from './constants';
|
||||
import { getEnvVar } from './utils/env-util';
|
||||
import { PRChange, PRStatus, BackportPurpose, CheckRunStatus } from './enums';
|
||||
import { Label } from '@octokit/webhooks-types';
|
||||
|
@ -28,15 +33,11 @@ import {
|
|||
updateBackportValidityCheck,
|
||||
} from './utils/checks-util';
|
||||
import { register } from './utils/prom';
|
||||
import {
|
||||
SimpleWebHookRepoContext,
|
||||
WebHookIssueContext,
|
||||
WebHookPR,
|
||||
WebHookPRContext,
|
||||
} from './types';
|
||||
import { SimpleWebHookRepoContext, WebHookPR, WebHookPRContext } from './types';
|
||||
|
||||
// Built in fetch doesn't support global-agent...
|
||||
// @ts-ignore
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
// @ts-ignore - builtin fetch doesn't support global-agent.
|
||||
delete globalThis.fetch;
|
||||
|
||||
const probotHandler: ApplicationFunction = async (robot, { getRouter }) => {
|
||||
|
@ -145,6 +146,12 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => {
|
|||
}
|
||||
};
|
||||
|
||||
const gitExists = execSync('which git').toString().trim();
|
||||
if (/git not found/.test(gitExists)) {
|
||||
robot.log('Git not found - unable to proceed with backporting');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that a PR done to `main` contains the required
|
||||
* backport information, i.e.: at least a `no-backport` or
|
||||
|
@ -154,8 +161,6 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => {
|
|||
* @returns
|
||||
*/
|
||||
|
||||
const VALID_BACKPORT_CHECK_NAME = 'Valid Backport';
|
||||
|
||||
robot.on(
|
||||
[
|
||||
'pull_request.opened',
|
||||
|
@ -423,7 +428,7 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => {
|
|||
);
|
||||
|
||||
// Backport pull requests to labeled targets when PR is merged.
|
||||
robot.on('pull_request.closed', async (context: WebHookPRContext) => {
|
||||
robot.on('pull_request.closed', async (context) => {
|
||||
const { pull_request: pr } = context.payload;
|
||||
|
||||
const oldPRNumbers = getPRNumbersFromPRBody(pr, true);
|
||||
|
@ -471,7 +476,7 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => {
|
|||
const TROP_COMMAND_PREFIX = '/trop ';
|
||||
|
||||
// Manually trigger backporting process on trigger comment phrase.
|
||||
robot.on('issue_comment.created', async (context: WebHookIssueContext) => {
|
||||
robot.on('issue_comment.created', async (context) => {
|
||||
const { issue, comment } = context.payload;
|
||||
|
||||
const isPullRequest = (i: { number: number; html_url: string }) =>
|
||||
|
|
14
src/utils.ts
14
src/utils.ts
|
@ -1,5 +1,6 @@
|
|||
import fetch from 'node-fetch';
|
||||
import * as fs from 'fs-extra';
|
||||
import { execSync } from 'child_process';
|
||||
import Queue from 'queue';
|
||||
import simpleGit from 'simple-git';
|
||||
|
||||
|
@ -29,7 +30,7 @@ import {
|
|||
WebHookPR,
|
||||
WebHookRepoContext,
|
||||
} from './types';
|
||||
import { Context, Probot } from 'probot';
|
||||
import { Probot } from 'probot';
|
||||
|
||||
const { parse: parseDiff } = require('what-the-diff');
|
||||
|
||||
|
@ -475,6 +476,17 @@ export const backportImpl = async (
|
|||
}
|
||||
}
|
||||
|
||||
const gitExists = execSync('which git').toString().trim();
|
||||
if (/git not found/.test(gitExists)) {
|
||||
await context.octokit.issues.createComment(
|
||||
context.repo({
|
||||
body: `Git not found - unable to proceed with backporting to ${targetBranch}`,
|
||||
issue_number: pr.number,
|
||||
}),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const base = pr.base;
|
||||
const slug = `${base.repo.owner.login}/${base.repo.name}`;
|
||||
const bp = `backport from PR #${pr.number} to "${targetBranch}"`;
|
||||
|
|
Загрузка…
Ссылка в новой задаче