Skip to content

Commit 96e6b65

Browse files
committed
Add tool-specific setup steps
1 parent 57c7bc6 commit 96e6b65

File tree

1 file changed

+142
-0
lines changed

1 file changed

+142
-0
lines changed

pr-checks/sync.ts

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,148 @@ function main(): void {
210210
},
211211
];
212212

213+
const installNode = isTruthy(checkSpecification.installNode);
214+
215+
if (installNode) {
216+
steps.push(
217+
{
218+
name: "Install Node.js",
219+
uses: "actions/setup-node@v6",
220+
with: {
221+
"node-version": "20.x",
222+
cache: "npm",
223+
},
224+
},
225+
{
226+
name: "Install dependencies",
227+
run: "npm ci",
228+
},
229+
);
230+
}
231+
232+
steps.push({
233+
name: "Prepare test",
234+
id: "prepare-test",
235+
uses: "./.github/actions/prepare-test",
236+
with: {
237+
version: "${{ matrix.version }}",
238+
"use-all-platform-bundle": useAllPlatformBundle,
239+
// If the action is being run from a container, then do not setup kotlin.
240+
// This is because the kotlin binaries cannot be downloaded from the container.
241+
"setup-kotlin": String(
242+
!("container" in checkSpecification),
243+
).toLowerCase(),
244+
},
245+
});
246+
247+
const installGo = isTruthy(checkSpecification.installGo);
248+
249+
if (installGo) {
250+
const baseGoVersionExpr = ">=1.21.0";
251+
workflowInputs["go-version"] = {
252+
type: "string",
253+
description: "The version of Go to install",
254+
required: false,
255+
default: baseGoVersionExpr,
256+
};
257+
258+
steps.push({
259+
name: "Install Go",
260+
uses: "actions/setup-go@v6",
261+
with: {
262+
"go-version":
263+
"${{ inputs.go-version || '" + baseGoVersionExpr + "' }}",
264+
// to avoid potentially misleading autobuilder results where we expect it to download
265+
// dependencies successfully, but they actually come from a warm cache
266+
cache: false,
267+
},
268+
});
269+
}
270+
271+
const installJava = isTruthy(checkSpecification.installJava);
272+
273+
if (installJava) {
274+
const baseJavaVersionExpr = "17";
275+
workflowInputs["java-version"] = {
276+
type: "string",
277+
description: "The version of Java to install",
278+
required: false,
279+
default: baseJavaVersionExpr,
280+
};
281+
282+
steps.push({
283+
name: "Install Java",
284+
uses: "actions/setup-java@v5",
285+
with: {
286+
"java-version":
287+
"${{ inputs.java-version || '" + baseJavaVersionExpr + "' }}",
288+
distribution: "temurin",
289+
},
290+
});
291+
}
292+
293+
const installPython = isTruthy(checkSpecification.installPython);
294+
295+
if (installPython) {
296+
const basePythonVersionExpr = "3.13";
297+
workflowInputs["python-version"] = {
298+
type: "string",
299+
description: "The version of Python to install",
300+
required: false,
301+
default: basePythonVersionExpr,
302+
};
303+
304+
steps.push({
305+
name: "Install Python",
306+
if: "matrix.version != 'nightly-latest'",
307+
uses: "actions/setup-python@v6",
308+
with: {
309+
"python-version":
310+
"${{ inputs.python-version || '" + basePythonVersionExpr + "' }}",
311+
},
312+
});
313+
}
314+
315+
const installDotNet = isTruthy(checkSpecification.installDotNet);
316+
317+
if (installDotNet) {
318+
const baseDotNetVersionExpr = "9.x";
319+
workflowInputs["dotnet-version"] = {
320+
type: "string",
321+
description: "The version of .NET to install",
322+
required: false,
323+
default: baseDotNetVersionExpr,
324+
};
325+
326+
steps.push({
327+
name: "Install .NET",
328+
uses: "actions/setup-dotnet@v5",
329+
with: {
330+
"dotnet-version":
331+
"${{ inputs.dotnet-version || '" + baseDotNetVersionExpr + "' }}",
332+
},
333+
});
334+
}
335+
336+
const installYq = isTruthy(checkSpecification.installYq);
337+
338+
if (installYq) {
339+
steps.push({
340+
name: "Install yq",
341+
if: "runner.os == 'Windows'",
342+
env: {
343+
YQ_PATH: "${{ runner.temp }}/yq",
344+
// This is essentially an arbitrary version of `yq`, which happened to be the one that
345+
// `choco` fetched when we moved away from using that here.
346+
// See https://github.com/github/codeql-action/pull/3423
347+
YQ_VERSION: "v4.50.1",
348+
},
349+
run:
350+
'gh release download --repo mikefarah/yq --pattern "yq_windows_amd64.exe" "$YQ_VERSION" -O "$YQ_PATH/yq.exe"\n' +
351+
'echo "$YQ_PATH" >> "$GITHUB_PATH"',
352+
});
353+
}
354+
213355
steps.push(...checkSpecification.steps);
214356

215357
const checkJob: Record<string, any> = {

0 commit comments

Comments
 (0)