Install npm dependencies where necessary in generated workflows

This commit is contained in:
Henry Mercer
2025-08-21 16:27:50 +01:00
parent f8c0d73f71
commit 879c788b45
31 changed files with 104 additions and 38 deletions

View File

@@ -41,6 +41,13 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v5
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
- name: Install dependencies
run: npm install
- name: Prepare test
id: prepare-test
uses: ./.github/actions/prepare-test

View File

@@ -67,6 +67,13 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v5
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
- name: Install dependencies
run: npm install
- name: Prepare test
id: prepare-test
uses: ./.github/actions/prepare-test

View File

@@ -67,6 +67,13 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v5
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
- name: Install dependencies
run: npm install
- name: Prepare test
id: prepare-test
uses: ./.github/actions/prepare-test

View File

@@ -67,6 +67,13 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v5
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
- name: Install dependencies
run: npm install
- name: Prepare test
id: prepare-test
uses: ./.github/actions/prepare-test

View File

@@ -67,6 +67,13 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v5
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
- name: Install dependencies
run: npm install
- name: Prepare test
id: prepare-test
uses: ./.github/actions/prepare-test

View File

@@ -3,7 +3,7 @@ description: "Tests using an all-platform CodeQL Bundle"
versions: ["nightly-latest"]
operatingSystems: ["ubuntu"]
useAllPlatformBundle: "true"
installGo: "true"
installGo: true
steps:
- id: init
uses: ./../action/init

View File

@@ -1,7 +1,7 @@
name: "Analyze: 'ref' and 'sha' from inputs"
description: "Checks that specifying 'ref' and 'sha' as inputs works"
versions: ["default"]
installGo: "true"
installGo: true
steps:
- uses: ./../action/init
with:

View File

@@ -2,7 +2,7 @@ name: "Build mode manual"
description: "An end-to-end integration test of a Java repository built using 'build-mode: manual'"
operatingSystems: ["ubuntu"]
versions: ["nightly-latest"]
installGo: "true"
installGo: true
steps:
- uses: ./../action/init
id: init

View File

@@ -1,5 +1,6 @@
name: "Config input"
description: "Tests specifying configuration using the config input"
installNode: true
operatingSystems: ["ubuntu"]
versions: ["linked"]
steps:

View File

@@ -1,7 +1,7 @@
name: "Export file baseline information"
description: "Tests that file baseline information is exported when the feature is enabled"
versions: ["nightly-latest"]
installGo: "true"
installGo: true
env:
CODEQL_ACTION_SUBLANGUAGE_FILE_COVERAGE: true
steps:

View File

@@ -6,7 +6,7 @@ operatingSystems:
versions:
- linked
- nightly-latest
installGo: "true"
installGo: true
env:
DOTNET_GENERATE_ASPNET_CERTIFICATE: "false"
steps:

View File

@@ -4,7 +4,7 @@ description: "Checks that we emit a diagnostic if Go is changed after the init s
operatingSystems: ["ubuntu"]
# pinned to a version which does not support statically linked binaries for indirect tracing
versions: ["default"]
installGo: "true"
installGo: true
collection: go
steps:
- uses: ./../action/init

View File

@@ -4,7 +4,7 @@ description: "Checks that we emit a diagnostic if the `file` program is not inst
operatingSystems: ["ubuntu"]
# pinned to a version which does not support statically linked binaries for indirect tracing
versions: ["default"]
installGo: "true"
installGo: true
collection: go
steps:
- name: Remove `file` program

View File

@@ -4,7 +4,7 @@ description: "Checks that our workaround for indirect tracing for Go 1.21+ on Li
operatingSystems: ["ubuntu"]
# pinned to a version which does not support statically linked binaries for indirect tracing
versions: ["default"]
installGo: "true"
installGo: true
collection: go
steps:
- uses: ./../action/init

View File

@@ -4,7 +4,7 @@ collection: go
operatingSystems: ["ubuntu", "macos"]
env:
DOTNET_GENERATE_ASPNET_CERTIFICATE: "false"
installGo: "true"
installGo: true
steps:
- uses: ./../action/init
with:

View File

@@ -2,7 +2,7 @@ name: "Go: tracing with custom build steps"
description: "Checks that Go tracing traces the build when using custom build steps"
collection: go
operatingSystems: ["ubuntu", "macos"]
installGo: "true"
installGo: true
steps:
- uses: ./../action/init
with:

View File

@@ -4,7 +4,7 @@ collection: go
operatingSystems: ["ubuntu", "macos"]
env:
DOTNET_GENERATE_ASPNET_CERTIFICATE: "false"
installGo: "true"
installGo: true
steps:
- uses: ./../action/init
with:

View File

@@ -1,7 +1,7 @@
name: "Multi-language repository"
description: "An end-to-end integration test of a multi-language repository using automatic language detection for macOS"
operatingSystems: ["macos", "ubuntu"]
installGo: "true"
installGo: true
steps:
- uses: ./../action/init
id: init

View File

@@ -1,7 +1,8 @@
name: "Packaging: Config and input passed to the CLI"
description: "Checks that specifying packages using a combination of a config file and input to the Action works"
versions: ["linked", "default", "nightly-latest"] # This feature is not compatible with old CLIs
installGo: "true"
installGo: true
installNode: true
steps:
- uses: ./../action/init
with:

View File

