diff --git a/README.md b/README.md index 2071f26..5827a0d 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,6 @@ Before starting to work on this project, we recommend reading the - [Pull request commands](#pull-request-commands) - [Help](#pull-request-command-help) - [Cancel](#pull-request-command-cancel) - - [Generic](#pull-request-command-generic) - - [Testing generic command in dev](#pull-request-command-generic-dev) - [API](#api) - [Queue](#api-command-queue) - [Cancel](#api-command-cancel) @@ -60,14 +58,6 @@ In `[bot-args]` are optional, you can provide the following options Bot responds with an actual list of commands generated from pipeline. -## Example of one generic command Bench - -`bot bench $ runtime westend-dev pallet_balances` - -#### Testing the updates to command-bot-scripts by overriding its default branch - -`bot bench -v PIPELINE_SCRIPTS_REF=your-branch $ overhead assets westmint` - ## Cancel In the pull request where you previously ran `bot queue`, comment: diff --git a/src/api.ts b/src/api.ts index eed778e..3199585 100644 --- a/src/api.ts +++ b/src/api.ts @@ -146,7 +146,7 @@ export const setupApi = (ctx: Context, server: Server): void => { job: { ...configuration.gitlab.job, variables: { ...configuration.gitlab.job.variables, ...variables }, - image: gitlab.jobImage, + image: gitlab.defaultJobImage, }, pipeline: null, }, diff --git a/src/bot/events/onIssueCommentCreated.ts b/src/bot/events/onIssueCommentCreated.ts index a140334..e3fa306 100644 --- a/src/bot/events/onIssueCommentCreated.ts +++ b/src/bot/events/onIssueCommentCreated.ts @@ -16,6 +16,7 @@ import { updateComment, } from "src/github"; import { counters, getMetricsPrData } from "src/metrics"; +import { CMD_IMAGE } from "src/setup"; import { cancelTask, getNextTaskId, PullRequestTask, queueTask, serializeTaskQueuedDate } from "src/task"; import { getLines } from "src/utils"; @@ -150,6 +151,12 @@ export const onIssueCommentCreated: WebhookHandler<"issue_comment.created"> = as const defaultVariables = parsedCommand.configuration.gitlab?.job.variables; const overriddenVariables = parsedCommand.variables; + const configJobImage = parsedCommand.configuration.gitlab?.job.image; + let image: string = typeof configJobImage === "string" ? configJobImage : gitlab.defaultJobImage; + + if (typeof overriddenVariables?.[CMD_IMAGE] === "string") { + image = overriddenVariables[CMD_IMAGE] as string; + } const task: PullRequestTask = { ...pr, @@ -167,8 +174,8 @@ export const onIssueCommentCreated: WebhookHandler<"issue_comment.created"> = as queuedDate: serializeTaskQueuedDate(queuedDate), gitlab: { job: { + image, tags: parsedCommand.configuration.gitlab?.job.tags || [], - image: gitlab.jobImage, variables: Object.assign(defaultVariables, overriddenVariables), }, pipeline: null, diff --git a/src/command-configs/help/parts/commands.pug b/src/command-configs/help/parts/commands.pug index 1b32208..b7183a4 100644 --- a/src/command-configs/help/parts/commands.pug +++ b/src/command-configs/help/parts/commands.pug @@ -37,6 +37,18 @@ div(id="link-new-command").command p code #{commandStart} new-command -v PIPELINE_SCRIPTS_REF=mak/new-command new-id --new-arg=value +div(id="link-override-ci-image").command + h5 Override Command's CI Image + p You can override command's CI image with any other image, for example when you need to test new version of Rust + + p Syntax (after command name): + p + code -v CMD_IMAGE=paritytech/ci-unified:bullseye-1.70.0-2023-05-23 + + p Examples: + p + code #{commandStart} update-ui -v CMD_IMAGE=paritytech/ci-unified:bullseye-1.70.0-2023-05-23 --rust_version=1.70.0 + div(id="link-rust").command h5 Rust Log, etc p You can define custom env variables like for RUST env diff --git a/src/command-configs/help/parts/navigation.pug b/src/command-configs/help/parts/navigation.pug index 5046293..48602a8 100644 --- a/src/command-configs/help/parts/navigation.pug +++ b/src/command-configs/help/parts/navigation.pug @@ -20,5 +20,7 @@ div.sticky-nav a(href="\#link-companion") Patch Companion li a(href="\#link-new-command") How to test new command (test dev branch) + li + a(href="\#link-override-ci-image") Override Command's CI Image li a(href="\#link-rust") Rust Log, etc diff --git a/src/main.ts b/src/main.ts index 8071d1b..eb69fab 100644 --- a/src/main.ts +++ b/src/main.ts @@ -37,7 +37,7 @@ const main = async () => { accessTokenUsername: config.gitlabAccessTokenUsername, domain: config.gitlabDomain, pushNamespace: config.gitlabPushNamespace, - jobImage: config.gitlabJobImage, + defaultJobImage: config.gitlabJobImage, }, }).then(resolve, reject), ) diff --git a/src/schema/schema.cmd.json b/src/schema/schema.cmd.json index 94d8994..bcfee24 100644 --- a/src/schema/schema.cmd.json +++ b/src/schema/schema.cmd.json @@ -30,6 +30,9 @@ "variables": { "type": "object", "additionalProperties": true + }, + "image": { + "type": "string" } }, "required": ["tags"] diff --git a/src/setup.ts b/src/setup.ts index 4d36c29..7e00a30 100644 --- a/src/setup.ts +++ b/src/setup.ts @@ -19,7 +19,12 @@ export const DOCS_URL_PATH = "/static/docs/"; export const GENERATED_DIR = path.join(process.cwd(), "generated"); export const DOCS_DIR = path.join(GENERATED_DIR, "docs"); +// -v --variable to override scripts branch to test new features export const PIPELINE_SCRIPTS_REF = "PIPELINE_SCRIPTS_REF"; + +// -v --variable to override default image revision +export const CMD_IMAGE = "CMD_IMAGE"; + export const LATEST = "latest"; export const setup = async ( diff --git a/src/types.ts b/src/types.ts index 254730a..3422856 100644 --- a/src/types.ts +++ b/src/types.ts @@ -32,7 +32,7 @@ export type Context = { accessToken: string; domain: string; pushNamespace: string; - jobImage: string; + defaultJobImage: string; accessTokenUsername: string; }; };