Skip to content

Commit 9104ff3

Browse files
committed
Scaffold validation job
1 parent a4fe152 commit 9104ff3

3 files changed

Lines changed: 81 additions & 12 deletions

File tree

‎.github/workflows/__diagnostics-without-db.yml‎

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pr-checks/checks/diagnostics-without-db.yml‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ versions:
44
# Overridden by the FF below.
55
- linked
66
installNode: true
7+
8+
env:
9+
# Allow the failed SARIF file to be generated.
10+
CODEQL_ACTION_TEST_MODE: false
11+
# But don't actually upload it.
12+
CODEQL_ACTION_SKIP_SARIF_UPLOAD: true
13+
# Mark telemetry for this workflow so it can be treated separately.
14+
CODEQL_ACTION_TESTING_ENVIRONMENT: codeql-action-pr-checks
15+
716
steps:
817
# We deliberately need to make this step fail before the database is initialised, but after
918
# some diagnostic has been produced. The simplest way to do that right now is to force the
@@ -25,3 +34,16 @@ steps:
2534
run: |
2635
cd ../action
2736
npx tsx ./pr-checks/diagnostics-without-db.ts
37+
validationJobs:
38+
diagnostics-without-db-validation:
39+
checkout: true
40+
installNode: true
41+
steps:
42+
- name: Download workflow artifact
43+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
44+
with:
45+
pattern: test-mode-sarif
46+
path: sarif
47+
48+
- name: List artifact contents
49+
run: ls -laR ./sarif

‎pr-checks/sync.ts‎

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ interface Specification extends JobSpecification {
9090
services?: any;
9191

9292
/** Additional jobs to run after the main PR check job. */
93-
validationJobs?: Record<string, JobSpecification>;
93+
validationJobs?: Record<string, ValidationJobSpecification>;
9494

9595
/** If set, this check is part of a named collection that gets its own caller workflow. */
9696
collection?: string;
@@ -122,6 +122,10 @@ interface JobSpecification {
122122
installYq?: boolean;
123123
}
124124

125+
type ValidationJobSpecification = JobSpecification & {
126+
checkout?: boolean;
127+
};
128+
125129
/** Describes language/framework-specific steps and inputs. */
126130
interface LanguageSetup {
127131
specProperty: keyof JobSpecification;
@@ -462,6 +466,20 @@ function generateJobMatrix(
462466
return matrix;
463467
}
464468

469+
/**
470+
* Gets the `actions/checkout` step.
471+
*/
472+
function getCheckoutStep(): Step {
473+
return {
474+
name: "Check out repository",
475+
uses: pinnedUses(
476+
"actions/checkout",
477+
"3d3c42e5aac5ba805825da76410c181273ba90b1",
478+
"v7.0.1",
479+
),
480+
};
481+
}
482+
465483
/**
466484
* Retrieves setup steps and additional input definitions based on specific languages or frameworks
467485
* that are requested by the `checkSpecification`.
@@ -531,14 +549,7 @@ function generateJob(
531549

532550
// Construct the workflow steps needed for this check.
533551
const steps: Step[] = [
534-
{
535-
name: "Check out repository",
536-
uses: pinnedUses(
537-
"actions/checkout",
538-
"3d3c42e5aac5ba805825da76410c181273ba90b1",
539-
"v7.0.1",
540-
),
541-
},
552+
getCheckoutStep(),
542553
...setupInfo.steps,
543554
{
544555
name: "Prepare test",
@@ -609,13 +620,16 @@ function generateJob(
609620
/** Generates a validation job. */
610621
function generateValidationJob(
611622
specDocument: yaml.Document,
612-
jobSpecification: JobSpecification,
623+
jobSpecification: ValidationJobSpecification,
613624
checkName: string,
614625
name: string,
615626
) {
616627
// Determine which languages or frameworks have to be installed.
617628
const { inputs, steps } = getSetupSteps(jobSpecification);
618629

630+
// Construct a checkout step if requested.
631+
const checkoutStep = jobSpecification.checkout ? [getCheckoutStep()] : [];
632+
619633
// Extract the sequence of steps from the YAML document to persist as much formatting as possible.
620634
const specSteps = specDocument.getIn([
621635
"validationJobs",
@@ -624,7 +638,7 @@ function generateValidationJob(
624638
]) as yaml.YAMLSeq;
625639

626640
// Add the generated steps in front of the ones from the specification.
627-
specSteps.items.unshift(...steps);
641+
specSteps.items.unshift(...checkoutStep, ...steps);
628642

629643
const validationJob: Record<string, any> = {
630644
name: jobSpecification.name,
@@ -635,7 +649,7 @@ function generateValidationJob(
635649
"security-events": "read",
636650
},
637651
"timeout-minutes": 5,
638-
"runs-on": "ubuntu-slim",
652+
"runs-on": "ubuntu-latest",
639653
steps: specSteps,
640654
};
641655

0 commit comments

Comments
 (0)