@@ -1,7 +1,8 @@
name: "Packaging: Config and input"
description: "Checks that specifying packages using a combination of a config file and input to the Action works"
versions: ["linked", "default", "nightly-latest"] # This feature is not compatible with old CLIs
installGo: "true"
installGo: true
installNode: true
steps:
- uses: ./../action/init
with:

View File

@@ -1,7 +1,8 @@
name: "Packaging: Config file"
description: "Checks that specifying packages using only a config file works"
versions: ["linked", "default", "nightly-latest"] # This feature is not compatible with old CLIs
installGo: "true"
installGo: true
installNode: true
steps:
- uses: ./../action/init
with:

View File

@@ -1,7 +1,8 @@
name: "Packaging: Action input"
description: "Checks that specifying packages using the input to the Action works"
versions: ["linked", "default", "nightly-latest"] # This feature is not compatible with old CLIs
installGo: "true"
installGo: true
installNode: true
steps:
- uses: ./../action/init
with:

View File

@@ -5,7 +5,7 @@ operatingSystems:
versions:
- linked
- nightly-latest
installGo: "true"
installGo: true
steps:
- uses: ./../action/init
with:

View File

@@ -2,7 +2,7 @@ name: "Split workflow"
description: "Tests a split-up workflow in which we first build a database and later analyze it"
operatingSystems: ["ubuntu", "macos"]
versions: ["linked", "default", "nightly-latest"] # This feature is not compatible with old CLIs
installGo: "true"
installGo: true
steps:
- uses: ./../action/init
with:

View File

@@ -2,7 +2,7 @@ name: "Swift analysis using a custom build command"
description: "Tests creation of a Swift database using custom build"
versions: ["linked", "default", "nightly-latest"]
operatingSystems: ["macos"]
installGo: "true"
installGo: true
env:
DOTNET_GENERATE_ASPNET_CERTIFICATE: "false"
steps:

View File

@@ -2,7 +2,7 @@ name: "Local CodeQL bundle"
description: "Tests using a CodeQL bundle from a local file rather than a URL"
versions: ["nightly-latest"]
operatingSystems: ["ubuntu"]
installGo: "true"
installGo: true
steps:
- name: Fetch a CodeQL bundle
shell: bash

View File

@@ -5,7 +5,7 @@ operatingSystems:
versions:
- linked
- nightly-latest
installGo: "true"
installGo: true
steps:
- uses: ./../action/init
id: init

View File

@@ -1,7 +1,7 @@
name: "Upload-sarif: code quality endpoint"
description: "Checks that uploading SARIFs to the code quality endpoint works"
versions: ["default"]
installGo: "true"
installGo: true
steps:
- uses: ./../action/init
with:

View File

@@ -1,7 +1,7 @@
name: "Upload-sarif: 'ref' and 'sha' from inputs"
description: "Checks that specifying 'ref' and 'sha' as inputs works"
versions: ["default"]
installGo: "true"
installGo: true
steps:
- uses: ./../action/init
with:

View File

@@ -1,7 +1,7 @@
name: "Use a custom `checkout_path`"
description: "Checks that a custom `checkout_path` will find the proper commit_oid"
versions: ["linked"]
installGo: "true"
installGo: true
steps:
# This ensures we don't accidentally use the original checkout for any part of the test.
- name: Delete original checkout

View File

@@ -44,6 +44,13 @@ header = """# Warning: This file is generated automatically, and should not be m
"""
def is_truthy(value):
if isinstance(value, str):
return value.lower() == 'true'
return bool(value)
class NonAliasingRTRepresenter(ruamel.yaml.representer.RoundTripRepresenter):
def ignore_aliases(self, data):
return True
@@ -100,21 +107,40 @@ for file in sorted((this_dir / 'checks').glob('*.yml')):
'name': 'Check out repository',
'uses': 'actions/checkout@v5'
},
{
'name': 'Prepare test',
'id': 'prepare-test',
'uses': './.github/actions/prepare-test',
'with': {
'version': '${{ matrix.version }}',
'use-all-platform-bundle': useAllPlatformBundle,
# If the action is being run from a container, then do not setup kotlin.
# This is because the kotlin binaries cannot be downloaded from the container.
'setup-kotlin': str(not 'container' in checkSpecification).lower(),
}
},
]
installGo = checkSpecification.get('installGo', '').lower() == 'true'
installNode = is_truthy(checkSpecification.get('installNode', ''))
if installNode:
steps.extend([
{
'name': 'Install Node.js',
'uses': 'actions/setup-node@v4',
'with': {
'node-version': '20.x',
'cache': 'npm',
},
},
{
'name': 'Install dependencies',
'run': 'npm install',
},
])
steps.append({
'name': 'Prepare test',
'id': 'prepare-test',
'uses': './.github/actions/prepare-test',
'with': {
'version': '${{ matrix.version }}',
'use-all-platform-bundle': useAllPlatformBundle,
# If the action is being run from a container, then do not setup kotlin.
# This is because the kotlin binaries cannot be downloaded from the container.
'setup-kotlin': str(not 'container' in checkSpecification).lower(),
}
})
installGo = is_truthy(checkSpecification.get('installGo', ''))
if installGo:
baseGoVersionExpr = '>=1.21.0'
@@ -136,7 +162,7 @@ for file in sorted((this_dir / 'checks').glob('*.yml')):
}
})
installJava = checkSpecification.get('installJava', '').lower() == 'true'
installJava = is_truthy(checkSpecification.get('installJava', ''))
if installJava:
baseJavaVersionExpr = '17'