Skip to content

Commit 7cfd19b

Browse files
authored
Merge pull request #2316 from philips-labs/develop
chore: Release
2 parents e4789ea + 014985a commit 7cfd19b

File tree

4 files changed

+11
-18
lines changed

4 files changed

+11
-18
lines changed

modules/runners/scale-up.tf

Lines changed: 1 addition & 1 deletion
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)

modules/webhook/lambdas/webhook/src/webhook/handler.test.ts

Lines changed: 5 additions & 5 deletions
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({
@@ -159,7 +159,7 @@ describe('handler', () => {
159159
expect(sendActionRequest).toBeCalled();
160160
});
161161

162-
it('Check webhook does not accept jobs where not all labels are provided in job.', async () => {
162+
it('Check webhook accept jobs where not all labels are provided in job.', async () => {
163163
process.env.RUNNER_LABELS = '["self-hosted", "test", "test2"]';
164164
process.env.ENABLE_WORKFLOW_JOB_LABELS_CHECK = 'true';
165165
process.env.WORKFLOW_JOB_LABELS_CHECK_ALL = 'true';
@@ -174,8 +174,8 @@ describe('handler', () => {
174174
{ 'X-Hub-Signature': await webhooks.sign(event), 'X-GitHub-Event': 'workflow_job' },
175175
event,
176176
);
177-
expect(resp.statusCode).toBe(202);
178-
expect(sendActionRequest).not.toBeCalled;
177+
expect(resp.statusCode).toBe(201);
178+
expect(sendActionRequest).toBeCalled();
179179
});
180180

181181
it('Check webhook does not accept jobs where not all labels are supported by the runner.', async () => {

modules/webhook/lambdas/webhook/src/webhook/handler.ts

Lines changed: 4 additions & 11 deletions
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
}
@@ -177,16 +177,9 @@ function isRepoNotAllowed(repoFullName: string, repositoryWhiteList: string[]):
177177

178178
function canRunJob(job: WorkflowJobEvent, runnerLabels: string[], workflowLabelCheckAll: boolean): boolean {
179179
const workflowJobLabels = job.workflow_job.labels;
180-
let runnerMatch;
181-
let jobMatch;
182-
if (workflowLabelCheckAll) {
183-
runnerMatch = runnerLabels.every((l) => workflowJobLabels.includes(l));
184-
jobMatch = workflowJobLabels.every((l) => runnerLabels.includes(l));
185-
} else {
186-
runnerMatch = runnerLabels.some((l) => workflowJobLabels.includes(l));
187-
jobMatch = workflowJobLabels.some((l) => runnerLabels.includes(l));
188-
}
189-
const match = jobMatch && runnerMatch;
180+
const match = workflowLabelCheckAll
181+
? workflowJobLabels.every((l) => runnerLabels.includes(l.toLowerCase()))
182+
: workflowJobLabels.some((l) => runnerLabels.includes(l.toLowerCase()));
190183

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

modules/webhook/webhook.tf

Lines changed: 1 addition & 1 deletion
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)