Add concurrency queue support (#355)
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import type {FeatureFlags} from "@actions/expressions/features";
|
||||
import {TemplateContext} from "../../templates/template-context.js";
|
||||
import {TemplateToken} from "../../templates/tokens/template-token.js";
|
||||
import {isString} from "../../templates/tokens/type-guards.js";
|
||||
import {ConcurrencySetting} from "../workflow-template.js";
|
||||
import {ConcurrencyQueue, ConcurrencySetting} from "../workflow-template.js";
|
||||
|
||||
export function convertConcurrency(context: TemplateContext, token: TemplateToken): ConcurrencySetting {
|
||||
const result: ConcurrencySetting = {};
|
||||
const featureFlags = context.state.featureFlags as FeatureFlags | undefined;
|
||||
|
||||
if (token.isExpression) {
|
||||
return result;
|
||||
@@ -26,6 +28,11 @@ export function convertConcurrency(context: TemplateContext, token: TemplateToke
|
||||
case "cancel-in-progress":
|
||||
result.cancelInProgress = property.value.assertBoolean("cancel-in-progress").value;
|
||||
break;
|
||||
case "queue":
|
||||
if (featureFlags?.isEnabled("allowConcurrencyQueue")) {
|
||||
result.queue = property.value.assertString("queue").value as ConcurrencyQueue;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
context.error(propertyName, `Invalid property name: ${propertyName.value}`);
|
||||
}
|
||||
|
||||
@@ -18,9 +18,12 @@ export type WorkflowTemplate = {
|
||||
}[];
|
||||
};
|
||||
|
||||
export type ConcurrencyQueue = "single" | "max";
|
||||
|
||||
export type ConcurrencySetting = {
|
||||
group?: StringToken;
|
||||
cancelInProgress?: boolean;
|
||||
queue?: ConcurrencyQueue;
|
||||
};
|
||||
|
||||
export type ActionsEnvironmentReference = {
|
||||
|
||||
@@ -2050,10 +2050,20 @@
|
||||
"cancel-in-progress": {
|
||||
"type": "boolean",
|
||||
"description": "To cancel any currently running job or workflow in the same concurrency group, specify cancel-in-progress: true."
|
||||
},
|
||||
"queue": {
|
||||
"type": "concurrency-queue",
|
||||
"description": "The queuing mode for the concurrency group. When set to `max`, workflows or jobs will wait in a queue for the concurrency group up to the maximum queue length. Default: `single` meaning at most one item can be pending."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"concurrency-queue": {
|
||||
"allowed-values": [
|
||||
"single",
|
||||
"max"
|
||||
]
|
||||
},
|
||||
"job-environment": {
|
||||
"description": "The environment that the job references. All environment protection rules must pass before a job referencing the environment is sent to a runner.",
|
||||
"context": [
|
||||
|
||||
Reference in New Issue
Block a user