Skip to content

Commit

Permalink
support setting a timeout for a job
Browse files Browse the repository at this point in the history
  • Loading branch information
mordamax committed Oct 17, 2023
1 parent 3923d4b commit 644611b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ export const setupApi = (ctx: Context, server: Server): void => {
command,
gitlab: {
job: {
...configuration.gitlab.job,
timeout: "24 hours",
...configuration.gitlab.job, // might override default timeout
variables: { ...configuration.gitlab.job.variables, ...variables },
image: gitlab.defaultJobImage,
},
Expand Down
3 changes: 3 additions & 0 deletions src/bot/events/handlers/genericHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ export async function genericHandler(this: EventHandler): Promise<PullRequestErr
gitlab: {
job: {
image,
...(typeof parsedCommand.configuration.gitlab?.job.timeout === "string"
? { timeout: parsedCommand.configuration.gitlab.job.timeout }
: {}),
tags: parsedCommand.configuration.gitlab?.job.tags || [],
variables: Object.assign(defaultVariables, overriddenVariables),
},
Expand Down
2 changes: 1 addition & 1 deletion src/gitlab/createCiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function createCiConfig(
workflow: { rules: [{ if: `$CI_PIPELINE_SOURCE == "api"` }, { if: `$CI_PIPELINE_SOURCE == "web"` }] },
command: {
timeout: "24 hours",
...task.gitlab.job,
...task.gitlab.job, // timeout could be overridden from the command configs
script: [
...`
echo "This job is related to task ${task.id}. ${jobTaskInfoMessage}."
Expand Down
3 changes: 3 additions & 0 deletions src/schema/schema.cmd.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"job": {
"type": "object",
"properties": {
"timeout": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
Expand Down
1 change: 1 addition & 0 deletions src/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type TaskBase<T> = {
requester: string;
gitlab: {
job: {
timeout?: string;
tags: string[];
image: string;
variables: {
Expand Down

0 comments on commit 644611b

Please sign in to comment.