feat: ignore initialization of virtual merge commits

Signed-off-by: Aleksei Igrychev <aleksei.igrychev@palark.com>
This commit is contained in:
Aleksei Igrychev
2023-12-21 22:13:33 +00:00
parent 123d59749a
commit ed26ed00c3
8 changed files with 35 additions and 107 deletions

View File

@@ -31679,7 +31679,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}); });
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ValidateWerfVersion = exports.ProcessGitHubContext = exports.SetupKubeConfig = exports.PrepareEnvironAndRunWerfCommand = exports.Setup = void 0; exports.ValidateWerfVersion = exports.ProcessGitHubContext = exports.SetupKubeConfig = exports.PrepareEnvironAndRunWerfCommand = void 0;
const core = __importStar(__nccwpck_require__(4181)); const core = __importStar(__nccwpck_require__(4181));
const tmp = __importStar(__nccwpck_require__(3728)); const tmp = __importStar(__nccwpck_require__(3728));
const fs = __importStar(__nccwpck_require__(7147)); const fs = __importStar(__nccwpck_require__(7147));
@@ -31689,26 +31689,6 @@ const typescript_string_operations_1 = __nccwpck_require__(9363);
const manager_1 = __nccwpck_require__(1856); const manager_1 = __nccwpck_require__(1856);
const werf = __importStar(__nccwpck_require__(8525)); const werf = __importStar(__nccwpck_require__(8525));
const minimalWerfVersion = 'v1.1.17'; const minimalWerfVersion = 'v1.1.17';
function Setup() {
return __awaiter(this, void 0, void 0, function* () {
try {
ProcessGitHubContext();
const kubeConfigBase64Data = core.getInput('kube-config-base64-data');
if (kubeConfigBase64Data !== '') {
SetupKubeConfig(kubeConfigBase64Data);
}
const m = new manager_1.Manager();
yield m.Install();
process.env.GITHUB_TOKEN =
process.env.GITHUB_TOKEN || core.getInput('github-token');
yield m.PerformCIEnv();
}
catch (error) {
core.setFailed(error.message);
}
});
}
exports.Setup = Setup;
function PrepareEnvironAndRunWerfCommand(args) { function PrepareEnvironAndRunWerfCommand(args) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
@@ -31743,6 +31723,10 @@ exports.SetupKubeConfig = SetupKubeConfig;
function ProcessGitHubContext() { function ProcessGitHubContext() {
if (github_1.context.eventName === 'pull_request') { if (github_1.context.eventName === 'pull_request') {
if (github_1.context.payload.pull_request) { if (github_1.context.payload.pull_request) {
// Do nothing if virtual merge variable is already set
if (process.env.WERF_VIRTUAL_MERGE) {
return;
}
const baseSha = github_1.context.payload.pull_request.base.sha; const baseSha = github_1.context.payload.pull_request.base.sha;
const headSha = github_1.context.payload.pull_request.head.sha; const headSha = github_1.context.payload.pull_request.head.sha;
process.env.WERF_VIRTUAL_MERGE = '1'; process.env.WERF_VIRTUAL_MERGE = '1';

View File

@@ -31679,7 +31679,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}); });
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ValidateWerfVersion = exports.ProcessGitHubContext = exports.SetupKubeConfig = exports.PrepareEnvironAndRunWerfCommand = exports.Setup = void 0; exports.ValidateWerfVersion = exports.ProcessGitHubContext = exports.SetupKubeConfig = exports.PrepareEnvironAndRunWerfCommand = void 0;
const core = __importStar(__nccwpck_require__(4181)); const core = __importStar(__nccwpck_require__(4181));
const tmp = __importStar(__nccwpck_require__(3728)); const tmp = __importStar(__nccwpck_require__(3728));
const fs = __importStar(__nccwpck_require__(7147)); const fs = __importStar(__nccwpck_require__(7147));
@@ -31689,26 +31689,6 @@ const typescript_string_operations_1 = __nccwpck_require__(9363);
const manager_1 = __nccwpck_require__(1856); const manager_1 = __nccwpck_require__(1856);
const werf = __importStar(__nccwpck_require__(8525)); const werf = __importStar(__nccwpck_require__(8525));
const minimalWerfVersion = 'v1.1.17'; const minimalWerfVersion = 'v1.1.17';
function Setup() {
return __awaiter(this, void 0, void 0, function* () {
try {
ProcessGitHubContext();
const kubeConfigBase64Data = core.getInput('kube-config-base64-data');
if (kubeConfigBase64Data !== '') {
SetupKubeConfig(kubeConfigBase64Data);
}
const m = new manager_1.Manager();
yield m.Install();
process.env.GITHUB_TOKEN =
process.env.GITHUB_TOKEN || core.getInput('github-token');
yield m.PerformCIEnv();
}
catch (error) {
core.setFailed(error.message);
}
});
}
exports.Setup = Setup;
function PrepareEnvironAndRunWerfCommand(args) { function PrepareEnvironAndRunWerfCommand(args) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
@@ -31743,6 +31723,10 @@ exports.SetupKubeConfig = SetupKubeConfig;
function ProcessGitHubContext() { function ProcessGitHubContext() {
if (github_1.context.eventName === 'pull_request') { if (github_1.context.eventName === 'pull_request') {
if (github_1.context.payload.pull_request) { if (github_1.context.payload.pull_request) {
// Do nothing if virtual merge variable is already set
if (process.env.WERF_VIRTUAL_MERGE) {
return;
}
const baseSha = github_1.context.payload.pull_request.base.sha; const baseSha = github_1.context.payload.pull_request.base.sha;
const headSha = github_1.context.payload.pull_request.head.sha; const headSha = github_1.context.payload.pull_request.head.sha;
process.env.WERF_VIRTUAL_MERGE = '1'; process.env.WERF_VIRTUAL_MERGE = '1';

View File

@@ -31628,7 +31628,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}); });
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ValidateWerfVersion = exports.ProcessGitHubContext = exports.SetupKubeConfig = exports.PrepareEnvironAndRunWerfCommand = exports.Setup = void 0; exports.ValidateWerfVersion = exports.ProcessGitHubContext = exports.SetupKubeConfig = exports.PrepareEnvironAndRunWerfCommand = void 0;
const core = __importStar(__nccwpck_require__(4181)); const core = __importStar(__nccwpck_require__(4181));
const tmp = __importStar(__nccwpck_require__(3728)); const tmp = __importStar(__nccwpck_require__(3728));
const fs = __importStar(__nccwpck_require__(7147)); const fs = __importStar(__nccwpck_require__(7147));
@@ -31638,26 +31638,6 @@ const typescript_string_operations_1 = __nccwpck_require__(9363);
const manager_1 = __nccwpck_require__(1856); const manager_1 = __nccwpck_require__(1856);
const werf = __importStar(__nccwpck_require__(8525)); const werf = __importStar(__nccwpck_require__(8525));
const minimalWerfVersion = 'v1.1.17'; const minimalWerfVersion = 'v1.1.17';
function Setup() {
return __awaiter(this, void 0, void 0, function* () {
try {
ProcessGitHubContext();
const kubeConfigBase64Data = core.getInput('kube-config-base64-data');
if (kubeConfigBase64Data !== '') {
SetupKubeConfig(kubeConfigBase64Data);
}
const m = new manager_1.Manager();
yield m.Install();
process.env.GITHUB_TOKEN =
process.env.GITHUB_TOKEN || core.getInput('github-token');
yield m.PerformCIEnv();
}
catch (error) {
core.setFailed(error.message);
}
});
}
exports.Setup = Setup;
function PrepareEnvironAndRunWerfCommand(args) { function PrepareEnvironAndRunWerfCommand(args) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
@@ -31692,6 +31672,10 @@ exports.SetupKubeConfig = SetupKubeConfig;
function ProcessGitHubContext() { function ProcessGitHubContext() {
if (github_1.context.eventName === 'pull_request') { if (github_1.context.eventName === 'pull_request') {
if (github_1.context.payload.pull_request) { if (github_1.context.payload.pull_request) {
// Do nothing if virtual merge variable is already set
if (process.env.WERF_VIRTUAL_MERGE) {
return;
}
const baseSha = github_1.context.payload.pull_request.base.sha; const baseSha = github_1.context.payload.pull_request.base.sha;
const headSha = github_1.context.payload.pull_request.head.sha; const headSha = github_1.context.payload.pull_request.head.sha;
process.env.WERF_VIRTUAL_MERGE = '1'; process.env.WERF_VIRTUAL_MERGE = '1';

View File

@@ -31628,7 +31628,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}); });
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ValidateWerfVersion = exports.ProcessGitHubContext = exports.SetupKubeConfig = exports.PrepareEnvironAndRunWerfCommand = exports.Setup = void 0; exports.ValidateWerfVersion = exports.ProcessGitHubContext = exports.SetupKubeConfig = exports.PrepareEnvironAndRunWerfCommand = void 0;
const core = __importStar(__nccwpck_require__(4181)); const core = __importStar(__nccwpck_require__(4181));
const tmp = __importStar(__nccwpck_require__(3728)); const tmp = __importStar(__nccwpck_require__(3728));
const fs = __importStar(__nccwpck_require__(7147)); const fs = __importStar(__nccwpck_require__(7147));
@@ -31638,26 +31638,6 @@ const typescript_string_operations_1 = __nccwpck_require__(9363);
const manager_1 = __nccwpck_require__(1856); const manager_1 = __nccwpck_require__(1856);
const werf = __importStar(__nccwpck_require__(8525)); const werf = __importStar(__nccwpck_require__(8525));
const minimalWerfVersion = 'v1.1.17'; const minimalWerfVersion = 'v1.1.17';
function Setup() {
return __awaiter(this, void 0, void 0, function* () {
try {
ProcessGitHubContext();
const kubeConfigBase64Data = core.getInput('kube-config-base64-data');
if (kubeConfigBase64Data !== '') {
SetupKubeConfig(kubeConfigBase64Data);
}
const m = new manager_1.Manager();
yield m.Install();
process.env.GITHUB_TOKEN =
process.env.GITHUB_TOKEN || core.getInput('github-token');
yield m.PerformCIEnv();
}
catch (error) {
core.setFailed(error.message);
}
});
}
exports.Setup = Setup;
function PrepareEnvironAndRunWerfCommand(args) { function PrepareEnvironAndRunWerfCommand(args) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
@@ -31692,6 +31672,10 @@ exports.SetupKubeConfig = SetupKubeConfig;
function ProcessGitHubContext() { function ProcessGitHubContext() {
if (github_1.context.eventName === 'pull_request') { if (github_1.context.eventName === 'pull_request') {
if (github_1.context.payload.pull_request) { if (github_1.context.payload.pull_request) {
// Do nothing if virtual merge variable is already set
if (process.env.WERF_VIRTUAL_MERGE) {
return;
}
const baseSha = github_1.context.payload.pull_request.base.sha; const baseSha = github_1.context.payload.pull_request.base.sha;
const headSha = github_1.context.payload.pull_request.head.sha; const headSha = github_1.context.payload.pull_request.head.sha;
process.env.WERF_VIRTUAL_MERGE = '1'; process.env.WERF_VIRTUAL_MERGE = '1';

View File

@@ -31672,6 +31672,10 @@ exports.SetupKubeConfig = SetupKubeConfig;
function ProcessGitHubContext() { function ProcessGitHubContext() {
if (github_1.context.eventName === 'pull_request') { if (github_1.context.eventName === 'pull_request') {
if (github_1.context.payload.pull_request) { if (github_1.context.payload.pull_request) {
// Do nothing if virtual merge variable is already set
if (process.env.WERF_VIRTUAL_MERGE) {
return;
}
const baseSha = github_1.context.payload.pull_request.base.sha; const baseSha = github_1.context.payload.pull_request.base.sha;
const headSha = github_1.context.payload.pull_request.head.sha; const headSha = github_1.context.payload.pull_request.head.sha;
process.env.WERF_VIRTUAL_MERGE = '1'; process.env.WERF_VIRTUAL_MERGE = '1';

View File

@@ -31680,7 +31680,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}); });
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ValidateWerfVersion = exports.ProcessGitHubContext = exports.SetupKubeConfig = exports.PrepareEnvironAndRunWerfCommand = exports.Setup = void 0; exports.ValidateWerfVersion = exports.ProcessGitHubContext = exports.SetupKubeConfig = exports.PrepareEnvironAndRunWerfCommand = void 0;
const core = __importStar(__nccwpck_require__(4181)); const core = __importStar(__nccwpck_require__(4181));
const tmp = __importStar(__nccwpck_require__(3728)); const tmp = __importStar(__nccwpck_require__(3728));
const fs = __importStar(__nccwpck_require__(7147)); const fs = __importStar(__nccwpck_require__(7147));
@@ -31690,26 +31690,6 @@ const typescript_string_operations_1 = __nccwpck_require__(9363);
const manager_1 = __nccwpck_require__(1856); const manager_1 = __nccwpck_require__(1856);
const werf = __importStar(__nccwpck_require__(8525)); const werf = __importStar(__nccwpck_require__(8525));
const minimalWerfVersion = 'v1.1.17'; const minimalWerfVersion = 'v1.1.17';
function Setup() {
return __awaiter(this, void 0, void 0, function* () {
try {
ProcessGitHubContext();
const kubeConfigBase64Data = core.getInput('kube-config-base64-data');
if (kubeConfigBase64Data !== '') {
SetupKubeConfig(kubeConfigBase64Data);
}
const m = new manager_1.Manager();
yield m.Install();
process.env.GITHUB_TOKEN =
process.env.GITHUB_TOKEN || core.getInput('github-token');
yield m.PerformCIEnv();
}
catch (error) {
core.setFailed(error.message);
}
});
}
exports.Setup = Setup;
function PrepareEnvironAndRunWerfCommand(args) { function PrepareEnvironAndRunWerfCommand(args) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
@@ -31744,6 +31724,10 @@ exports.SetupKubeConfig = SetupKubeConfig;
function ProcessGitHubContext() { function ProcessGitHubContext() {
if (github_1.context.eventName === 'pull_request') { if (github_1.context.eventName === 'pull_request') {
if (github_1.context.payload.pull_request) { if (github_1.context.payload.pull_request) {
// Do nothing if virtual merge variable is already set
if (process.env.WERF_VIRTUAL_MERGE) {
return;
}
const baseSha = github_1.context.payload.pull_request.base.sha; const baseSha = github_1.context.payload.pull_request.base.sha;
const headSha = github_1.context.payload.pull_request.head.sha; const headSha = github_1.context.payload.pull_request.head.sha;
process.env.WERF_VIRTUAL_MERGE = '1'; process.env.WERF_VIRTUAL_MERGE = '1';

View File

@@ -47,13 +47,17 @@ export async function SetupKubeConfig(
export function ProcessGitHubContext(): void { export function ProcessGitHubContext(): void {
if (context.eventName === 'pull_request') { if (context.eventName === 'pull_request') {
if (context.payload.pull_request) { if (context.payload.pull_request) {
// Do nothing if virtual merge variable is already set
if (process.env.WERF_VIRTUAL_MERGE) {
return
}
const baseSha = context.payload.pull_request.base.sha const baseSha = context.payload.pull_request.base.sha
const headSha = context.payload.pull_request.head.sha const headSha = context.payload.pull_request.head.sha
process.env.WERF_VIRTUAL_MERGE = '1' process.env.WERF_VIRTUAL_MERGE = '1'
process.env.WERF_VIRTUAL_MERGE_FROM_COMMIT = headSha process.env.WERF_VIRTUAL_MERGE_FROM_COMMIT = headSha
process.env.WERF_VIRTUAL_MERGE_INTO_COMMIT = baseSha process.env.WERF_VIRTUAL_MERGE_INTO_COMMIT = baseSha
core.exportVariable('WERF_VIRTUAL_MERGE', '1') core.exportVariable('WERF_VIRTUAL_MERGE', '1')
core.exportVariable('WERF_VIRTUAL_MERGE_FROM_COMMIT', headSha) core.exportVariable('WERF_VIRTUAL_MERGE_FROM_COMMIT', headSha)
core.exportVariable('WERF_VIRTUAL_MERGE_INTO_COMMIT', baseSha) core.exportVariable('WERF_VIRTUAL_MERGE_INTO_COMMIT', baseSha)

View File

@@ -5,7 +5,7 @@ import {ProcessGitHubContext} from './common'
async function run(): Promise<void> { async function run(): Promise<void> {
try { try {
ProcessGitHubContext() ProcessGitHubContext()
const m = new Manager() const m = new Manager()
await m.Install() await m.Install()
} catch (error) { } catch (error) {