Skip to content

Commit 95fc2f1

Browse files
committed
Move yq setup code into getSetupSteps
1 parent 92ab799 commit 95fc2f1

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

pr-checks/sync.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ const languageSetups: LanguageSetups = {
231231
},
232232
};
233233

234+
// This is essentially an arbitrary version of `yq`, which happened to be the one that
235+
// `choco` fetched when we moved away from using that here.
236+
// See https://github.com/github/codeql-action/pull/3423
237+
const YQ_VERSION = "v4.50.1";
238+
234239
const THIS_DIR = __dirname;
235240
const CHECKS_DIR = path.join(THIS_DIR, "checks");
236241
const OUTPUT_DIR = path.join(THIS_DIR, "..", ".github", "workflows");
@@ -348,6 +353,22 @@ function getSetupSteps(checkSpecification: Specification): {
348353
inputs = { ...inputs, ...setupSpec.inputs };
349354
}
350355

356+
const installYq = checkSpecification.installYq;
357+
358+
if (installYq) {
359+
steps.push({
360+
name: "Install yq",
361+
if: "runner.os == 'Windows'",
362+
env: {
363+
YQ_PATH: "${{ runner.temp }}/yq",
364+
YQ_VERSION,
365+
},
366+
run:
367+
'gh release download --repo mikefarah/yq --pattern "yq_windows_amd64.exe" "$YQ_VERSION" -O "$YQ_PATH/yq.exe"\n' +
368+
'echo "$YQ_PATH" >> "$GITHUB_PATH"',
369+
});
370+
}
371+
351372
return { inputs, steps };
352373
}
353374

@@ -396,25 +417,6 @@ function generateJob(
396417
...setupInfo.steps,
397418
];
398419

399-
const installYq = checkSpecification.installYq;
400-
401-
if (installYq) {
402-
steps.push({
403-
name: "Install yq",
404-
if: "runner.os == 'Windows'",
405-
env: {
406-
YQ_PATH: "${{ runner.temp }}/yq",
407-
// This is essentially an arbitrary version of `yq`, which happened to be the one that
408-
// `choco` fetched when we moved away from using that here.
409-
// See https://github.com/github/codeql-action/pull/3423
410-
YQ_VERSION: "v4.50.1",
411-
},
412-
run:
413-
'gh release download --repo mikefarah/yq --pattern "yq_windows_amd64.exe" "$YQ_VERSION" -O "$YQ_PATH/yq.exe"\n' +
414-
'echo "$YQ_PATH" >> "$GITHUB_PATH"',
415-
});
416-
}
417-
418420
// Extract the sequence of steps from the YAML document to persist as much formatting as possible.
419421
const specSteps = specDocument.get("steps") as yaml.YAMLSeq;
420422

0 commit comments

Comments
 (0)