Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit 014985a

Browse files
authored
fix: Ignore case for runner labels. (#2315)
* fix: Ignore case for runner labels. * format code
1 parent 6d9116f commit 014985a

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

Diff for: modules/runners/scale-up.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ resource "aws_lambda_function" "scale_up" {
3232
NODE_TLS_REJECT_UNAUTHORIZED = var.ghes_url != null && !var.ghes_ssl_verify ? 0 : 1
3333
PARAMETER_GITHUB_APP_ID_NAME = var.github_app_parameters.id.name
3434
PARAMETER_GITHUB_APP_KEY_BASE64_NAME = var.github_app_parameters.key_base64.name
35-
RUNNER_EXTRA_LABELS = var.runner_extra_labels
35+
RUNNER_EXTRA_LABELS = lower(var.runner_extra_labels)
3636
RUNNER_GROUP_NAME = var.runner_group_name
3737
RUNNERS_MAXIMUM_COUNT = var.runners_maximum_count
3838
SUBNET_IDS = join(",", var.subnet_ids)

Diff for: modules/webhook/lambdas/webhook/src/webhook/handler.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ describe('handler', () => {
129129
...workflowjob_event,
130130
workflow_job: {
131131
...workflowjob_event.workflow_job,
132-
labels: ['self-hosted', 'test'],
132+
labels: ['self-hosted', 'Test'],
133133
},
134134
});
135135
const resp = await handle(
@@ -141,7 +141,7 @@ describe('handler', () => {
141141
});
142142

143143
it('Check runner labels accept job with mixed order.', async () => {
144-
process.env.RUNNER_LABELS = '["linux", "test", "self-hosted"]';
144+
process.env.RUNNER_LABELS = '["linux", "TEST", "self-hosted"]';
145145
process.env.ENABLE_WORKFLOW_JOB_LABELS_CHECK = 'true';
146146
process.env.WORKFLOW_JOB_LABELS_CHECK_ALL = 'true';
147147
const event = JSON.stringify({

Diff for: modules/webhook/lambdas/webhook/src/webhook/handler.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function readEnvironmentVariables() {
8484
const workflowLabelCheckAll = JSON.parse(workflowLabelCheckAllEnv) as boolean;
8585
const repositoryWhiteListEnv = process.env.REPOSITORY_WHITE_LIST || '[]';
8686
const repositoryWhiteList = JSON.parse(repositoryWhiteListEnv) as Array<string>;
87-
const runnerLabelsEnv = process.env.RUNNER_LABELS || '[]';
87+
const runnerLabelsEnv = (process.env.RUNNER_LABELS || '[]').toLowerCase();
8888
const runnerLabels = JSON.parse(runnerLabelsEnv) as Array<string>;
8989
return { environment, repositoryWhiteList, enableWorkflowLabelCheck, workflowLabelCheckAll, runnerLabels };
9090
}
@@ -178,8 +178,8 @@ function isRepoNotAllowed(repoFullName: string, repositoryWhiteList: string[]):
178178
function canRunJob(job: WorkflowJobEvent, runnerLabels: string[], workflowLabelCheckAll: boolean): boolean {
179179
const workflowJobLabels = job.workflow_job.labels;
180180
const match = workflowLabelCheckAll
181-
? workflowJobLabels.every((l) => runnerLabels.includes(l))
182-
: workflowJobLabels.some((l) => runnerLabels.includes(l));
181+
? workflowJobLabels.every((l) => runnerLabels.includes(l.toLowerCase()))
182+
: workflowJobLabels.some((l) => runnerLabels.includes(l.toLowerCase()));
183183

184184
logger.debug(
185185
`Received workflow job event with labels: '${JSON.stringify(workflowJobLabels)}'. The event does ${

Diff for: modules/webhook/webhook.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ resource "aws_lambda_function" "webhook" {
1919
LOG_LEVEL = var.log_level
2020
LOG_TYPE = var.log_type
2121
REPOSITORY_WHITE_LIST = jsonencode(var.repository_white_list)
22-
RUNNER_LABELS = jsonencode(split(",", var.runner_labels))
22+
RUNNER_LABELS = jsonencode(split(",", lower(var.runner_labels)))
2323
SQS_URL_WEBHOOK = var.sqs_build_queue.id
2424
SQS_IS_FIFO = var.sqs_build_queue_fifo
2525
}

0 commit comments

Comments
 (0)