mirror of
https://github.com/github/codeql-action.git
synced 2026-05-27 17:04:46 +00:00
Compare commits
149 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 95152f814a | |||
| f34cadbf2a | |||
| dda23c79a8 | |||
| 5fb81ae73e | |||
| eeaa56bdbb | |||
| bee9891358 | |||
| f4d0a7abf7 | |||
| f62fbc9627 | |||
| 2a7340616e | |||
| 3b0e64cb09 | |||
| 0a7280a837 | |||
| b79a976789 | |||
| eb9a790d15 | |||
| b8baf41834 | |||
| 5e9ae56429 | |||
| 8442bc0af9 | |||
| 26a1e570a6 | |||
| 9665bc2f5a | |||
| fcc1e3197f | |||
| c8a3492b26 | |||
| e94195c896 | |||
| 05e8f288eb | |||
| b71f5aebfc | |||
| 2365a46087 | |||
| cf51dca1af | |||
| b30a935ea5 | |||
| 5b815f25ca | |||
| 93c8a9ed99 | |||
| 2a02de1a14 | |||
| 67f403822c | |||
| bbef5ff663 | |||
| 7187b6ecc7 | |||
| f1ce9f4421 | |||
| 06c7e6fdd5 | |||
| 9e0d7b8d25 | |||
| 6d7d59927c | |||
| 51f7e38c69 | |||
| b43bb7bd69 | |||
| 064674dfa3 | |||
| ab5047bf8f | |||
| 2320f9d058 | |||
| 46959216a2 | |||
| 9e1f914560 | |||
| db84cb5ccb | |||
| d4b485515e | |||
| 931147e852 | |||
| 127de8117f | |||
| 7fde13f26a | |||
| dfa61e7305 | |||
| 52aafec073 | |||
| 0d08c01f78 | |||
| 1b65777c19 | |||
| 14085a675c | |||
| a32db48565 | |||
| aa005faaad | |||
| fcdf5dd4cf | |||
| e8d3fa290e | |||
| eb17ca4f4d | |||
| a41c444cd9 | |||
| d7e50c23fe | |||
| bb30f3132d | |||
| 336884853e | |||
| 2f137c9dc6 | |||
| 4795ef8153 | |||
| f0489abddd | |||
| 2e202367c7 | |||
| 9d7243005b | |||
| 237b03b3c3 | |||
| d4eab006fa | |||
| ea37b337cd | |||
| ba0a2f91b7 | |||
| 4041a11865 | |||
| 2a6fe1608c | |||
| 3c8c0ae6cb | |||
| 93d215d874 | |||
| 4235601f6f | |||
| 3d6ea97f26 | |||
| 7d25a3e590 | |||
| 4dc72761a6 | |||
| 9c3aedb4cd | |||
| a66f7bbb5a | |||
| b986640672 | |||
| a333d64ec4 | |||
| 97fb30df6b | |||
| d122da3c9f | |||
| de3e561d12 | |||
| c559992c9e | |||
| 6a4e35fad9 | |||
| 8d217609b0 | |||
| 257b3d3fc8 | |||
| 201a96b541 | |||
| 312a2fee96 | |||
| 2ca0fbdca8 | |||
| 12c1d88854 | |||
| 70419e3273 | |||
| b62aaa99a5 | |||
| 2f2dbd2e78 | |||
| b4ea7aa65a | |||
| 87ac48dae6 | |||
| 42d7f62579 | |||
| 540699dcca | |||
| 9a85234875 | |||
| 2a950b930c | |||
| 4f815a68d3 | |||
| 0aedbb71d8 | |||
| 868e2ea564 | |||
| 792c223bc1 | |||
| efc9b0a9e3 | |||
| 272ada693f | |||
| 610a6682b6 | |||
| 1627096569 | |||
| 68bde559de | |||
| 9739ad2d18 | |||
| b81d0d250f | |||
| a16cb53dd8 | |||
| 803d9e8c3c | |||
| 0c80cee806 | |||
| d032ee8c47 | |||
| 0fd9c7d135 | |||
| 922d6fb888 | |||
| df77e87896 | |||
| 6e3f985e4f | |||
| e7a347dfb1 | |||
| 17eabb2500 | |||
| aaef09c48d | |||
| ae1b9155d3 | |||
| 9f82f88f07 | |||
| 7525c68ea1 | |||
| 01bc9be56a | |||
| 9d6b456c59 | |||
| e259d26055 | |||
| 817b68489e | |||
| 1b5632783c | |||
| 1848b73afa | |||
| d1e9792bc8 | |||
| 2c9cd77837 | |||
| b967fdfbdc | |||
| 55d6319f96 | |||
| b0942116d7 | |||
| a796e3e4ed | |||
| 8ab64a211d | |||
| f8b93c30a6 | |||
| 80a72986d3 | |||
| e9e36aec74 | |||
| 4ed52dcbfa | |||
| 3cc8dd3e59 | |||
| 5ded561dcd | |||
| faca00d3ae | |||
| 5d1c58464f |
@@ -41,7 +41,38 @@ runs:
|
|||||||
git add .
|
git add .
|
||||||
git commit -m "Update changelog and version after ${VERSION}"
|
git commit -m "Update changelog and version after ${VERSION}"
|
||||||
|
|
||||||
git push origin "${NEW_BRANCH}"
|
# Update the build artifacts with the new version number
|
||||||
|
- name: Rebuild the Action
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -exu
|
||||||
|
npm ci
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
- name: Check for rebuild changes
|
||||||
|
id: rebuild_changes
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -exu
|
||||||
|
git add --all
|
||||||
|
if git diff --cached --quiet; then
|
||||||
|
echo "has_changes=false" >> "${GITHUB_OUTPUT}"
|
||||||
|
else
|
||||||
|
echo "has_changes=true" >> "${GITHUB_OUTPUT}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Commit rebuild
|
||||||
|
if: steps.rebuild_changes.outputs.has_changes == 'true'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -exu
|
||||||
|
git commit -m "Rebuild"
|
||||||
|
|
||||||
|
- name: Push mergeback branch
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
NEW_BRANCH: "${{ inputs.branch }}"
|
||||||
|
run: git push origin "${NEW_BRANCH}"
|
||||||
|
|
||||||
- name: Create PR
|
- name: Create PR
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -60,8 +91,6 @@ runs:
|
|||||||
|
|
||||||
Please do the following:
|
Please do the following:
|
||||||
|
|
||||||
- [ ] Remove and re-add the "Rebuild" label to the PR to trigger just this workflow.
|
|
||||||
- [ ] Wait for the "Rebuild" workflow to push a commit updating the distribution files.
|
|
||||||
- [ ] Mark the PR as ready for review to trigger the full set of PR checks.
|
- [ ] Mark the PR as ready for review to trigger the full set of PR checks.
|
||||||
- [ ] Approve and merge the PR. When merging the PR, make sure "Create a merge commit" is
|
- [ ] Approve and merge the PR. When merging the PR, make sure "Create a merge commit" is
|
||||||
selected rather than "Squash and merge" or "Rebase and merge".
|
selected rather than "Squash and merge" or "Rebase and merge".
|
||||||
@@ -74,7 +103,6 @@ runs:
|
|||||||
--head "${NEW_BRANCH}" \
|
--head "${NEW_BRANCH}" \
|
||||||
--base "${BASE_BRANCH}" \
|
--base "${BASE_BRANCH}" \
|
||||||
--title "${pr_title}" \
|
--title "${pr_title}" \
|
||||||
--label "Rebuild" \
|
|
||||||
--body "${pr_body}" \
|
--body "${pr_body}" \
|
||||||
--assignee "${GITHUB_ACTOR}" \
|
--assignee "${GITHUB_ACTOR}" \
|
||||||
--draft
|
--draft
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ runs:
|
|||||||
- name: Set up Node
|
- name: Set up Node
|
||||||
uses: actions/setup-node@v6
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: 20
|
node-version: 24
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
|
|||||||
@@ -16,12 +16,27 @@ No user facing changes.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# NB: This exact commit message is used to find commits for reverting during backports.
|
# NB: This exact commit message is used to find commits for reverting during backports.
|
||||||
# Changing it requires a transition period where both old and new versions are supported.
|
# Changing it requires a transition period where both old and new versions are supported.
|
||||||
BACKPORT_COMMIT_MESSAGE = 'Update version and changelog for v'
|
BACKPORT_COMMIT_MESSAGE = 'Update version and changelog for v'
|
||||||
|
|
||||||
|
# Commit message used for rebuild commits, both those produced by this script and those produced
|
||||||
|
# by the `Rebuild Action` workflow (`.github/workflows/rebuild.yml`).
|
||||||
|
REBUILD_COMMIT_MESSAGE = 'Rebuild'
|
||||||
|
|
||||||
# Name of the remote
|
# Name of the remote
|
||||||
ORIGIN = 'origin'
|
ORIGIN = 'origin'
|
||||||
|
|
||||||
|
# Environment variables to check for a GitHub API token.
|
||||||
|
TOKEN_ENVIRONMENT_VARIABLES = ('GH_TOKEN', 'GITHUB_TOKEN')
|
||||||
|
|
||||||
|
# Gets a GitHub API token from one of the supported environment variables.
|
||||||
|
def get_github_token():
|
||||||
|
for variable_name in TOKEN_ENVIRONMENT_VARIABLES:
|
||||||
|
token = os.environ.get(variable_name, '').strip()
|
||||||
|
if token:
|
||||||
|
return token
|
||||||
|
raise Exception('Missing GitHub token. Set GITHUB_TOKEN or GH_TOKEN.')
|
||||||
|
|
||||||
# Runs git with the given args and returns the stdout.
|
# Runs git with the given args and returns the stdout.
|
||||||
# Raises an error if git does not exit successfully (unless passed
|
# Raises an error if git does not exit successfully (unless passed
|
||||||
# allow_non_zero_exit_code=True).
|
# allow_non_zero_exit_code=True).
|
||||||
@@ -32,6 +47,28 @@ def run_git(*args, allow_non_zero_exit_code=False):
|
|||||||
raise Exception(f'Call to {" ".join(cmd)} exited with code {p.returncode} stderr: {p.stderr.decode("ascii")}.')
|
raise Exception(f'Call to {" ".join(cmd)} exited with code {p.returncode} stderr: {p.stderr.decode("ascii")}.')
|
||||||
return p.stdout.decode('ascii')
|
return p.stdout.decode('ascii')
|
||||||
|
|
||||||
|
# Runs the given command, streaming output to the console.
|
||||||
|
# Raises an error if the command does not exit successfully.
|
||||||
|
def run_command(*args):
|
||||||
|
cmd = list(args)
|
||||||
|
print(f'Running `{" ".join(cmd)}`.')
|
||||||
|
subprocess.run(cmd, check=True)
|
||||||
|
|
||||||
|
# Rebuilds the action and commits any changes.
|
||||||
|
def rebuild_action():
|
||||||
|
# For backports, the only source-level change vs the source branch is the new version number,
|
||||||
|
# so we just need to refresh the version embedded in `lib/`.
|
||||||
|
run_command('npm', 'ci')
|
||||||
|
run_command('npm', 'run', 'build')
|
||||||
|
|
||||||
|
run_git('add', '--all')
|
||||||
|
# `git diff --cached --quiet` exits 0 if there are no staged changes, 1 if there are.
|
||||||
|
if subprocess.run(['git', 'diff', '--cached', '--quiet']).returncode == 0:
|
||||||
|
print('Rebuild produced no changes; skipping Rebuild commit.')
|
||||||
|
else:
|
||||||
|
run_git('commit', '-m', REBUILD_COMMIT_MESSAGE)
|
||||||
|
print('Created Rebuild commit.')
|
||||||
|
|
||||||
# Returns true if the given branch exists on the origin remote
|
# Returns true if the given branch exists on the origin remote
|
||||||
def branch_exists_on_remote(branch_name):
|
def branch_exists_on_remote(branch_name):
|
||||||
return run_git('ls-remote', '--heads', ORIGIN, branch_name).strip() != ''
|
return run_git('ls-remote', '--heads', ORIGIN, branch_name).strip() != ''
|
||||||
@@ -87,9 +124,11 @@ def open_pr(
|
|||||||
body.append('Please do the following:')
|
body.append('Please do the following:')
|
||||||
if len(conflicted_files) > 0:
|
if len(conflicted_files) > 0:
|
||||||
body.append(' - [ ] Ensure `package.json` file contains the correct version.')
|
body.append(' - [ ] Ensure `package.json` file contains the correct version.')
|
||||||
body.append(' - [ ] Add commits to this branch to resolve the merge conflicts ' +
|
body.append(' - [ ] Add a commit to this branch to resolve the merge conflicts ' +
|
||||||
'in the following files:')
|
'in the following files:')
|
||||||
body.extend([f' - [ ] `{file}`' for file in conflicted_files])
|
body.extend([f' - `{file}`' for file in conflicted_files])
|
||||||
|
body.append(' - [ ] Rebuild the Action locally (`npm run build`) and push any changes to the ' +
|
||||||
|
f'built output in `lib` as a separate commit named exactly `{REBUILD_COMMIT_MESSAGE}`.')
|
||||||
body.append(' - [ ] Ensure another maintainer has reviewed the additional commits you added to this ' +
|
body.append(' - [ ] Ensure another maintainer has reviewed the additional commits you added to this ' +
|
||||||
'branch to resolve the merge conflicts.')
|
'branch to resolve the merge conflicts.')
|
||||||
body.append(' - [ ] Ensure the CHANGELOG displays the correct version and date.')
|
body.append(' - [ ] Ensure the CHANGELOG displays the correct version and date.')
|
||||||
@@ -97,10 +136,6 @@ def open_pr(
|
|||||||
body.append(f' - [ ] Check that there are not any unexpected commits being merged into the `{target_branch}` branch.')
|
body.append(f' - [ ] Check that there are not any unexpected commits being merged into the `{target_branch}` branch.')
|
||||||
body.append(' - [ ] Ensure the docs team is aware of any documentation changes that need to be released.')
|
body.append(' - [ ] Ensure the docs team is aware of any documentation changes that need to be released.')
|
||||||
|
|
||||||
if not is_primary_release:
|
|
||||||
body.append(' - [ ] Remove and re-add the "Rebuild" label to the PR to trigger just this workflow.')
|
|
||||||
body.append(' - [ ] Wait for the "Rebuild" workflow to push a commit updating the distribution files.')
|
|
||||||
|
|
||||||
body.append(' - [ ] Mark the PR as ready for review to trigger the full set of PR checks.')
|
body.append(' - [ ] Mark the PR as ready for review to trigger the full set of PR checks.')
|
||||||
body.append(' - [ ] Approve and merge this PR. Make sure `Create a merge commit` is selected rather than `Squash and merge` or `Rebase and merge`.')
|
body.append(' - [ ] Approve and merge this PR. Make sure `Create a merge commit` is selected rather than `Squash and merge` or `Rebase and merge`.')
|
||||||
|
|
||||||
@@ -109,13 +144,11 @@ def open_pr(
|
|||||||
body.append(' - [ ] Merge all backport PRs to older release branches, that will automatically be created once this PR is merged.')
|
body.append(' - [ ] Merge all backport PRs to older release branches, that will automatically be created once this PR is merged.')
|
||||||
|
|
||||||
title = f'Merge {source_branch} into {target_branch}'
|
title = f'Merge {source_branch} into {target_branch}'
|
||||||
labels = ['Rebuild'] if not is_primary_release else []
|
|
||||||
|
|
||||||
# Create the pull request
|
# Create the pull request
|
||||||
# PR checks won't be triggered on PRs created by Actions. Therefore mark the PR as draft so that
|
# PR checks won't be triggered on PRs created by Actions. Therefore mark the PR as draft so that
|
||||||
# a maintainer can take the PR out of draft, thereby triggering the PR checks.
|
# a maintainer can take the PR out of draft, thereby triggering the PR checks.
|
||||||
pr = repo.create_pull(title=title, body='\n'.join(body), head=new_branch_name, base=target_branch, draft=True)
|
pr = repo.create_pull(title=title, body='\n'.join(body), head=new_branch_name, base=target_branch, draft=True)
|
||||||
pr.add_to_labels(*labels)
|
|
||||||
print(f'Created PR #{str(pr.number)}')
|
print(f'Created PR #{str(pr.number)}')
|
||||||
|
|
||||||
# Assign the conductor
|
# Assign the conductor
|
||||||
@@ -270,12 +303,6 @@ def update_changelog(version):
|
|||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser('update-release-branch.py')
|
parser = argparse.ArgumentParser('update-release-branch.py')
|
||||||
|
|
||||||
parser.add_argument(
|
|
||||||
'--github-token',
|
|
||||||
type=str,
|
|
||||||
required=True,
|
|
||||||
help='GitHub token, typically from GitHub Actions.'
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--repository-nwo',
|
'--repository-nwo',
|
||||||
type=str,
|
type=str,
|
||||||
@@ -313,7 +340,7 @@ def main():
|
|||||||
target_branch = args.target_branch
|
target_branch = args.target_branch
|
||||||
is_primary_release = args.is_primary_release
|
is_primary_release = args.is_primary_release
|
||||||
|
|
||||||
repo = Github(args.github_token).get_repo(args.repository_nwo)
|
repo = Github(get_github_token()).get_repo(args.repository_nwo)
|
||||||
|
|
||||||
# the target branch will be of the form releases/vN, where N is the major version number
|
# the target branch will be of the form releases/vN, where N is the major version number
|
||||||
target_branch_major_version = target_branch.strip('releases/v')
|
target_branch_major_version = target_branch.strip('releases/v')
|
||||||
@@ -380,8 +407,9 @@ def main():
|
|||||||
# releases.
|
# releases.
|
||||||
run_git('revert', vOlder_update_commits[0], '--no-edit')
|
run_git('revert', vOlder_update_commits[0], '--no-edit')
|
||||||
|
|
||||||
# Also revert the "Rebuild" commit created by Actions.
|
# Also revert the "Rebuild" commit, whether created by this script or by the
|
||||||
rebuild_commit = run_git('log', '--grep', '^Rebuild$', '--format=%H').split()[0]
|
# `Rebuild Action` workflow.
|
||||||
|
rebuild_commit = run_git('log', '--grep', f'^{REBUILD_COMMIT_MESSAGE}$', '--format=%H').split()[0]
|
||||||
print(f' Reverting {rebuild_commit}')
|
print(f' Reverting {rebuild_commit}')
|
||||||
run_git('revert', rebuild_commit, '--no-edit')
|
run_git('revert', rebuild_commit, '--no-edit')
|
||||||
|
|
||||||
@@ -396,9 +424,10 @@ def main():
|
|||||||
run_git('add', '.')
|
run_git('add', '.')
|
||||||
run_git('commit', '--no-edit')
|
run_git('commit', '--no-edit')
|
||||||
|
|
||||||
# Migrate the package version number from a vLatest version number to a vOlder version number
|
# Migrate the package version number from a vLatest version number to a vOlder version number.
|
||||||
|
# `package-lock.json` is updated as part of the subsequent rebuild step (see `rebuild_action`).
|
||||||
print(f'Setting version number to {version} in package.json')
|
print(f'Setting version number to {version} in package.json')
|
||||||
replace_version_package_json(get_current_version(), version) # We rely on the `Rebuild` workflow to update package-lock.json
|
replace_version_package_json(get_current_version(), version)
|
||||||
run_git('add', 'package.json')
|
run_git('add', 'package.json')
|
||||||
|
|
||||||
# Migrate the changelog notes from vLatest version numbers to vOlder version numbers
|
# Migrate the changelog notes from vLatest version numbers to vOlder version numbers
|
||||||
@@ -421,6 +450,13 @@ def main():
|
|||||||
run_git('add', 'CHANGELOG.md')
|
run_git('add', 'CHANGELOG.md')
|
||||||
run_git('commit', '-m', f'Update changelog for v{version}')
|
run_git('commit', '-m', f'Update changelog for v{version}')
|
||||||
|
|
||||||
|
if not is_primary_release:
|
||||||
|
if len(conflicted_files) == 0:
|
||||||
|
print('Rebuilding the Action.')
|
||||||
|
rebuild_action()
|
||||||
|
else:
|
||||||
|
print(f'Skipping automatic rebuild because the merge produced conflicts in {conflicted_files}.')
|
||||||
|
|
||||||
run_git('push', ORIGIN, new_branch_name)
|
run_git('push', ORIGIN, new_branch_name)
|
||||||
|
|
||||||
# Open a PR to update the branch
|
# Open a PR to update the branch
|
||||||
|
|||||||
+4
-4
@@ -49,10 +49,6 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-latest
|
|
||||||
version: stable-v2.17.6
|
|
||||||
- os: ubuntu-latest
|
|
||||||
version: stable-v2.18.4
|
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: stable-v2.19.4
|
version: stable-v2.19.4
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
@@ -61,6 +57,10 @@ jobs:
|
|||||||
version: stable-v2.21.4
|
version: stable-v2.21.4
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: stable-v2.22.4
|
version: stable-v2.22.4
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: stable-v2.23.9
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: stable-v2.24.3
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: default
|
version: default
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
|
|||||||
+4
-4
@@ -49,10 +49,6 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-latest
|
|
||||||
version: stable-v2.17.6
|
|
||||||
- os: ubuntu-latest
|
|
||||||
version: stable-v2.18.4
|
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: stable-v2.19.4
|
version: stable-v2.19.4
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
@@ -61,6 +57,10 @@ jobs:
|
|||||||
version: stable-v2.21.4
|
version: stable-v2.21.4
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: stable-v2.22.4
|
version: stable-v2.22.4
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: stable-v2.23.9
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: stable-v2.24.3
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: default
|
version: default
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
|
|||||||
+4
-4
@@ -49,10 +49,6 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-latest
|
|
||||||
version: stable-v2.17.6
|
|
||||||
- os: ubuntu-latest
|
|
||||||
version: stable-v2.18.4
|
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: stable-v2.19.4
|
version: stable-v2.19.4
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
@@ -61,6 +57,10 @@ jobs:
|
|||||||
version: stable-v2.21.4
|
version: stable-v2.21.4
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: stable-v2.22.4
|
version: stable-v2.22.4
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: stable-v2.23.9
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: stable-v2.24.3
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: default
|
version: default
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
|
|||||||
+15
-15
@@ -59,41 +59,41 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-latest
|
|
||||||
version: stable-v2.17.6
|
|
||||||
- os: macos-latest
|
|
||||||
version: stable-v2.17.6
|
|
||||||
- os: ubuntu-latest
|
|
||||||
version: stable-v2.18.4
|
|
||||||
- os: macos-latest
|
|
||||||
version: stable-v2.18.4
|
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: stable-v2.19.4
|
version: stable-v2.19.4
|
||||||
- os: macos-latest
|
- os: macos-latest-xlarge
|
||||||
version: stable-v2.19.4
|
version: stable-v2.19.4
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: stable-v2.20.7
|
version: stable-v2.20.7
|
||||||
- os: macos-latest
|
- os: macos-latest-xlarge
|
||||||
version: stable-v2.20.7
|
version: stable-v2.20.7
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: stable-v2.21.4
|
version: stable-v2.21.4
|
||||||
- os: macos-latest
|
- os: macos-latest-xlarge
|
||||||
version: stable-v2.21.4
|
version: stable-v2.21.4
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: stable-v2.22.4
|
version: stable-v2.22.4
|
||||||
- os: macos-latest
|
- os: macos-latest-xlarge
|
||||||
version: stable-v2.22.4
|
version: stable-v2.22.4
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: stable-v2.23.9
|
||||||
|
- os: macos-latest-xlarge
|
||||||
|
version: stable-v2.23.9
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: stable-v2.24.3
|
||||||
|
- os: macos-latest-xlarge
|
||||||
|
version: stable-v2.24.3
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: default
|
version: default
|
||||||
- os: macos-latest
|
- os: macos-latest-xlarge
|
||||||
version: default
|
version: default
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: linked
|
version: linked
|
||||||
- os: macos-latest
|
- os: macos-latest-xlarge
|
||||||
version: linked
|
version: linked
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: nightly-latest
|
version: nightly-latest
|
||||||
- os: macos-latest
|
- os: macos-latest-xlarge
|
||||||
version: nightly-latest
|
version: nightly-latest
|
||||||
name: Multi-language repository
|
name: Multi-language repository
|
||||||
if: github.triggering_actor != 'dependabot[bot]'
|
if: github.triggering_actor != 'dependabot[bot]'
|
||||||
|
|||||||
+1
-1
@@ -59,7 +59,7 @@ jobs:
|
|||||||
use-all-platform-bundle: 'false'
|
use-all-platform-bundle: 'false'
|
||||||
setup-kotlin: 'true'
|
setup-kotlin: 'true'
|
||||||
- name: Set up Ruby
|
- name: Set up Ruby
|
||||||
uses: ruby/setup-ruby@0cb964fd540e0a24c900370abf38a33466142735 # v1.305.0
|
uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1.306.0
|
||||||
with:
|
with:
|
||||||
ruby-version: 2.6
|
ruby-version: 2.6
|
||||||
- name: Install Code Scanning integration
|
- name: Install Code Scanning integration
|
||||||
|
|||||||
Generated
+1
-1
@@ -40,7 +40,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: stable-v2.19.3
|
version: stable-v2.19.4
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: stable-v2.22.1
|
version: stable-v2.22.1
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
|
|||||||
Generated
+1
-1
@@ -39,7 +39,7 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: macos-latest
|
- os: macos-latest-xlarge
|
||||||
version: nightly-latest
|
version: nightly-latest
|
||||||
name: Swift analysis using autobuild
|
name: Swift analysis using autobuild
|
||||||
if: github.triggering_actor != 'dependabot[bot]'
|
if: github.triggering_actor != 'dependabot[bot]'
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-22.04,ubuntu-24.04,windows-2022,windows-2025,macos-14,macos-15]
|
os: [ubuntu-22.04,ubuntu-24.04,windows-2022,windows-2025,macos-14-xlarge,macos-15-xlarge]
|
||||||
tools: ${{ fromJson(needs.check-codeql-versions.outputs.versions) }}
|
tools: ${{ fromJson(needs.check-codeql-versions.outputs.versions) }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,6 @@ env:
|
|||||||
# Diff informed queries add an additional query filter which is not yet
|
# Diff informed queries add an additional query filter which is not yet
|
||||||
# taken into account by these tests.
|
# taken into account by these tests.
|
||||||
CODEQL_ACTION_DIFF_INFORMED_QUERIES: false
|
CODEQL_ACTION_DIFF_INFORMED_QUERIES: false
|
||||||
# Specify overlay enablement manually to ensure stability around the exclude-from-incremental
|
|
||||||
# query filter. Here we only enable for the default code scanning suite.
|
|
||||||
CODEQL_ACTION_OVERLAY_ANALYSIS: true
|
|
||||||
CODEQL_ACTION_OVERLAY_ANALYSIS_JAVASCRIPT: false
|
|
||||||
CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_JAVASCRIPT: true
|
|
||||||
CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK: false
|
|
||||||
CODEQL_ACTION_OVERLAY_ANALYSIS_SKIP_RESOURCE_CHECKS: true
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -79,33 +72,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
version: ${{ matrix.version }}
|
version: ${{ matrix.version }}
|
||||||
|
|
||||||
# On PRs, overlay analysis may change the config that is passed to the CLI.
|
- name: Empty file
|
||||||
# Therefore, we have two variants of the following test, one for PRs and one for other events.
|
|
||||||
- name: Empty file (non-PR)
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: ./../action/.github/actions/check-codescanning-config
|
uses: ./../action/.github/actions/check-codescanning-config
|
||||||
with:
|
with:
|
||||||
expected-config-file-contents: "{}"
|
expected-config-file-contents: "{}"
|
||||||
languages: javascript
|
languages: javascript
|
||||||
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
|
|
||||||
- name: Empty file (PR)
|
|
||||||
if: github.event_name == 'pull_request'
|
|
||||||
uses: ./../action/.github/actions/check-codescanning-config
|
|
||||||
with:
|
|
||||||
expected-config-file-contents: |
|
|
||||||
{
|
|
||||||
"query-filters": [
|
|
||||||
{
|
|
||||||
"exclude": {
|
|
||||||
"tags": "exclude-from-incremental"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
languages: javascript
|
|
||||||
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
|
||||||
|
|
||||||
- name: Packs from input
|
- name: Packs from input
|
||||||
if: success() || failure()
|
if: success() || failure()
|
||||||
uses: ./../action/.github/actions/check-codescanning-config
|
uses: ./../action/.github/actions/check-codescanning-config
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0 # ensure we have all tags and can push commits
|
fetch-depth: 0 # ensure we have all tags and can push commits
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
cache: 'npm'
|
||||||
- uses: actions/setup-python@v6
|
- uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: '3.12'
|
python-version: '3.12'
|
||||||
@@ -131,7 +134,7 @@ jobs:
|
|||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
- name: Generate token
|
- name: Generate token
|
||||||
uses: actions/create-github-app-token@v3.1.1
|
uses: actions/create-github-app-token@v3.2.0
|
||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
app-id: ${{ vars.AUTOMATION_APP_ID }}
|
app-id: ${{ vars.AUTOMATION_APP_ID }}
|
||||||
|
|||||||
@@ -105,10 +105,10 @@ jobs:
|
|||||||
run: npx tsx --test
|
run: npx tsx --test
|
||||||
|
|
||||||
check-node-version:
|
check-node-version:
|
||||||
if: github.triggering_actor != 'dependabot[bot]'
|
if: github.triggering_actor != 'dependabot[bot]' && startsWith(github.head_ref, 'backport-')
|
||||||
name: Check Action Node versions
|
name: Check Action Node versions for Backport
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 45
|
timeout-minutes: 5
|
||||||
env:
|
env:
|
||||||
BASE_REF: ${{ github.base_ref }}
|
BASE_REF: ${{ github.base_ref }}
|
||||||
|
|
||||||
@@ -116,31 +116,40 @@ jobs:
|
|||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
- id: head-version
|
- id: head-version
|
||||||
name: Verify all Actions use the same Node version
|
name: Determine Node version for HEAD
|
||||||
run: |
|
run: |
|
||||||
NODE_VERSION=$(find . -name "action.yml" -exec yq -e '.runs.using' {} \; | grep node | sort | uniq)
|
if [[ ! -f ".nvmrc" ]]; then
|
||||||
echo "NODE_VERSION: ${NODE_VERSION}"
|
echo "::error::Cannot find .nvmrc in the HEAD commit."
|
||||||
if [[ $(echo "$NODE_VERSION" | wc -l) -gt 1 ]]; then
|
|
||||||
echo "::error::More than one node version used in 'action.yml' files."
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
NODE_VERSION=$(cat .nvmrc)
|
||||||
|
echo "NODE_VERSION: ${NODE_VERSION}"
|
||||||
echo "node_version=${NODE_VERSION}" >> $GITHUB_OUTPUT
|
echo "node_version=${NODE_VERSION}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- id: checkout-base
|
- id: checkout-base
|
||||||
name: 'Backport: Check out base ref'
|
name: 'Backport: Check out base ref'
|
||||||
if: ${{ startsWith(github.head_ref, 'backport-') }}
|
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
ref: ${{ env.BASE_REF }}
|
ref: ${{ env.BASE_REF }}
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
- name: 'Backport: Verify Node versions unchanged'
|
- name: 'Backport: Verify Node versions unchanged'
|
||||||
if: steps.checkout-base.outcome == 'success'
|
|
||||||
env:
|
env:
|
||||||
HEAD_VERSION: ${{ steps.head-version.outputs.node_version }}
|
HEAD_VERSION: ${{ steps.head-version.outputs.node_version }}
|
||||||
run: |
|
run: |
|
||||||
BASE_VERSION=$(find . -name "action.yml" -exec yq -e '.runs.using' {} \; | grep node | sort | uniq)
|
if [[ ! -f ".nvmrc" ]]; then
|
||||||
|
echo "::error::Cannot find .nvmrc in the base commit."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
BASE_VERSION=$(cat .nvmrc)
|
||||||
echo "HEAD_VERSION: ${HEAD_VERSION}"
|
echo "HEAD_VERSION: ${HEAD_VERSION}"
|
||||||
echo "BASE_VERSION: ${BASE_VERSION}"
|
echo "BASE_VERSION: ${BASE_VERSION}"
|
||||||
if [[ "$BASE_VERSION" != "$HEAD_VERSION" ]]; then
|
if [[ "$BASE_VERSION" != "$HEAD_VERSION" ]]; then
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Generate token
|
- name: Generate token
|
||||||
if: github.event_name == 'workflow_dispatch'
|
if: github.event_name == 'workflow_dispatch'
|
||||||
uses: actions/create-github-app-token@v3.1.1
|
uses: actions/create-github-app-token@v3.2.0
|
||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
app-id: ${{ vars.AUTOMATION_APP_ID }}
|
app-id: ${{ vars.AUTOMATION_APP_ID }}
|
||||||
|
|||||||
@@ -64,11 +64,12 @@ jobs:
|
|||||||
|
|
||||||
- name: Update current release branch
|
- name: Update current release branch
|
||||||
if: github.event_name == 'workflow_dispatch'
|
if: github.event_name == 'workflow_dispatch'
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
echo SOURCE_BRANCH=${REF_NAME}
|
echo SOURCE_BRANCH=${REF_NAME}
|
||||||
echo TARGET_BRANCH=releases/${MAJOR_VERSION}
|
echo TARGET_BRANCH=releases/${MAJOR_VERSION}
|
||||||
python .github/update-release-branch.py \
|
python .github/update-release-branch.py \
|
||||||
--github-token ${{ secrets.GITHUB_TOKEN }} \
|
|
||||||
--repository-nwo ${{ github.repository }} \
|
--repository-nwo ${{ github.repository }} \
|
||||||
--source-branch '${{ env.REF_NAME }}' \
|
--source-branch '${{ env.REF_NAME }}' \
|
||||||
--target-branch 'releases/${{ env.MAJOR_VERSION }}' \
|
--target-branch 'releases/${{ env.MAJOR_VERSION }}' \
|
||||||
@@ -93,7 +94,7 @@ jobs:
|
|||||||
pull-requests: write # needed to create pull request
|
pull-requests: write # needed to create pull request
|
||||||
steps:
|
steps:
|
||||||
- name: Generate token
|
- name: Generate token
|
||||||
uses: actions/create-github-app-token@v3.1.1
|
uses: actions/create-github-app-token@v3.2.0
|
||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
app-id: ${{ vars.AUTOMATION_APP_ID }}
|
app-id: ${{ vars.AUTOMATION_APP_ID }}
|
||||||
@@ -107,11 +108,12 @@ jobs:
|
|||||||
- uses: ./.github/actions/release-initialise
|
- uses: ./.github/actions/release-initialise
|
||||||
|
|
||||||
- name: Update older release branch
|
- name: Update older release branch
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
echo SOURCE_BRANCH=${SOURCE_BRANCH}
|
echo SOURCE_BRANCH=${SOURCE_BRANCH}
|
||||||
echo TARGET_BRANCH=${TARGET_BRANCH}
|
echo TARGET_BRANCH=${TARGET_BRANCH}
|
||||||
python .github/update-release-branch.py \
|
python .github/update-release-branch.py \
|
||||||
--github-token ${{ secrets.GITHUB_TOKEN }} \
|
|
||||||
--repository-nwo ${{ github.repository }} \
|
--repository-nwo ${{ github.repository }} \
|
||||||
--source-branch ${SOURCE_BRANCH} \
|
--source-branch ${SOURCE_BRANCH} \
|
||||||
--target-branch ${TARGET_BRANCH} \
|
--target-branch ${TARGET_BRANCH} \
|
||||||
|
|||||||
Vendored
+1
-1
@@ -19,7 +19,7 @@
|
|||||||
"scope": "javascript, typescript",
|
"scope": "javascript, typescript",
|
||||||
"prefix": "testMacro",
|
"prefix": "testMacro",
|
||||||
"body": [
|
"body": [
|
||||||
"const ${1:nameMacro} = test.macro({",
|
"const ${1:nameMacro} = makeMacro({",
|
||||||
" exec: async (t: ExecutionContext<unknown>) => {},",
|
" exec: async (t: ExecutionContext<unknown>) => {},",
|
||||||
"",
|
"",
|
||||||
" title: (providedTitle = \"\") => `${2:common title} - \\${providedTitle}`,",
|
" title: (providedTitle = \"\") => `${2:common title} - \\${providedTitle}`,",
|
||||||
|
|||||||
+13
-1
@@ -4,7 +4,19 @@ See the [releases page](https://github.com/github/codeql-action/releases) for th
|
|||||||
|
|
||||||
## [UNRELEASED]
|
## [UNRELEASED]
|
||||||
|
|
||||||
No user facing changes.
|
- _Breaking change_: Bump the minimum required CodeQL bundle version to 2.19.4. [#3894](https://github.com/github/codeql-action/pull/3894)
|
||||||
|
- Add support for SHA-256 Git object IDs. [#3893](https://github.com/github/codeql-action/pull/3893)
|
||||||
|
|
||||||
|
## 4.35.5 - 15 May 2026
|
||||||
|
|
||||||
|
- We have improved how the JavaScript bundles for the CodeQL Action are generated to avoid duplication across bundles and reduce the size of the repository by around 70%. This should have no effect on the runtime behaviour of the CodeQL Action. [#3899](https://github.com/github/codeql-action/pull/3899)
|
||||||
|
- For performance and accuracy reasons, [improved incremental analysis](https://github.com/github/roadmap/issues/1158) will now only be enabled on a pull request when diff-informed analysis is also enabled for that run. If diff-informed analysis is unavailable (for example, because the PR diff ranges could not be computed), the action will fall back to a full analysis. [#3791](https://github.com/github/codeql-action/pull/3791)
|
||||||
|
- If multiple inputs are provided for the GitHub-internal `analysis-kinds` input, only `code-scanning` will be enabled. The `analysis-kinds` input is experimental, for GitHub-internal use only, and may change without notice at any time. [#3892](https://github.com/github/codeql-action/pull/3892)
|
||||||
|
- Added an experimental change which, when running a Code Scanning analysis for a PR with [improved incremental analysis](https://github.com/github/roadmap/issues/1158) enabled, prefers CodeQL CLI versions that have a cached overlay-base database for the configured languages. This speeds up analysis for a repository when there is not yet a cached overlay-base database for the latest CLI version. We expect to roll this change out to everyone in May. [#3880](https://github.com/github/codeql-action/pull/3880)
|
||||||
|
|
||||||
|
## 4.35.4 - 07 May 2026
|
||||||
|
|
||||||
|
- Update default CodeQL bundle version to [2.25.4](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.25.4). [#3881](https://github.com/github/codeql-action/pull/3881)
|
||||||
|
|
||||||
## 4.35.3 - 01 May 2026
|
## 4.35.3 - 01 May 2026
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -71,7 +71,7 @@ Once the mergeback and backport pull request have been merged, the release is co
|
|||||||
|
|
||||||
Since the `codeql-action` runs most of its testing through individual Actions workflows, there are over two hundred required jobs that need to pass in order for a PR to turn green. It would be too tedious to maintain that list manually. You can regenerate the set of required checks automatically by running the [sync-checks.ts](pr-checks/sync-checks.ts) script:
|
Since the `codeql-action` runs most of its testing through individual Actions workflows, there are over two hundred required jobs that need to pass in order for a PR to turn green. It would be too tedious to maintain that list manually. You can regenerate the set of required checks automatically by running the [sync-checks.ts](pr-checks/sync-checks.ts) script:
|
||||||
|
|
||||||
- At a minimum, you must provide an argument for the `--token` input. For example, `--token "$(gh auth token)"` to use the same token that `gh` uses. If no token is provided or the token has insufficient permissions, the script will fail.
|
- At a minimum, you must provide a token with permissions to update branch protection rules. For example, `gh auth token | pr-checks/sync-checks.ts --token-stdin` uses the same token that `gh` uses. You can also set the `GH_TOKEN` or `GITHUB_TOKEN` environment variable. If no token is provided or the token has insufficient permissions, the script will fail.
|
||||||
- By default, the script performs a dry run and outputs information about the changes it would make to the branch protection rules. To actually apply the changes, specify the `--apply` flag.
|
- By default, the script performs a dry run and outputs information about the changes it would make to the branch protection rules. To actually apply the changes, specify the `--apply` flag.
|
||||||
- If you run the script without any other arguments, it will retrieve the set of workflows that ran for the latest commit on `main`.
|
- If you run the script without any other arguments, it will retrieve the set of workflows that ran for the latest commit on `main`.
|
||||||
- You can specify a different git ref with the `--ref` input. You will likely want to use this if you have a PR that removes or adds PR checks. For example, `--ref "some/branch/name"` to use the HEAD of the `some/branch/name` branch.
|
- You can specify a different git ref with the `--ref` input. You will likely want to use this if you have a PR that removes or adds PR checks. For example, `--ref "some/branch/name"` to use the HEAD of the `some/branch/name` branch.
|
||||||
|
|||||||
@@ -78,8 +78,6 @@ We typically release new minor versions of the CodeQL Action and Bundle when a n
|
|||||||
| `v3.28.21` | `2.21.3` | Enterprise Server 3.18 | |
|
| `v3.28.21` | `2.21.3` | Enterprise Server 3.18 | |
|
||||||
| `v3.28.12` | `2.20.7` | Enterprise Server 3.17 | |
|
| `v3.28.12` | `2.20.7` | Enterprise Server 3.17 | |
|
||||||
| `v3.28.6` | `2.20.3` | Enterprise Server 3.16 | |
|
| `v3.28.6` | `2.20.3` | Enterprise Server 3.16 | |
|
||||||
| `v3.28.6` | `2.20.3` | Enterprise Server 3.15 | |
|
|
||||||
| `v3.28.6` | `2.20.3` | Enterprise Server 3.14 | |
|
|
||||||
|
|
||||||
See the full list of GHES release and deprecation dates at [GitHub Enterprise Server releases](https://docs.github.com/en/enterprise-server/admin/all-releases#releases-of-github-enterprise-server).
|
See the full list of GHES release and deprecation dates at [GitHub Enterprise Server releases](https://docs.github.com/en/enterprise-server/admin/all-releases#releases-of-github-enterprise-server).
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -95,5 +95,5 @@ outputs:
|
|||||||
description: The ID of the uploaded SARIF file.
|
description: The ID of the uploaded SARIF file.
|
||||||
runs:
|
runs:
|
||||||
using: node24
|
using: node24
|
||||||
main: "../lib/analyze-action.js"
|
main: "../lib/analyze-entry.js"
|
||||||
post: "../lib/analyze-action-post.js"
|
post: "../lib/analyze-post-entry.js"
|
||||||
|
|||||||
@@ -16,4 +16,4 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
runs:
|
runs:
|
||||||
using: node24
|
using: node24
|
||||||
main: '../lib/autobuild-action.js'
|
main: '../lib/autobuild-entry.js'
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { copyFile, rm, writeFile } from "node:fs/promises";
|
import { copyFile, readFile, rm, writeFile } from "node:fs/promises";
|
||||||
import { dirname, join } from "node:path";
|
import { basename, dirname, join } from "node:path";
|
||||||
import { fileURLToPath } from "node:url";
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
import * as esbuild from "esbuild";
|
import * as esbuild from "esbuild";
|
||||||
import { globSync } from "glob";
|
import { globSync } from "glob";
|
||||||
|
import * as yaml from "js-yaml";
|
||||||
|
|
||||||
import pkg from "./package.json" with { type: "json" };
|
import pkg from "./package.json" with { type: "json" };
|
||||||
|
|
||||||
@@ -27,6 +28,70 @@ const cleanPlugin = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** A plugin that checks that the Node versions in all `action.yml` files are the same. */
|
||||||
|
const checkNodeVersionsPlugin = {
|
||||||
|
name: "check-node-versions",
|
||||||
|
setup(build) {
|
||||||
|
build.onStart(async () => {
|
||||||
|
// Find all the `action.yml` files. We don't care about the stub in the repository root,
|
||||||
|
// since that is a `composite` action.
|
||||||
|
const actionSpecifications = globSync("*/action.yml");
|
||||||
|
|
||||||
|
// Track the Node versions we find for each file.
|
||||||
|
const nodeVersions = {};
|
||||||
|
|
||||||
|
// We will store the first Node version we find and use it to compare against the others.
|
||||||
|
// If there's any disagreement, we set `versionMismatch` to `true` and throw an error
|
||||||
|
// that includes all the discovered Node versions at the end.
|
||||||
|
let nodeVersion = undefined;
|
||||||
|
let versionMismatch = false;
|
||||||
|
|
||||||
|
for (const actionSpecification of actionSpecifications) {
|
||||||
|
// Read the contents of the action.yml file.
|
||||||
|
const contents = await readFile(actionSpecification, "utf-8");
|
||||||
|
const specification = yaml.load(contents);
|
||||||
|
|
||||||
|
// Find the `runs.using` value in the specification.
|
||||||
|
const using = specification.runs.using;
|
||||||
|
if (using === undefined || using === null) {
|
||||||
|
throw new Error(
|
||||||
|
`Couldn't find 'runs.using' in ${actionSpecification}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof using !== "string" || !using.startsWith("node")) {
|
||||||
|
throw new Error(
|
||||||
|
`Expected 'runs.using' to be a string starting with 'node' in ${actionSpecification}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nodeVersion === undefined) {
|
||||||
|
// First one we found: set it as the baseline.
|
||||||
|
nodeVersion = using;
|
||||||
|
} else if (nodeVersion !== using) {
|
||||||
|
// Disagreement: set `versionMismatch` to indicate that we should throw an error later.
|
||||||
|
versionMismatch = true;
|
||||||
|
}
|
||||||
|
nodeVersions[actionSpecification] = using;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Throw an error if there was a version mismatch.
|
||||||
|
if (versionMismatch) {
|
||||||
|
throw new Error(
|
||||||
|
`More than one node version used in 'action.yml' files: ${JSON.stringify(nodeVersions)}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write the node version to `.nvmrc`.
|
||||||
|
await writeFile(
|
||||||
|
join(__dirname, ".nvmrc"),
|
||||||
|
nodeVersion.substring("node".length) + "\n",
|
||||||
|
"utf-8",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy defaults.json to the output directory since other projects depend on it.
|
* Copy defaults.json to the output directory since other projects depend on it.
|
||||||
*
|
*
|
||||||
@@ -62,18 +127,159 @@ const onEndPlugin = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** The name of the virtual `entry-points` module. */
|
||||||
|
const SHARED_ENTRYPOINT = "entry-points";
|
||||||
|
|
||||||
|
/** The property name under which `upload-lib`'s namespace is exposed in `entry-points`. */
|
||||||
|
const UPLOAD_LIB_EXPORT = "uploadLib";
|
||||||
|
|
||||||
|
/** The relative source path of the `upload-lib` module that we re-export from `entry-points`. */
|
||||||
|
const UPLOAD_LIB_SRC = "./src/upload-lib";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This plugin finds all source files that contain Action entry points. It then generates the
|
||||||
|
* virtual `entry-points` module which imports all identified files, and re-exports their
|
||||||
|
* `runWrapper` functions with suitable aliases.
|
||||||
|
*
|
||||||
|
* The virtual module additionally re-exports `upload-lib` under the `uploadLib` namespace so that
|
||||||
|
* external consumers can access it via the small `lib/upload-lib.js` stub emitted below.
|
||||||
|
*
|
||||||
|
* A tiny stub file is emitted for each Action entrypoint, and one for `upload-lib`. Each stub
|
||||||
|
* imports the shared bundle and calls/re-exports from the respective entry point.
|
||||||
|
*
|
||||||
|
* @type {esbuild.Plugin}
|
||||||
|
*/
|
||||||
|
const entryPointsPlugin = {
|
||||||
|
name: "entry-points",
|
||||||
|
setup(build) {
|
||||||
|
const namespace = "actions";
|
||||||
|
const actions = [];
|
||||||
|
|
||||||
|
const toPascal = (s) =>
|
||||||
|
s.replace(/(^|-)([a-z0-9])/gi, (_, __, c) => c.toUpperCase());
|
||||||
|
|
||||||
|
// Find the source files containing Action entry points.
|
||||||
|
build.onStart(() => {
|
||||||
|
const actionFiles = globSync("src/*-action{,-post}.ts");
|
||||||
|
for (const actionFile of actionFiles) {
|
||||||
|
const match = basename(actionFile).match(/(.*)-action(-post)?/);
|
||||||
|
|
||||||
|
if (match.length < 2) {
|
||||||
|
throw new Error(`'${actionFile}' didn't match expected pattern.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const actionName = match[1];
|
||||||
|
const isPost = match[2] !== undefined;
|
||||||
|
|
||||||
|
actions.push({
|
||||||
|
path: actionFile,
|
||||||
|
name: actionName,
|
||||||
|
isPost,
|
||||||
|
pascalCaseName: `${toPascal(actionName)}${isPost ? "Post" : ""}Action`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Resolve the virtual `entry-points` file and set the corresponding namespace.
|
||||||
|
// Ideally, we'd `RegExp.escape` the entrypoint here, but that API isn't supported in Node 20.
|
||||||
|
// Since we're dealing with a hardcoded string, this isn't too much of a problem.
|
||||||
|
build.onResolve({ filter: new RegExp(`^${SHARED_ENTRYPOINT}$`) }, () => {
|
||||||
|
return { path: SHARED_ENTRYPOINT, namespace };
|
||||||
|
});
|
||||||
|
|
||||||
|
// Generate the virtual `entry-points` file based on the Actions we discovered.
|
||||||
|
// Restrict using the namespace. The path filter does not need to discriminate any further.
|
||||||
|
build.onLoad({ filter: /.*/, namespace }, async () => {
|
||||||
|
const wrapperTemplatePath = "entry-wrapper.js.tpl";
|
||||||
|
const wrapperTemplate = await readFile(
|
||||||
|
join(SRC_DIR, wrapperTemplatePath),
|
||||||
|
"utf-8",
|
||||||
|
);
|
||||||
|
|
||||||
|
const actionsSorted = actions.sort((a, b) =>
|
||||||
|
a.name.localeCompare(b.name),
|
||||||
|
);
|
||||||
|
const imports = actionsSorted
|
||||||
|
.map(
|
||||||
|
(action) =>
|
||||||
|
`import * as ${action.pascalCaseName} from "./src/${basename(action.path)}";`,
|
||||||
|
)
|
||||||
|
.join("\n");
|
||||||
|
const wrappers = actionsSorted
|
||||||
|
.map((action) =>
|
||||||
|
wrapperTemplate.replaceAll("__ACTION__", action.pascalCaseName),
|
||||||
|
)
|
||||||
|
.join("\n\n");
|
||||||
|
|
||||||
|
// Also re-export the `upload-lib` namespace so that external consumers can reach it
|
||||||
|
// via the `lib/upload-lib.js` stub without us having to bundle a second copy.
|
||||||
|
const uploadLibReExport = `export * as ${UPLOAD_LIB_EXPORT} from "${UPLOAD_LIB_SRC}";`;
|
||||||
|
|
||||||
|
return {
|
||||||
|
contents: `"use strict";\n${imports}\n\n${uploadLibReExport}\n\n${wrappers}\n`,
|
||||||
|
resolveDir: ".",
|
||||||
|
loader: "ts",
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Emit entry point stubs for each Action using the entry template.
|
||||||
|
build.onEnd(async () => {
|
||||||
|
const makeHeader = (templatePath, sourceFile) =>
|
||||||
|
`// Automatically generated from '${templatePath}' for 'src/${basename(sourceFile)}'.\n\n`;
|
||||||
|
|
||||||
|
// Read the entry point template.
|
||||||
|
const actionTemplatePath = "action-entry.js.tpl";
|
||||||
|
const actionTemplate = await readFile(
|
||||||
|
join(SRC_DIR, actionTemplatePath),
|
||||||
|
"utf-8",
|
||||||
|
);
|
||||||
|
|
||||||
|
// Write entry point stubs for each Action.
|
||||||
|
for (const action of actions) {
|
||||||
|
await writeFile(
|
||||||
|
join(
|
||||||
|
OUT_DIR,
|
||||||
|
`${action.name}${action.isPost ? "-post" : ""}-entry.js`,
|
||||||
|
),
|
||||||
|
makeHeader(actionTemplatePath, action.path) +
|
||||||
|
actionTemplate.replaceAll("__ACTION__", action.pascalCaseName),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write a small stub for `upload-lib` that re-exports it from the shared bundle.
|
||||||
|
// External callers (e.g. internal testing environments) `require("./lib/upload-lib")`
|
||||||
|
// and expect the same shape as before, so we expose the namespace as `module.exports`.
|
||||||
|
const uploadLibStubTemplatePath = "upload-lib-stub.js.tpl";
|
||||||
|
const uploadLibStubTemplate = await readFile(
|
||||||
|
join(SRC_DIR, uploadLibStubTemplatePath),
|
||||||
|
"utf-8",
|
||||||
|
);
|
||||||
|
await writeFile(
|
||||||
|
join(OUT_DIR, "upload-lib.js"),
|
||||||
|
makeHeader(uploadLibStubTemplatePath, `${UPLOAD_LIB_SRC}.ts`) +
|
||||||
|
uploadLibStubTemplate.replaceAll(
|
||||||
|
"__UPLOAD_LIB_EXPORT__",
|
||||||
|
UPLOAD_LIB_EXPORT,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const context = await esbuild.context({
|
const context = await esbuild.context({
|
||||||
// Include upload-lib.ts as an entry point for use in testing environments.
|
entryPoints: [{ in: SHARED_ENTRYPOINT, out: SHARED_ENTRYPOINT }],
|
||||||
entryPoints: globSync([
|
|
||||||
`${SRC_DIR}/*-action.ts`,
|
|
||||||
`${SRC_DIR}/*-action-post.ts`,
|
|
||||||
"src/upload-lib.ts",
|
|
||||||
]),
|
|
||||||
bundle: true,
|
bundle: true,
|
||||||
format: "cjs",
|
format: "cjs",
|
||||||
outdir: OUT_DIR,
|
outdir: OUT_DIR,
|
||||||
platform: "node",
|
platform: "node",
|
||||||
plugins: [cleanPlugin, copyDefaultsPlugin, onEndPlugin],
|
external: ["./entry-points"],
|
||||||
|
plugins: [
|
||||||
|
cleanPlugin,
|
||||||
|
checkNodeVersionsPlugin,
|
||||||
|
copyDefaultsPlugin,
|
||||||
|
entryPointsPlugin,
|
||||||
|
onEndPlugin,
|
||||||
|
],
|
||||||
target: ["node20"],
|
target: ["node20"],
|
||||||
define: {
|
define: {
|
||||||
__CODEQL_ACTION_VERSION__: JSON.stringify(pkg.version),
|
__CODEQL_ACTION_VERSION__: JSON.stringify(pkg.version),
|
||||||
|
|||||||
+2
-2
@@ -171,5 +171,5 @@ outputs:
|
|||||||
description: The version of the CodeQL binary used for analysis
|
description: The version of the CodeQL binary used for analysis
|
||||||
runs:
|
runs:
|
||||||
using: node24
|
using: node24
|
||||||
main: '../lib/init-action.js'
|
main: '../lib/init-entry.js'
|
||||||
post: '../lib/init-action-post.js'
|
post: '../lib/init-post-entry.js'
|
||||||
|
|||||||
Generated
-129157
File diff suppressed because one or more lines are too long
Generated
-95829
File diff suppressed because one or more lines are too long
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
// Automatically generated from 'action-entry.js.tpl' for 'src/analyze-action.ts'.
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const import_entry_points = require("./entry-points");
|
||||||
|
void (0, import_entry_points.runAnalyzeAction)();
|
||||||
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
// Automatically generated from 'action-entry.js.tpl' for 'src/analyze-action-post.ts'.
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const import_entry_points = require("./entry-points");
|
||||||
|
void (0, import_entry_points.runAnalyzePostAction)();
|
||||||
Generated
-88218
File diff suppressed because one or more lines are too long
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
// Automatically generated from 'action-entry.js.tpl' for 'src/autobuild-action.ts'.
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const import_entry_points = require("./entry-points");
|
||||||
|
void (0, import_entry_points.runAutobuildAction)();
|
||||||
+4
-4
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"bundleVersion": "codeql-bundle-v2.25.3",
|
"bundleVersion": "codeql-bundle-v2.25.4",
|
||||||
"cliVersion": "2.25.3",
|
"cliVersion": "2.25.4",
|
||||||
"priorBundleVersion": "codeql-bundle-v2.25.2",
|
"priorBundleVersion": "codeql-bundle-v2.25.3",
|
||||||
"priorCliVersion": "2.25.2"
|
"priorCliVersion": "2.25.3"
|
||||||
}
|
}
|
||||||
|
|||||||
+32433
-7740
File diff suppressed because it is too large
Load Diff
Generated
-92812
File diff suppressed because one or more lines are too long
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
// Automatically generated from 'action-entry.js.tpl' for 'src/init-action.ts'.
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const import_entry_points = require("./entry-points");
|
||||||
|
void (0, import_entry_points.runInitAction)();
|
||||||
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
// Automatically generated from 'action-entry.js.tpl' for 'src/init-action-post.ts'.
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const import_entry_points = require("./entry-points");
|
||||||
|
void (0, import_entry_points.runInitPostAction)();
|
||||||
Generated
-87777
File diff suppressed because one or more lines are too long
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
// Automatically generated from 'action-entry.js.tpl' for 'src/resolve-environment-action.ts'.
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const import_entry_points = require("./entry-points");
|
||||||
|
void (0, import_entry_points.runResolveEnvironmentAction)();
|
||||||
Generated
-89286
File diff suppressed because one or more lines are too long
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
// Automatically generated from 'action-entry.js.tpl' for 'src/setup-codeql-action.ts'.
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const import_entry_points = require("./entry-points");
|
||||||
|
void (0, import_entry_points.runSetupCodeqlAction)();
|
||||||
Generated
-127969
File diff suppressed because one or more lines are too long
Generated
-105038
File diff suppressed because one or more lines are too long
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
// Automatically generated from 'action-entry.js.tpl' for 'src/start-proxy-action.ts'.
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const import_entry_points = require("./entry-points");
|
||||||
|
void (0, import_entry_points.runStartProxyAction)();
|
||||||
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
// Automatically generated from 'action-entry.js.tpl' for 'src/start-proxy-action-post.ts'.
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const import_entry_points = require("./entry-points");
|
||||||
|
void (0, import_entry_points.runStartProxyPostAction)();
|
||||||
Generated
+3
-93489
File diff suppressed because one or more lines are too long
Generated
-127994
File diff suppressed because one or more lines are too long
Generated
-94176
File diff suppressed because one or more lines are too long
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
// Automatically generated from 'action-entry.js.tpl' for 'src/upload-sarif-action.ts'.
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const import_entry_points = require("./entry-points");
|
||||||
|
void (0, import_entry_points.runUploadSarifAction)();
|
||||||
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
// Automatically generated from 'action-entry.js.tpl' for 'src/upload-sarif-action-post.ts'.
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const import_entry_points = require("./entry-points");
|
||||||
|
void (0, import_entry_points.runUploadSarifPostAction)();
|
||||||
Generated
+349
-432
File diff suppressed because it is too large
Load Diff
+12
-12
@@ -1,18 +1,19 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "4.35.4",
|
"version": "4.36.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "CodeQL action",
|
"description": "CodeQL action",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"_build_comment": "echo 'Run the full build so we typecheck the project and can reuse the transpiled files in npm test'",
|
"_build_comment": "echo 'Run the full build so we typecheck the project and can reuse the transpiled files in npm test'",
|
||||||
"build": "./scripts/check-node-modules.sh && npm run transpile && node build.mjs && npx tsx ./pr-checks/bundle-metadata.ts",
|
"build": "./scripts/check-node-modules.sh && npm run transpile && node build.mjs",
|
||||||
"lint": "eslint --report-unused-disable-directives --max-warnings=0 .",
|
"lint": "eslint --report-unused-disable-directives --max-warnings=0 .",
|
||||||
"lint-ci": "SARIF_ESLINT_IGNORE_SUPPRESSED=true eslint --report-unused-disable-directives --max-warnings=0 . --format @microsoft/eslint-formatter-sarif --output-file=eslint.sarif",
|
"lint-ci": "SARIF_ESLINT_IGNORE_SUPPRESSED=true eslint --report-unused-disable-directives --max-warnings=0 . --format @microsoft/eslint-formatter-sarif --output-file=eslint.sarif",
|
||||||
"lint-fix": "eslint --report-unused-disable-directives --max-warnings=0 . --fix",
|
"lint-fix": "eslint --report-unused-disable-directives --max-warnings=0 . --fix",
|
||||||
"ava": "npm run transpile && ava --verbose",
|
"ava": "npm run transpile && ava --verbose",
|
||||||
"test": "npm run ava -- src/",
|
"test": "npm run ava -- src/",
|
||||||
"test-debug": "npm run test -- --timeout=20m",
|
"test-debug": "npm run test -- --timeout=20m",
|
||||||
"transpile": "tsc --build --verbose tsconfig.json"
|
"transpile": "tsc --build --verbose tsconfig.json",
|
||||||
|
"update-pr-checks": "./pr-checks/sync.sh"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
@@ -43,32 +44,32 @@
|
|||||||
"uuid": "^14.0.0"
|
"uuid": "^14.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@ava/typescript": "7.0.0",
|
"@ava/typescript": "6.0.0",
|
||||||
"@eslint/compat": "^2.0.5",
|
"@eslint/compat": "^2.0.5",
|
||||||
"@microsoft/eslint-formatter-sarif": "^3.1.0",
|
"@microsoft/eslint-formatter-sarif": "^3.1.0",
|
||||||
"@octokit/types": "^16.0.0",
|
"@octokit/types": "^16.0.0",
|
||||||
"@types/archiver": "^7.0.0",
|
"@types/archiver": "^7.0.0",
|
||||||
"@types/follow-redirects": "^1.14.4",
|
"@types/follow-redirects": "^1.14.4",
|
||||||
"@types/js-yaml": "^4.0.9",
|
"@types/js-yaml": "^4.0.9",
|
||||||
"@types/node": "^20.19.9",
|
"@types/node": "^20.19.39",
|
||||||
"@types/node-forge": "^1.3.14",
|
"@types/node-forge": "^1.3.14",
|
||||||
"@types/sarif": "^2.1.7",
|
"@types/sarif": "^2.1.7",
|
||||||
"@types/semver": "^7.7.1",
|
"@types/semver": "^7.7.1",
|
||||||
"@types/sinon": "^21.0.1",
|
"@types/sinon": "^21.0.1",
|
||||||
"ava": "^7.0.0",
|
"ava": "^6.4.1",
|
||||||
"esbuild": "^0.28.0",
|
"esbuild": "^0.28.0",
|
||||||
"eslint": "^9.39.2",
|
"eslint": "^9.39.4",
|
||||||
"eslint-import-resolver-typescript": "^4.4.4",
|
"eslint-import-resolver-typescript": "^4.4.4",
|
||||||
"eslint-plugin-github": "^6.0.0",
|
"eslint-plugin-github": "^6.0.0",
|
||||||
"eslint-plugin-import-x": "^4.16.2",
|
"eslint-plugin-import-x": "^4.16.2",
|
||||||
"eslint-plugin-jsdoc": "^62.9.0",
|
"eslint-plugin-jsdoc": "^62.9.0",
|
||||||
"eslint-plugin-no-async-foreach": "^0.1.1",
|
"eslint-plugin-no-async-foreach": "^0.1.1",
|
||||||
"glob": "^11.1.0",
|
"glob": "^11.1.0",
|
||||||
"globals": "^17.5.0",
|
"globals": "^17.6.0",
|
||||||
"nock": "^14.0.12",
|
"nock": "^14.0.12",
|
||||||
"sinon": "^21.1.2",
|
"sinon": "^22.0.0",
|
||||||
"typescript": "^6.0.2",
|
"typescript": "^6.0.3",
|
||||||
"typescript-eslint": "^8.58.2"
|
"typescript-eslint": "^8.59.2"
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"@actions/tool-cache": {
|
"@actions/tool-cache": {
|
||||||
@@ -89,7 +90,6 @@
|
|||||||
"eslint-plugin-jsx-a11y": {
|
"eslint-plugin-jsx-a11y": {
|
||||||
"semver": ">=6.3.1"
|
"semver": ">=6.3.1"
|
||||||
},
|
},
|
||||||
"brace-expansion@2.0.1": "2.0.2",
|
|
||||||
"glob": "^11.1.0",
|
"glob": "^11.1.0",
|
||||||
"undici": "^6.24.0"
|
"undici": "^6.24.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ name: "Multi-language repository"
|
|||||||
description: "An end-to-end integration test of a multi-language repository using automatic language detection"
|
description: "An end-to-end integration test of a multi-language repository using automatic language detection"
|
||||||
operatingSystems:
|
operatingSystems:
|
||||||
- ubuntu
|
- ubuntu
|
||||||
- macos
|
- os: macos
|
||||||
|
runner-image: macos-latest-xlarge
|
||||||
env:
|
env:
|
||||||
CODEQL_ACTION_RESOLVE_SUPPORTED_LANGUAGES_USING_CLI: true
|
CODEQL_ACTION_RESOLVE_SUPPORTED_LANGUAGES_USING_CLI: true
|
||||||
installGo: true
|
installGo: true
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ versions:
|
|||||||
- default
|
- default
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Ruby
|
- name: Set up Ruby
|
||||||
uses: ruby/setup-ruby@0cb964fd540e0a24c900370abf38a33466142735 # v1.305.0
|
uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1.306.0
|
||||||
with:
|
with:
|
||||||
ruby-version: 2.6
|
ruby-version: 2.6
|
||||||
- name: Install Code Scanning integration
|
- name: Install Code Scanning integration
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ name: "Rust analysis"
|
|||||||
description: "Tests creation of a Rust database"
|
description: "Tests creation of a Rust database"
|
||||||
versions:
|
versions:
|
||||||
# experimental rust support introduced, requires action to set `CODEQL_ENABLE_EXPERIMENTAL_FEATURES`
|
# experimental rust support introduced, requires action to set `CODEQL_ENABLE_EXPERIMENTAL_FEATURES`
|
||||||
- stable-v2.19.3
|
- stable-v2.19.4
|
||||||
# first public preview version
|
# first public preview version
|
||||||
- stable-v2.22.1
|
- stable-v2.22.1
|
||||||
- linked
|
- linked
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ description: "Tests creation of a Swift database using autobuild"
|
|||||||
versions:
|
versions:
|
||||||
- nightly-latest
|
- nightly-latest
|
||||||
operatingSystems:
|
operatingSystems:
|
||||||
- macos
|
- os: macos
|
||||||
|
runner-image: macos-latest-xlarge
|
||||||
steps:
|
steps:
|
||||||
- uses: ./../action/init
|
- uses: ./../action/init
|
||||||
id: init
|
id: init
|
||||||
|
|||||||
@@ -7,10 +7,10 @@
|
|||||||
"@octokit/core": "^7.0.6",
|
"@octokit/core": "^7.0.6",
|
||||||
"@octokit/plugin-paginate-rest": ">=9.2.2",
|
"@octokit/plugin-paginate-rest": ">=9.2.2",
|
||||||
"@octokit/plugin-rest-endpoint-methods": "^17.0.0",
|
"@octokit/plugin-rest-endpoint-methods": "^17.0.0",
|
||||||
"yaml": "^2.8.3"
|
"yaml": "^2.8.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.19.9",
|
"@types/node": "^20.19.39",
|
||||||
"tsx": "^4.21.0"
|
"tsx": "^4.21.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,13 @@ Tests for the sync-checks.ts script
|
|||||||
import * as assert from "node:assert/strict";
|
import * as assert from "node:assert/strict";
|
||||||
import { describe, it } from "node:test";
|
import { describe, it } from "node:test";
|
||||||
|
|
||||||
import { CheckInfo, Exclusions, Options, removeExcluded } from "./sync-checks";
|
import {
|
||||||
|
CheckInfo,
|
||||||
|
Exclusions,
|
||||||
|
Options,
|
||||||
|
removeExcluded,
|
||||||
|
resolveToken,
|
||||||
|
} from "./sync-checks";
|
||||||
|
|
||||||
const defaultOptions: Options = {
|
const defaultOptions: Options = {
|
||||||
apply: false,
|
apply: false,
|
||||||
@@ -58,3 +64,46 @@ describe("removeExcluded", async () => {
|
|||||||
assert.deepEqual(retained, expectedExactMatches);
|
assert.deepEqual(retained, expectedExactMatches);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("resolveToken", async () => {
|
||||||
|
await it("reads the token from standard input", async () => {
|
||||||
|
const token = await resolveToken(
|
||||||
|
{ tokenStdin: true },
|
||||||
|
{ env: {}, readStdin: async () => " stdin-token\n" },
|
||||||
|
);
|
||||||
|
assert.equal(token, "stdin-token");
|
||||||
|
});
|
||||||
|
|
||||||
|
await it("reads the token from the GH_TOKEN environment variable", async () => {
|
||||||
|
const token = await resolveToken(
|
||||||
|
{},
|
||||||
|
{ env: { GH_TOKEN: "env-token" }, readStdin: async () => "" },
|
||||||
|
);
|
||||||
|
assert.equal(token, "env-token");
|
||||||
|
});
|
||||||
|
|
||||||
|
await it("reads the token from the GITHUB_TOKEN environment variable", async () => {
|
||||||
|
const token = await resolveToken(
|
||||||
|
{},
|
||||||
|
{ env: { GITHUB_TOKEN: "env-token" }, readStdin: async () => "" },
|
||||||
|
);
|
||||||
|
assert.equal(token, "env-token");
|
||||||
|
});
|
||||||
|
|
||||||
|
await it("rejects an empty standard input token", async () => {
|
||||||
|
await assert.rejects(
|
||||||
|
resolveToken(
|
||||||
|
{ tokenStdin: true },
|
||||||
|
{ env: {}, readStdin: async () => "\n" },
|
||||||
|
),
|
||||||
|
/No token received on standard input/,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
await it("rejects missing token sources", async () => {
|
||||||
|
await assert.rejects(
|
||||||
|
resolveToken({}, { env: {}, readStdin: async () => "" }),
|
||||||
|
/Missing authentication token/,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import {
|
|||||||
|
|
||||||
/** Represents the command-line options. */
|
/** Represents the command-line options. */
|
||||||
export interface Options {
|
export interface Options {
|
||||||
/** The token to use to authenticate to the GitHub API. */
|
/** Whether to read the GitHub API token from standard input. */
|
||||||
token?: string;
|
tokenStdin?: boolean;
|
||||||
/** The git ref to use the checks for. */
|
/** The git ref to use the checks for. */
|
||||||
ref?: string;
|
ref?: string;
|
||||||
/** Whether to actually apply the changes or not. */
|
/** Whether to actually apply the changes or not. */
|
||||||
@@ -31,6 +31,65 @@ const codeqlActionRepo = {
|
|||||||
repo: "codeql-action",
|
repo: "codeql-action",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Environment variables to check for a GitHub API token. */
|
||||||
|
const TOKEN_ENVIRONMENT_VARIABLES = ["GH_TOKEN", "GITHUB_TOKEN"];
|
||||||
|
|
||||||
|
/** Represents the sources from which we can retrieve the GitHub API token. */
|
||||||
|
interface TokenSource {
|
||||||
|
/** Environment variables to inspect. */
|
||||||
|
env: NodeJS.ProcessEnv;
|
||||||
|
/** Reads a token from standard input. */
|
||||||
|
readStdin: () => Promise<string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reads the GitHub API token from standard input. */
|
||||||
|
async function readTokenFromStdin(): Promise<string> {
|
||||||
|
let token = "";
|
||||||
|
process.stdin.setEncoding("utf8");
|
||||||
|
for await (const chunk of process.stdin) {
|
||||||
|
token += chunk;
|
||||||
|
}
|
||||||
|
return token.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gets a GitHub API token from one of the supported environment variables. */
|
||||||
|
function getTokenFromEnvironment(env: NodeJS.ProcessEnv): string | undefined {
|
||||||
|
for (const variableName of TOKEN_ENVIRONMENT_VARIABLES) {
|
||||||
|
const token = env[variableName]?.trim();
|
||||||
|
if (token) {
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gets the token to use to authenticate to the GitHub API. */
|
||||||
|
export async function resolveToken(
|
||||||
|
options: Pick<Options, "tokenStdin">,
|
||||||
|
tokenSource: TokenSource = {
|
||||||
|
env: process.env,
|
||||||
|
readStdin: readTokenFromStdin,
|
||||||
|
},
|
||||||
|
): Promise<string> {
|
||||||
|
if (options.tokenStdin) {
|
||||||
|
const token = (await tokenSource.readStdin()).trim();
|
||||||
|
if (token.length === 0) {
|
||||||
|
throw new Error("No token received on standard input.");
|
||||||
|
}
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
const environmentToken = getTokenFromEnvironment(tokenSource.env);
|
||||||
|
if (environmentToken !== undefined) {
|
||||||
|
return environmentToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error(
|
||||||
|
"Missing authentication token. Set GH_TOKEN/GITHUB_TOKEN or pipe a token " +
|
||||||
|
"to --token-stdin.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/** Represents a configuration of which checks should not be set up as required checks. */
|
/** Represents a configuration of which checks should not be set up as required checks. */
|
||||||
export interface Exclusions {
|
export interface Exclusions {
|
||||||
/** A list of strings that, if contained in a check name, are excluded. */
|
/** A list of strings that, if contained in a check name, are excluded. */
|
||||||
@@ -205,9 +264,10 @@ async function updateBranch(
|
|||||||
async function main(): Promise<void> {
|
async function main(): Promise<void> {
|
||||||
const { values: options } = parseArgs({
|
const { values: options } = parseArgs({
|
||||||
options: {
|
options: {
|
||||||
// The token to use to authenticate to the API.
|
// Read the token to use to authenticate to the API from standard input.
|
||||||
token: {
|
"token-stdin": {
|
||||||
type: "string",
|
type: "boolean",
|
||||||
|
default: false,
|
||||||
},
|
},
|
||||||
// The git ref for which to retrieve the check runs.
|
// The git ref for which to retrieve the check runs.
|
||||||
ref: {
|
ref: {
|
||||||
@@ -228,16 +288,16 @@ async function main(): Promise<void> {
|
|||||||
strict: true,
|
strict: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (options.token === undefined) {
|
const token = await resolveToken({
|
||||||
throw new Error("Missing --token");
|
tokenStdin: options["token-stdin"],
|
||||||
}
|
});
|
||||||
|
|
||||||
console.info(
|
console.info(
|
||||||
`Oldest supported major version is: ${OLDEST_SUPPORTED_MAJOR_VERSION}`,
|
`Oldest supported major version is: ${OLDEST_SUPPORTED_MAJOR_VERSION}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Initialise the API client.
|
// Initialise the API client.
|
||||||
const client = getApiClient(options.token);
|
const client = getApiClient(token);
|
||||||
|
|
||||||
// Find the check runs for the specified `ref` that we will later set as the required checks
|
// Find the check runs for the specified `ref` that we will later set as the required checks
|
||||||
// for the main and release branches.
|
// for the main and release branches.
|
||||||
|
|||||||
+42
-11
@@ -28,6 +28,24 @@ interface WorkflowInput {
|
|||||||
/** A partial mapping from known input names to input definitions. */
|
/** A partial mapping from known input names to input definitions. */
|
||||||
type WorkflowInputs = Partial<Record<KnownInputName, WorkflowInput>>;
|
type WorkflowInputs = Partial<Record<KnownInputName, WorkflowInput>>;
|
||||||
|
|
||||||
|
/** An operating system identifier. */
|
||||||
|
type OperatingSystemIdentifier = "ubuntu" | "macos" | "windows";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an operating system matrix entry for a generated PR check workflow.
|
||||||
|
*
|
||||||
|
* Either a string containing the OS identifier or an object containing the OS identifier and an
|
||||||
|
* optional runner image label.
|
||||||
|
*/
|
||||||
|
type OperatingSystem =
|
||||||
|
| OperatingSystemIdentifier
|
||||||
|
| {
|
||||||
|
/** OS identifier. */
|
||||||
|
os: OperatingSystemIdentifier;
|
||||||
|
/** Optional runner image label. */
|
||||||
|
"runner-image"?: string;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents PR check specifications.
|
* Represents PR check specifications.
|
||||||
*/
|
*/
|
||||||
@@ -36,8 +54,8 @@ interface Specification extends JobSpecification {
|
|||||||
inputs?: Record<string, WorkflowInput>;
|
inputs?: Record<string, WorkflowInput>;
|
||||||
/** CodeQL bundle versions to test against. Defaults to `DEFAULT_TEST_VERSIONS`. */
|
/** CodeQL bundle versions to test against. Defaults to `DEFAULT_TEST_VERSIONS`. */
|
||||||
versions?: string[];
|
versions?: string[];
|
||||||
/** Operating system prefixes used to select runner images (e.g. `["ubuntu", "macos"]`). */
|
/** Operating system prefixes, either as strings or with explicit runner image labels. */
|
||||||
operatingSystems?: string[];
|
operatingSystems?: OperatingSystem[];
|
||||||
/** Per-OS version overrides. If specified for an OS, only those versions are tested on that OS. */
|
/** Per-OS version overrides. If specified for an OS, only those versions are tested on that OS. */
|
||||||
osCodeQlVersions?: Record<string, string[]>;
|
osCodeQlVersions?: Record<string, string[]>;
|
||||||
/** Whether to use the all-platform CodeQL bundle. */
|
/** Whether to use the all-platform CodeQL bundle. */
|
||||||
@@ -97,10 +115,6 @@ type LanguageSetups = Partial<Record<BuiltInLanguage, LanguageSetup>>;
|
|||||||
// The default set of CodeQL Bundle versions to use for the PR checks.
|
// The default set of CodeQL Bundle versions to use for the PR checks.
|
||||||
const defaultTestVersions = [
|
const defaultTestVersions = [
|
||||||
// The oldest supported CodeQL version. If bumping, update `CODEQL_MINIMUM_VERSION` in `codeql.ts`
|
// The oldest supported CodeQL version. If bumping, update `CODEQL_MINIMUM_VERSION` in `codeql.ts`
|
||||||
"stable-v2.17.6",
|
|
||||||
// The last CodeQL release in the 2.18 series.
|
|
||||||
"stable-v2.18.4",
|
|
||||||
// The last CodeQL release in the 2.19 series.
|
|
||||||
"stable-v2.19.4",
|
"stable-v2.19.4",
|
||||||
// The last CodeQL release in the 2.20 series.
|
// The last CodeQL release in the 2.20 series.
|
||||||
"stable-v2.20.7",
|
"stable-v2.20.7",
|
||||||
@@ -108,6 +122,10 @@ const defaultTestVersions = [
|
|||||||
"stable-v2.21.4",
|
"stable-v2.21.4",
|
||||||
// The last CodeQL release in the 2.22 series.
|
// The last CodeQL release in the 2.22 series.
|
||||||
"stable-v2.22.4",
|
"stable-v2.22.4",
|
||||||
|
// The last CodeQL release in the 2.23 series.
|
||||||
|
"stable-v2.23.9",
|
||||||
|
// The last CodeQL release in the 2.24 series.
|
||||||
|
"stable-v2.24.3",
|
||||||
// The default version of CodeQL for Dotcom, as determined by feature flags.
|
// The default version of CodeQL for Dotcom, as determined by feature flags.
|
||||||
"default",
|
"default",
|
||||||
// The version of CodeQL shipped with the Action in `defaults.json`. During the release process
|
// The version of CodeQL shipped with the Action in `defaults.json`. During the release process
|
||||||
@@ -311,10 +329,19 @@ function generateJobMatrix(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const runnerImages = ["ubuntu-latest", "macos-latest", "windows-latest"];
|
const defaultRunnerImages = [
|
||||||
|
"ubuntu-latest",
|
||||||
|
"macos-latest",
|
||||||
|
"windows-latest",
|
||||||
|
];
|
||||||
const operatingSystems = checkSpecification.operatingSystems ?? ["ubuntu"];
|
const operatingSystems = checkSpecification.operatingSystems ?? ["ubuntu"];
|
||||||
|
|
||||||
for (const operatingSystem of operatingSystems) {
|
for (const operatingSystemConfig of operatingSystems) {
|
||||||
|
const operatingSystem =
|
||||||
|
typeof operatingSystemConfig === "string"
|
||||||
|
? operatingSystemConfig
|
||||||
|
: operatingSystemConfig.os;
|
||||||
|
|
||||||
// If osCodeQlVersions is set for this OS, only include the specified CodeQL versions.
|
// If osCodeQlVersions is set for this OS, only include the specified CodeQL versions.
|
||||||
const allowedVersions =
|
const allowedVersions =
|
||||||
checkSpecification.osCodeQlVersions?.[operatingSystem];
|
checkSpecification.osCodeQlVersions?.[operatingSystem];
|
||||||
@@ -322,9 +349,13 @@ function generateJobMatrix(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const runnerImagesForOs = runnerImages.filter((image) =>
|
const runnerImagesForOs =
|
||||||
image.startsWith(operatingSystem),
|
typeof operatingSystemConfig === "string" ||
|
||||||
);
|
operatingSystemConfig["runner-image"] === undefined
|
||||||
|
? defaultRunnerImages.filter((image) =>
|
||||||
|
image.startsWith(operatingSystem),
|
||||||
|
)
|
||||||
|
: [operatingSystemConfig["runner-image"]];
|
||||||
|
|
||||||
for (const runnerImage of runnerImagesForOs) {
|
for (const runnerImage of runnerImagesForOs) {
|
||||||
matrix.push({
|
matrix.push({
|
||||||
|
|||||||
@@ -22,4 +22,4 @@ outputs:
|
|||||||
description: The inferred build environment configuration.
|
description: The inferred build environment configuration.
|
||||||
runs:
|
runs:
|
||||||
using: node24
|
using: node24
|
||||||
main: '../lib/resolve-environment-action.js'
|
main: '../lib/resolve-environment-entry.js'
|
||||||
|
|||||||
+20
-1
@@ -19,6 +19,25 @@ inputs:
|
|||||||
If not specified, the Action will check in several places until it finds
|
If not specified, the Action will check in several places until it finds
|
||||||
the CodeQL tools.
|
the CodeQL tools.
|
||||||
required: false
|
required: false
|
||||||
|
languages:
|
||||||
|
description: >-
|
||||||
|
A comma-separated list of CodeQL languages that will be analyzed in subsequent
|
||||||
|
`github/codeql-action/init` and `github/codeql-action/analyze` invocations. If specified, the
|
||||||
|
Action may use this list to select a CodeQL CLI version that is best suited to analyzing those
|
||||||
|
languages, for example by preferring a version that has a cached overlay-base database for the
|
||||||
|
specified languages. This input is not remembered and must also be passed to
|
||||||
|
`github/codeql-action/init`.
|
||||||
|
required: false
|
||||||
|
analysis-kinds:
|
||||||
|
description: >-
|
||||||
|
[Internal] A comma-separated list of analysis kinds that subsequent
|
||||||
|
`github/codeql-action/init` invocations will enable. If specified, the Action may use this
|
||||||
|
list to select a CodeQL CLI version that is best suited to those analysis kinds. This input is
|
||||||
|
not remembered and must also be passed to `github/codeql-action/init`.
|
||||||
|
|
||||||
|
Available options are the same as for the `analysis-kinds` input on the `init` Action.
|
||||||
|
default: 'code-scanning'
|
||||||
|
required: true
|
||||||
token:
|
token:
|
||||||
description: GitHub token to use for authenticating with this instance of GitHub.
|
description: GitHub token to use for authenticating with this instance of GitHub.
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
@@ -36,4 +55,4 @@ outputs:
|
|||||||
description: The version of the CodeQL binary that was installed.
|
description: The version of the CodeQL binary that was installed.
|
||||||
runs:
|
runs:
|
||||||
using: node24
|
using: node24
|
||||||
main: '../lib/setup-codeql-action.js'
|
main: '../lib/setup-codeql-entry.js'
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
const import_entry_points = require("./entry-points");
|
||||||
|
void (0, import_entry_points.run__ACTION__)();
|
||||||
+96
-9
@@ -16,7 +16,12 @@ import {
|
|||||||
} from "./analyses";
|
} from "./analyses";
|
||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
import { getRunnerLogger } from "./logging";
|
import { getRunnerLogger } from "./logging";
|
||||||
import { setupTests } from "./testing-utils";
|
import {
|
||||||
|
createFeatures,
|
||||||
|
RecordingLogger,
|
||||||
|
setupBaseActionsVars,
|
||||||
|
setupTests,
|
||||||
|
} from "./testing-utils";
|
||||||
import { AssessmentPayload } from "./upload-lib/types";
|
import { AssessmentPayload } from "./upload-lib/types";
|
||||||
import { ConfigurationError } from "./util";
|
import { ConfigurationError } from "./util";
|
||||||
|
|
||||||
@@ -53,24 +58,91 @@ test("Parsing analysis kinds requires at least one analysis kind", async (t) =>
|
|||||||
test.serial(
|
test.serial(
|
||||||
"getAnalysisKinds - returns expected analysis kinds for `analysis-kinds` input",
|
"getAnalysisKinds - returns expected analysis kinds for `analysis-kinds` input",
|
||||||
async (t) => {
|
async (t) => {
|
||||||
|
process.env[EnvVar.TEST_MODE] = "true";
|
||||||
|
const features = createFeatures([]);
|
||||||
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
||||||
requiredInputStub
|
requiredInputStub
|
||||||
.withArgs("analysis-kinds")
|
.withArgs("analysis-kinds")
|
||||||
.returns("code-scanning,code-quality");
|
.returns("code-scanning,code-quality");
|
||||||
const result = await getAnalysisKinds(getRunnerLogger(true), true);
|
const result = await getAnalysisKinds(
|
||||||
|
getRunnerLogger(true),
|
||||||
|
features,
|
||||||
|
true,
|
||||||
|
);
|
||||||
t.assert(result.includes(AnalysisKind.CodeScanning));
|
t.assert(result.includes(AnalysisKind.CodeScanning));
|
||||||
t.assert(result.includes(AnalysisKind.CodeQuality));
|
t.assert(result.includes(AnalysisKind.CodeQuality));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"getAnalysisKinds - only use `code-scanning` for multiple analysis kinds outside of test mode",
|
||||||
|
async (t) => {
|
||||||
|
setupBaseActionsVars();
|
||||||
|
process.env[EnvVar.TEST_MODE] = "false";
|
||||||
|
const features = createFeatures([]);
|
||||||
|
const logger = new RecordingLogger();
|
||||||
|
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
||||||
|
requiredInputStub
|
||||||
|
.withArgs("analysis-kinds")
|
||||||
|
.returns("code-scanning,code-quality");
|
||||||
|
const result = await getAnalysisKinds(logger, features, true);
|
||||||
|
t.deepEqual(result, [AnalysisKind.CodeScanning]);
|
||||||
|
t.assert(
|
||||||
|
logger.hasMessage(
|
||||||
|
"Continuing with only `analysis-kinds: code-scanning`.",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"getAnalysisKinds - logs error for non-default `analysis-kinds` in custom workflow",
|
||||||
|
async (t) => {
|
||||||
|
setupBaseActionsVars({ GITHUB_EVENT_NAME: "push" });
|
||||||
|
process.env[EnvVar.TEST_MODE] = "false";
|
||||||
|
const features = createFeatures([]);
|
||||||
|
const logger = new RecordingLogger();
|
||||||
|
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
||||||
|
requiredInputStub.withArgs("analysis-kinds").returns("code-quality");
|
||||||
|
const result = await getAnalysisKinds(logger, features, true);
|
||||||
|
t.deepEqual(result, [AnalysisKind.CodeQuality]);
|
||||||
|
t.assert(
|
||||||
|
logger.hasMessage(
|
||||||
|
"An analysis kind other than `code-scanning` was specified in a custom workflow.",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"getAnalysisKinds - no error for non-default `analysis-kinds` in managed workflow",
|
||||||
|
async (t) => {
|
||||||
|
setupBaseActionsVars({ GITHUB_EVENT_NAME: "dynamic" });
|
||||||
|
process.env[EnvVar.TEST_MODE] = "false";
|
||||||
|
const features = createFeatures([]);
|
||||||
|
const logger = new RecordingLogger();
|
||||||
|
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
||||||
|
requiredInputStub.withArgs("analysis-kinds").returns("code-quality");
|
||||||
|
const result = await getAnalysisKinds(logger, features, true);
|
||||||
|
t.deepEqual(result, [AnalysisKind.CodeQuality]);
|
||||||
|
t.deepEqual(logger.messages, []);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
test.serial(
|
test.serial(
|
||||||
"getAnalysisKinds - includes `code-quality` when deprecated `quality-queries` input is used",
|
"getAnalysisKinds - includes `code-quality` when deprecated `quality-queries` input is used",
|
||||||
async (t) => {
|
async (t) => {
|
||||||
|
process.env[EnvVar.TEST_MODE] = "true";
|
||||||
|
const features = createFeatures([]);
|
||||||
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
||||||
requiredInputStub.withArgs("analysis-kinds").returns("code-scanning");
|
requiredInputStub.withArgs("analysis-kinds").returns("code-scanning");
|
||||||
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
|
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
|
||||||
optionalInputStub.withArgs("quality-queries").returns("code-quality");
|
optionalInputStub.withArgs("quality-queries").returns("code-quality");
|
||||||
const result = await getAnalysisKinds(getRunnerLogger(true), true);
|
const result = await getAnalysisKinds(
|
||||||
|
getRunnerLogger(true),
|
||||||
|
features,
|
||||||
|
true,
|
||||||
|
);
|
||||||
t.assert(result.includes(AnalysisKind.CodeScanning));
|
t.assert(result.includes(AnalysisKind.CodeScanning));
|
||||||
t.assert(result.includes(AnalysisKind.CodeQuality));
|
t.assert(result.includes(AnalysisKind.CodeQuality));
|
||||||
},
|
},
|
||||||
@@ -79,9 +151,12 @@ test.serial(
|
|||||||
test.serial(
|
test.serial(
|
||||||
"getAnalysisKinds - throws if `analysis-kinds` input is invalid",
|
"getAnalysisKinds - throws if `analysis-kinds` input is invalid",
|
||||||
async (t) => {
|
async (t) => {
|
||||||
|
const features = createFeatures([]);
|
||||||
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
||||||
requiredInputStub.withArgs("analysis-kinds").returns("no-such-thing");
|
requiredInputStub.withArgs("analysis-kinds").returns("no-such-thing");
|
||||||
await t.throwsAsync(getAnalysisKinds(getRunnerLogger(true), true));
|
await t.throwsAsync(
|
||||||
|
getAnalysisKinds(getRunnerLogger(true), features, true),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -98,11 +173,18 @@ for (let i = 0; i < analysisKinds.length; i++) {
|
|||||||
test.serial(
|
test.serial(
|
||||||
`getAnalysisKinds - allows ${analysisKind} with ${otherAnalysis}`,
|
`getAnalysisKinds - allows ${analysisKind} with ${otherAnalysis}`,
|
||||||
async (t) => {
|
async (t) => {
|
||||||
|
setupBaseActionsVars();
|
||||||
|
process.env[EnvVar.TEST_MODE] = "true";
|
||||||
|
const features = createFeatures([]);
|
||||||
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
||||||
requiredInputStub
|
requiredInputStub
|
||||||
.withArgs("analysis-kinds")
|
.withArgs("analysis-kinds")
|
||||||
.returns([analysisKind, otherAnalysis].join(","));
|
.returns([analysisKind, otherAnalysis].join(","));
|
||||||
const result = await getAnalysisKinds(getRunnerLogger(true), true);
|
const result = await getAnalysisKinds(
|
||||||
|
getRunnerLogger(true),
|
||||||
|
features,
|
||||||
|
true,
|
||||||
|
);
|
||||||
t.is(result.length, 2);
|
t.is(result.length, 2);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -110,14 +192,19 @@ for (let i = 0; i < analysisKinds.length; i++) {
|
|||||||
test.serial(
|
test.serial(
|
||||||
`getAnalysisKinds - throws if ${analysisKind} is enabled with ${otherAnalysis}`,
|
`getAnalysisKinds - throws if ${analysisKind} is enabled with ${otherAnalysis}`,
|
||||||
async (t) => {
|
async (t) => {
|
||||||
|
setupBaseActionsVars();
|
||||||
|
const features = createFeatures([]);
|
||||||
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
||||||
requiredInputStub
|
requiredInputStub
|
||||||
.withArgs("analysis-kinds")
|
.withArgs("analysis-kinds")
|
||||||
.returns([analysisKind, otherAnalysis].join(","));
|
.returns([analysisKind, otherAnalysis].join(","));
|
||||||
await t.throwsAsync(getAnalysisKinds(getRunnerLogger(true), true), {
|
await t.throwsAsync(
|
||||||
instanceOf: ConfigurationError,
|
getAnalysisKinds(getRunnerLogger(true), features, true),
|
||||||
message: `${analysisKind} and ${otherAnalysis} cannot be enabled at the same time`,
|
{
|
||||||
});
|
instanceOf: ConfigurationError,
|
||||||
|
message: `${analysisKind} and ${otherAnalysis} cannot be enabled at the same time`,
|
||||||
|
},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+58
-1
@@ -2,15 +2,17 @@ import {
|
|||||||
fixCodeQualityCategory,
|
fixCodeQualityCategory,
|
||||||
getOptionalInput,
|
getOptionalInput,
|
||||||
getRequiredInput,
|
getRequiredInput,
|
||||||
|
isDynamicWorkflow,
|
||||||
} from "./actions-util";
|
} from "./actions-util";
|
||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
|
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
import {
|
import {
|
||||||
AssessmentPayload,
|
AssessmentPayload,
|
||||||
BasePayload,
|
BasePayload,
|
||||||
UploadPayload,
|
UploadPayload,
|
||||||
} from "./upload-lib/types";
|
} from "./upload-lib/types";
|
||||||
import { ConfigurationError, getRequiredEnvParam } from "./util";
|
import { ConfigurationError, getRequiredEnvParam, isInTestMode } from "./util";
|
||||||
|
|
||||||
export enum AnalysisKind {
|
export enum AnalysisKind {
|
||||||
CodeScanning = "code-scanning",
|
CodeScanning = "code-scanning",
|
||||||
@@ -64,6 +66,21 @@ export async function parseAnalysisKinds(
|
|||||||
// Used to avoid re-parsing the input after we have done it once.
|
// Used to avoid re-parsing the input after we have done it once.
|
||||||
let cachedAnalysisKinds: AnalysisKind[] | undefined;
|
let cachedAnalysisKinds: AnalysisKind[] | undefined;
|
||||||
|
|
||||||
|
/** Determines whether `code-scanning` is the only enabled analysis kind in `analysisKinds`. */
|
||||||
|
function isOnlyCodeScanningEnabled(analysisKinds: AnalysisKind[]) {
|
||||||
|
return (
|
||||||
|
analysisKinds.length === 1 && analysisKinds[0] === AnalysisKind.CodeScanning
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Prepends a generic message about the intended usage for `analysis-kinds` to `message`. */
|
||||||
|
function makeAnalysisKindUsageError(message: string) {
|
||||||
|
return (
|
||||||
|
"The `analysis-kinds` input is experimental and for GitHub-internal use only. " +
|
||||||
|
`Its behaviour may change at any time or be removed entirely. ${message}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialises the analysis kinds for the analysis based on the `analysis-kinds` input.
|
* Initialises the analysis kinds for the analysis based on the `analysis-kinds` input.
|
||||||
* This function will also use the deprecated `quality-queries` input as an indicator to enable `code-quality`.
|
* This function will also use the deprecated `quality-queries` input as an indicator to enable `code-quality`.
|
||||||
@@ -77,6 +94,7 @@ let cachedAnalysisKinds: AnalysisKind[] | undefined;
|
|||||||
*/
|
*/
|
||||||
export async function getAnalysisKinds(
|
export async function getAnalysisKinds(
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
|
features: FeatureEnablement,
|
||||||
skipCache: boolean = false,
|
skipCache: boolean = false,
|
||||||
): Promise<AnalysisKind[]> {
|
): Promise<AnalysisKind[]> {
|
||||||
if (!skipCache && cachedAnalysisKinds !== undefined) {
|
if (!skipCache && cachedAnalysisKinds !== undefined) {
|
||||||
@@ -87,6 +105,26 @@ export async function getAnalysisKinds(
|
|||||||
getRequiredInput("analysis-kinds"),
|
getRequiredInput("analysis-kinds"),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Log an error if we are outside of a GitHub-managed workflow and an analysis kind
|
||||||
|
// other than `code-scanning` is enabled.
|
||||||
|
if (
|
||||||
|
!isInTestMode() &&
|
||||||
|
!isDynamicWorkflow() &&
|
||||||
|
!isOnlyCodeScanningEnabled(analysisKinds)
|
||||||
|
) {
|
||||||
|
const codeQualityHint = analysisKinds.includes(AnalysisKind.CodeQuality)
|
||||||
|
? " If your intention is to use quality queries outside of Code Quality, " +
|
||||||
|
"use the `queries` input with `code-quality` instead."
|
||||||
|
: "";
|
||||||
|
|
||||||
|
logger.error(
|
||||||
|
makeAnalysisKindUsageError(
|
||||||
|
"An analysis kind other than `code-scanning` was specified in a custom workflow. " +
|
||||||
|
`This is not supported and will become a fatal error in a future version of the CodeQL Action.${codeQualityHint}`,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Warn that `quality-queries` is deprecated if there is an argument for it.
|
// Warn that `quality-queries` is deprecated if there is an argument for it.
|
||||||
const qualityQueriesInput = getOptionalInput("quality-queries");
|
const qualityQueriesInput = getOptionalInput("quality-queries");
|
||||||
|
|
||||||
@@ -120,6 +158,25 @@ export async function getAnalysisKinds(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Log an error if we have multiple inputs for `analysis-kinds` outside of test mode,
|
||||||
|
// and enable only `code-scanning`.
|
||||||
|
if (
|
||||||
|
!isInTestMode() &&
|
||||||
|
analysisKinds.length > 1 &&
|
||||||
|
!(await features.getValue(Feature.AllowMultipleAnalysisKinds))
|
||||||
|
) {
|
||||||
|
logger.error(
|
||||||
|
makeAnalysisKindUsageError(
|
||||||
|
"Specifying multiple values as input is no longer supported. " +
|
||||||
|
"Continuing with only `analysis-kinds: code-scanning`.",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Only enable Code Scanning.
|
||||||
|
cachedAnalysisKinds = [AnalysisKind.CodeScanning];
|
||||||
|
return cachedAnalysisKinds;
|
||||||
|
}
|
||||||
|
|
||||||
// Cache the analysis kinds and return them.
|
// Cache the analysis kinds and return them.
|
||||||
cachedAnalysisKinds = analysisKinds;
|
cachedAnalysisKinds = analysisKinds;
|
||||||
return cachedAnalysisKinds;
|
return cachedAnalysisKinds;
|
||||||
|
|||||||
@@ -1,90 +0,0 @@
|
|||||||
import test from "ava";
|
|
||||||
import * as sinon from "sinon";
|
|
||||||
|
|
||||||
import * as actionsUtil from "./actions-util";
|
|
||||||
import * as analyze from "./analyze";
|
|
||||||
import * as api from "./api-client";
|
|
||||||
import * as configUtils from "./config-utils";
|
|
||||||
import * as gitUtils from "./git-utils";
|
|
||||||
import * as statusReport from "./status-report";
|
|
||||||
import {
|
|
||||||
setupTests,
|
|
||||||
setupActionsVars,
|
|
||||||
mockFeatureFlagApiEndpoint,
|
|
||||||
} from "./testing-utils";
|
|
||||||
import * as util from "./util";
|
|
||||||
|
|
||||||
setupTests(test);
|
|
||||||
|
|
||||||
// This test needs to be in its own file so that ava would run it in its own
|
|
||||||
// nodejs process. The code being tested is in analyze-action.ts, which runs
|
|
||||||
// immediately on load. So the file needs to be loaded during part of the test,
|
|
||||||
// and that can happen only once per nodejs process. If multiple such tests are
|
|
||||||
// in the same test file, ava would run them in the same nodejs process, and all
|
|
||||||
// but the first test would fail.
|
|
||||||
|
|
||||||
test("analyze action with RAM & threads from environment variables", async (t) => {
|
|
||||||
// This test frequently times out on Windows with the default timeout, so we bump
|
|
||||||
// it a bit to 20s.
|
|
||||||
t.timeout(1000 * 20);
|
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
|
||||||
setupActionsVars(tmpDir, tmpDir);
|
|
||||||
sinon
|
|
||||||
.stub(statusReport, "createStatusReportBase")
|
|
||||||
.resolves({} as statusReport.StatusReportBase);
|
|
||||||
sinon.stub(statusReport, "sendStatusReport").resolves();
|
|
||||||
sinon.stub(gitUtils, "isAnalyzingDefaultBranch").resolves(true);
|
|
||||||
|
|
||||||
const gitHubVersion: util.GitHubVersion = {
|
|
||||||
type: util.GitHubVariant.DOTCOM,
|
|
||||||
};
|
|
||||||
sinon.stub(configUtils, "getConfig").resolves({
|
|
||||||
gitHubVersion,
|
|
||||||
augmentationProperties: {},
|
|
||||||
languages: [],
|
|
||||||
packs: [],
|
|
||||||
trapCaches: {},
|
|
||||||
} as unknown as configUtils.Config);
|
|
||||||
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
|
||||||
requiredInputStub.withArgs("token").returns("fake-token");
|
|
||||||
requiredInputStub.withArgs("upload-database").returns("false");
|
|
||||||
requiredInputStub.withArgs("output").returns("out");
|
|
||||||
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
|
|
||||||
optionalInputStub.withArgs("expect-error").returns("false");
|
|
||||||
sinon.stub(api, "getGitHubVersion").resolves(gitHubVersion);
|
|
||||||
mockFeatureFlagApiEndpoint(200, {});
|
|
||||||
|
|
||||||
// When there are no action inputs for RAM and threads, the action uses
|
|
||||||
// environment variables (passed down from the init action) to set RAM and
|
|
||||||
// threads usage.
|
|
||||||
process.env["CODEQL_THREADS"] = "-1";
|
|
||||||
process.env["CODEQL_RAM"] = "4992";
|
|
||||||
|
|
||||||
const runFinalizeStub = sinon.stub(analyze, "runFinalize");
|
|
||||||
const runQueriesStub = sinon.stub(analyze, "runQueries");
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
||||||
const analyzeAction = require("./analyze-action");
|
|
||||||
|
|
||||||
// When analyze-action.ts loads, it runs an async function from the top
|
|
||||||
// level but does not wait for it to finish. To ensure that calls to
|
|
||||||
// runFinalize and runQueries are correctly captured by spies, we explicitly
|
|
||||||
// wait for the action promise to complete before starting verification.
|
|
||||||
await analyzeAction.runPromise;
|
|
||||||
|
|
||||||
t.assert(
|
|
||||||
runFinalizeStub.calledOnceWith(
|
|
||||||
sinon.match.any,
|
|
||||||
sinon.match.any,
|
|
||||||
"--threads=-1",
|
|
||||||
"--ram=4992",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
t.assert(
|
|
||||||
runQueriesStub.calledOnceWith(
|
|
||||||
sinon.match.any,
|
|
||||||
"--ram=4992",
|
|
||||||
"--threads=-1",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
import test from "ava";
|
|
||||||
import * as sinon from "sinon";
|
|
||||||
|
|
||||||
import * as actionsUtil from "./actions-util";
|
|
||||||
import * as analyze from "./analyze";
|
|
||||||
import * as api from "./api-client";
|
|
||||||
import * as configUtils from "./config-utils";
|
|
||||||
import * as gitUtils from "./git-utils";
|
|
||||||
import * as statusReport from "./status-report";
|
|
||||||
import {
|
|
||||||
setupTests,
|
|
||||||
setupActionsVars,
|
|
||||||
mockFeatureFlagApiEndpoint,
|
|
||||||
} from "./testing-utils";
|
|
||||||
import * as util from "./util";
|
|
||||||
|
|
||||||
setupTests(test);
|
|
||||||
|
|
||||||
// This test needs to be in its own file so that ava would run it in its own
|
|
||||||
// nodejs process. The code being tested is in analyze-action.ts, which runs
|
|
||||||
// immediately on load. So the file needs to be loaded during part of the test,
|
|
||||||
// and that can happen only once per nodejs process. If multiple such tests are
|
|
||||||
// in the same test file, ava would run them in the same nodejs process, and all
|
|
||||||
// but the first test would fail.
|
|
||||||
|
|
||||||
test("analyze action with RAM & threads from action inputs", async (t) => {
|
|
||||||
t.timeout(1000 * 20);
|
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
|
||||||
setupActionsVars(tmpDir, tmpDir);
|
|
||||||
sinon
|
|
||||||
.stub(statusReport, "createStatusReportBase")
|
|
||||||
.resolves({} as statusReport.StatusReportBase);
|
|
||||||
sinon.stub(statusReport, "sendStatusReport").resolves();
|
|
||||||
const gitHubVersion: util.GitHubVersion = {
|
|
||||||
type: util.GitHubVariant.DOTCOM,
|
|
||||||
};
|
|
||||||
sinon.stub(configUtils, "getConfig").resolves({
|
|
||||||
gitHubVersion,
|
|
||||||
augmentationProperties: {},
|
|
||||||
languages: [],
|
|
||||||
packs: [],
|
|
||||||
trapCaches: {},
|
|
||||||
} as unknown as configUtils.Config);
|
|
||||||
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
|
||||||
requiredInputStub.withArgs("token").returns("fake-token");
|
|
||||||
requiredInputStub.withArgs("upload-database").returns("false");
|
|
||||||
requiredInputStub.withArgs("output").returns("out");
|
|
||||||
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
|
|
||||||
optionalInputStub.withArgs("expect-error").returns("false");
|
|
||||||
sinon.stub(api, "getGitHubVersion").resolves(gitHubVersion);
|
|
||||||
sinon.stub(gitUtils, "isAnalyzingDefaultBranch").resolves(true);
|
|
||||||
mockFeatureFlagApiEndpoint(200, {});
|
|
||||||
|
|
||||||
process.env["CODEQL_THREADS"] = "1";
|
|
||||||
process.env["CODEQL_RAM"] = "4992";
|
|
||||||
|
|
||||||
// Action inputs have precedence over environment variables.
|
|
||||||
optionalInputStub.withArgs("threads").returns("-1");
|
|
||||||
optionalInputStub.withArgs("ram").returns("3012");
|
|
||||||
|
|
||||||
const runFinalizeStub = sinon.stub(analyze, "runFinalize");
|
|
||||||
const runQueriesStub = sinon.stub(analyze, "runQueries");
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
||||||
const analyzeAction = require("./analyze-action");
|
|
||||||
|
|
||||||
// When analyze-action.ts loads, it runs an async function from the top
|
|
||||||
// level but does not wait for it to finish. To ensure that calls to
|
|
||||||
// runFinalize and runQueries are correctly captured by spies, we explicitly
|
|
||||||
// wait for the action promise to complete before starting verification.
|
|
||||||
await analyzeAction.runPromise;
|
|
||||||
|
|
||||||
t.assert(
|
|
||||||
runFinalizeStub.calledOnceWith(
|
|
||||||
sinon.match.any,
|
|
||||||
sinon.match.any,
|
|
||||||
"--threads=-1",
|
|
||||||
"--ram=3012",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
t.assert(
|
|
||||||
runQueriesStub.calledOnceWith(
|
|
||||||
sinon.match.any,
|
|
||||||
"--ram=3012",
|
|
||||||
"--threads=-1",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -20,7 +20,7 @@ import { EnvVar } from "./environment";
|
|||||||
import { getActionsLogger } from "./logging";
|
import { getActionsLogger } from "./logging";
|
||||||
import { checkGitHubVersionInRange, getErrorMessage } from "./util";
|
import { checkGitHubVersionInRange, getErrorMessage } from "./util";
|
||||||
|
|
||||||
async function runWrapper() {
|
export async function runWrapper() {
|
||||||
// To capture errors appropriately, keep as much code within the try-catch as
|
// To capture errors appropriately, keep as much code within the try-catch as
|
||||||
// possible, and only use safe functions outside.
|
// possible, and only use safe functions outside.
|
||||||
|
|
||||||
@@ -72,5 +72,3 @@ async function runWrapper() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void runWrapper();
|
|
||||||
|
|||||||
@@ -0,0 +1,142 @@
|
|||||||
|
import test from "ava";
|
||||||
|
import * as sinon from "sinon";
|
||||||
|
|
||||||
|
import * as actionsUtil from "./actions-util";
|
||||||
|
import * as analyze from "./analyze";
|
||||||
|
import { runWrapper } from "./analyze-action";
|
||||||
|
import * as api from "./api-client";
|
||||||
|
import * as configUtils from "./config-utils";
|
||||||
|
import * as gitUtils from "./git-utils";
|
||||||
|
import * as statusReport from "./status-report";
|
||||||
|
import {
|
||||||
|
setupTests,
|
||||||
|
setupActionsVars,
|
||||||
|
mockFeatureFlagApiEndpoint,
|
||||||
|
} from "./testing-utils";
|
||||||
|
import * as util from "./util";
|
||||||
|
|
||||||
|
setupTests(test);
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"analyze action with RAM & threads from environment variables",
|
||||||
|
async (t) => {
|
||||||
|
// This test frequently times out on Windows with the default timeout, so we bump
|
||||||
|
// it a bit to 20s.
|
||||||
|
t.timeout(1000 * 20);
|
||||||
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
|
setupActionsVars(tmpDir, tmpDir);
|
||||||
|
sinon
|
||||||
|
.stub(statusReport, "createStatusReportBase")
|
||||||
|
.resolves({} as statusReport.StatusReportBase);
|
||||||
|
sinon.stub(statusReport, "sendStatusReport").resolves();
|
||||||
|
sinon.stub(gitUtils, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
|
|
||||||
|
const gitHubVersion: util.GitHubVersion = {
|
||||||
|
type: util.GitHubVariant.DOTCOM,
|
||||||
|
};
|
||||||
|
sinon.stub(configUtils, "getConfig").resolves({
|
||||||
|
gitHubVersion,
|
||||||
|
augmentationProperties: {},
|
||||||
|
languages: [],
|
||||||
|
packs: [],
|
||||||
|
trapCaches: {},
|
||||||
|
} as unknown as configUtils.Config);
|
||||||
|
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
||||||
|
requiredInputStub.withArgs("token").returns("fake-token");
|
||||||
|
requiredInputStub.withArgs("upload-database").returns("false");
|
||||||
|
requiredInputStub.withArgs("output").returns("out");
|
||||||
|
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
|
||||||
|
optionalInputStub.withArgs("expect-error").returns("false");
|
||||||
|
sinon.stub(api, "getGitHubVersion").resolves(gitHubVersion);
|
||||||
|
mockFeatureFlagApiEndpoint(200, {});
|
||||||
|
|
||||||
|
// When there are no action inputs for RAM and threads, the action uses
|
||||||
|
// environment variables (passed down from the init action) to set RAM and
|
||||||
|
// threads usage.
|
||||||
|
process.env["CODEQL_THREADS"] = "-1";
|
||||||
|
process.env["CODEQL_RAM"] = "4992";
|
||||||
|
|
||||||
|
const runFinalizeStub = sinon.stub(analyze, "runFinalize");
|
||||||
|
const runQueriesStub = sinon.stub(analyze, "runQueries");
|
||||||
|
|
||||||
|
await runWrapper();
|
||||||
|
|
||||||
|
t.assert(
|
||||||
|
runFinalizeStub.calledOnceWith(
|
||||||
|
sinon.match.any,
|
||||||
|
sinon.match.any,
|
||||||
|
"--threads=-1",
|
||||||
|
"--ram=4992",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
t.assert(
|
||||||
|
runQueriesStub.calledOnceWith(
|
||||||
|
sinon.match.any,
|
||||||
|
"--ram=4992",
|
||||||
|
"--threads=-1",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"analyze action with RAM & threads from action inputs",
|
||||||
|
async (t) => {
|
||||||
|
t.timeout(1000 * 20);
|
||||||
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
|
setupActionsVars(tmpDir, tmpDir);
|
||||||
|
sinon
|
||||||
|
.stub(statusReport, "createStatusReportBase")
|
||||||
|
.resolves({} as statusReport.StatusReportBase);
|
||||||
|
sinon.stub(statusReport, "sendStatusReport").resolves();
|
||||||
|
const gitHubVersion: util.GitHubVersion = {
|
||||||
|
type: util.GitHubVariant.DOTCOM,
|
||||||
|
};
|
||||||
|
sinon.stub(configUtils, "getConfig").resolves({
|
||||||
|
gitHubVersion,
|
||||||
|
augmentationProperties: {},
|
||||||
|
languages: [],
|
||||||
|
packs: [],
|
||||||
|
trapCaches: {},
|
||||||
|
} as unknown as configUtils.Config);
|
||||||
|
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
||||||
|
requiredInputStub.withArgs("token").returns("fake-token");
|
||||||
|
requiredInputStub.withArgs("upload-database").returns("false");
|
||||||
|
requiredInputStub.withArgs("output").returns("out");
|
||||||
|
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
|
||||||
|
optionalInputStub.withArgs("expect-error").returns("false");
|
||||||
|
sinon.stub(api, "getGitHubVersion").resolves(gitHubVersion);
|
||||||
|
sinon.stub(gitUtils, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
|
mockFeatureFlagApiEndpoint(200, {});
|
||||||
|
|
||||||
|
process.env["CODEQL_THREADS"] = "1";
|
||||||
|
process.env["CODEQL_RAM"] = "4992";
|
||||||
|
|
||||||
|
// Action inputs have precedence over environment variables.
|
||||||
|
optionalInputStub.withArgs("threads").returns("-1");
|
||||||
|
optionalInputStub.withArgs("ram").returns("3012");
|
||||||
|
|
||||||
|
const runFinalizeStub = sinon.stub(analyze, "runFinalize");
|
||||||
|
const runQueriesStub = sinon.stub(analyze, "runQueries");
|
||||||
|
|
||||||
|
await runWrapper();
|
||||||
|
|
||||||
|
t.assert(
|
||||||
|
runFinalizeStub.calledOnceWith(
|
||||||
|
sinon.match.any,
|
||||||
|
sinon.match.any,
|
||||||
|
"--threads=-1",
|
||||||
|
"--ram=3012",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
t.assert(
|
||||||
|
runQueriesStub.calledOnceWith(
|
||||||
|
sinon.match.any,
|
||||||
|
"--ram=3012",
|
||||||
|
"--threads=-1",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
@@ -523,14 +523,11 @@ async function run(startedAt: Date) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Module-level startedAt so it can be accessed by runWrapper for error reporting
|
export async function runWrapper() {
|
||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
export const runPromise = run(startedAt);
|
|
||||||
|
|
||||||
async function runWrapper() {
|
|
||||||
const logger = getActionsLogger();
|
const logger = getActionsLogger();
|
||||||
try {
|
try {
|
||||||
await runPromise;
|
await run(startedAt);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(`analyze action failed: ${util.getErrorMessage(error)}`);
|
core.setFailed(`analyze action failed: ${util.getErrorMessage(error)}`);
|
||||||
await sendUnhandledErrorStatusReport(
|
await sendUnhandledErrorStatusReport(
|
||||||
@@ -542,5 +539,3 @@ async function runWrapper() {
|
|||||||
}
|
}
|
||||||
await util.checkForTimeout();
|
await util.checkForTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void runWrapper();
|
|
||||||
|
|||||||
@@ -141,9 +141,9 @@ test("scanArtifactsForTokens handles files without tokens", async (t) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// `scanArchiveFile` does not support Windows, so we skip this test there.
|
||||||
if (os.platform() !== "win32") {
|
if (os.platform() !== "win32") {
|
||||||
test("scanArtifactsForTokens finds token in debug artifacts", async (t) => {
|
test("scanArtifactsForTokens finds token in debug artifacts", async (t) => {
|
||||||
t.timeout(15000); // 15 seconds
|
|
||||||
const messages: LoggedMessage[] = [];
|
const messages: LoggedMessage[] = [];
|
||||||
const logger = getRecordingLogger(messages, { logToConsole: false });
|
const logger = getRecordingLogger(messages, { logToConsole: false });
|
||||||
// The zip here is a regression test based on
|
// The zip here is a regression test based on
|
||||||
|
|||||||
@@ -156,6 +156,10 @@ async function scanArchiveFile(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
throw new Error("Scanning archives is not supported on Windows.");
|
||||||
|
}
|
||||||
|
|
||||||
const result: ScanResult = {
|
const result: ScanResult = {
|
||||||
scannedFiles: 0,
|
scannedFiles: 0,
|
||||||
findings: [],
|
findings: [],
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ async function run(startedAt: Date) {
|
|||||||
await sendCompletedStatusReport(config, logger, startedAt, languages ?? []);
|
await sendCompletedStatusReport(config, logger, startedAt, languages ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runWrapper() {
|
export async function runWrapper() {
|
||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
const logger = getActionsLogger();
|
const logger = getActionsLogger();
|
||||||
try {
|
try {
|
||||||
@@ -157,5 +157,3 @@ async function runWrapper() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void runWrapper();
|
|
||||||
|
|||||||
+58
-38
@@ -33,6 +33,7 @@ import {
|
|||||||
mockBundleDownloadApi,
|
mockBundleDownloadApi,
|
||||||
makeVersionInfo,
|
makeVersionInfo,
|
||||||
createTestConfig,
|
createTestConfig,
|
||||||
|
makeMacro,
|
||||||
} from "./testing-utils";
|
} from "./testing-utils";
|
||||||
import { ToolsDownloadStatusReport } from "./tools-download";
|
import { ToolsDownloadStatusReport } from "./tools-download";
|
||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
@@ -70,8 +71,10 @@ async function installIntoToolcache({
|
|||||||
tmpDir,
|
tmpDir,
|
||||||
util.GitHubVariant.GHES,
|
util.GitHubVariant.GHES,
|
||||||
cliVersion !== undefined
|
cliVersion !== undefined
|
||||||
? { cliVersion, tagName }
|
? { enabledVersions: [{ cliVersion, tagName }] }
|
||||||
: SAMPLE_DEFAULT_CLI_VERSION,
|
: SAMPLE_DEFAULT_CLI_VERSION,
|
||||||
|
undefined, // rawLanguages
|
||||||
|
false, // useOverlayAwareDefaultCliVersion
|
||||||
createFeatures([]),
|
createFeatures([]),
|
||||||
getRunnerLogger(true),
|
getRunnerLogger(true),
|
||||||
false,
|
false,
|
||||||
@@ -143,6 +146,8 @@ test.serial(
|
|||||||
tmpDir,
|
tmpDir,
|
||||||
util.GitHubVariant.DOTCOM,
|
util.GitHubVariant.DOTCOM,
|
||||||
SAMPLE_DEFAULT_CLI_VERSION,
|
SAMPLE_DEFAULT_CLI_VERSION,
|
||||||
|
undefined, // rawLanguages
|
||||||
|
false, // useOverlayAwareDefaultCliVersion
|
||||||
features,
|
features,
|
||||||
getRunnerLogger(true),
|
getRunnerLogger(true),
|
||||||
false,
|
false,
|
||||||
@@ -175,6 +180,8 @@ test.serial(
|
|||||||
tmpDir,
|
tmpDir,
|
||||||
util.GitHubVariant.DOTCOM,
|
util.GitHubVariant.DOTCOM,
|
||||||
SAMPLE_DEFAULT_CLI_VERSION,
|
SAMPLE_DEFAULT_CLI_VERSION,
|
||||||
|
undefined, // rawLanguages
|
||||||
|
false, // useOverlayAwareDefaultCliVersion
|
||||||
features,
|
features,
|
||||||
getRunnerLogger(true),
|
getRunnerLogger(true),
|
||||||
false,
|
false,
|
||||||
@@ -214,6 +221,8 @@ test.serial(
|
|||||||
tmpDir,
|
tmpDir,
|
||||||
util.GitHubVariant.DOTCOM,
|
util.GitHubVariant.DOTCOM,
|
||||||
SAMPLE_DEFAULT_CLI_VERSION,
|
SAMPLE_DEFAULT_CLI_VERSION,
|
||||||
|
undefined, // rawLanguages
|
||||||
|
false, // useOverlayAwareDefaultCliVersion
|
||||||
features,
|
features,
|
||||||
getRunnerLogger(true),
|
getRunnerLogger(true),
|
||||||
false,
|
false,
|
||||||
@@ -264,6 +273,8 @@ for (const {
|
|||||||
tmpDir,
|
tmpDir,
|
||||||
util.GitHubVariant.DOTCOM,
|
util.GitHubVariant.DOTCOM,
|
||||||
SAMPLE_DEFAULT_CLI_VERSION,
|
SAMPLE_DEFAULT_CLI_VERSION,
|
||||||
|
undefined, // rawLanguages
|
||||||
|
false, // useOverlayAwareDefaultCliVersion
|
||||||
features,
|
features,
|
||||||
getRunnerLogger(true),
|
getRunnerLogger(true),
|
||||||
false,
|
false,
|
||||||
@@ -284,11 +295,11 @@ for (const {
|
|||||||
for (const toolcacheVersion of [
|
for (const toolcacheVersion of [
|
||||||
// Test that we use the tools from the toolcache when `SAMPLE_DEFAULT_CLI_VERSION` is requested
|
// Test that we use the tools from the toolcache when `SAMPLE_DEFAULT_CLI_VERSION` is requested
|
||||||
// and `SAMPLE_DEFAULT_CLI_VERSION-` is in the toolcache.
|
// and `SAMPLE_DEFAULT_CLI_VERSION-` is in the toolcache.
|
||||||
SAMPLE_DEFAULT_CLI_VERSION.cliVersion,
|
SAMPLE_DEFAULT_CLI_VERSION.enabledVersions[0].cliVersion,
|
||||||
`${SAMPLE_DEFAULT_CLI_VERSION.cliVersion}-20230101`,
|
`${SAMPLE_DEFAULT_CLI_VERSION.enabledVersions[0].cliVersion}-20230101`,
|
||||||
]) {
|
]) {
|
||||||
test.serial(
|
test.serial(
|
||||||
`uses tools from toolcache when ${SAMPLE_DEFAULT_CLI_VERSION.cliVersion} is requested and ` +
|
`uses tools from toolcache when ${SAMPLE_DEFAULT_CLI_VERSION.enabledVersions[0].cliVersion} is requested and ` +
|
||||||
`${toolcacheVersion} is installed`,
|
`${toolcacheVersion} is installed`,
|
||||||
async (t) => {
|
async (t) => {
|
||||||
const features = createFeatures([]);
|
const features = createFeatures([]);
|
||||||
@@ -308,11 +319,16 @@ for (const toolcacheVersion of [
|
|||||||
tmpDir,
|
tmpDir,
|
||||||
util.GitHubVariant.DOTCOM,
|
util.GitHubVariant.DOTCOM,
|
||||||
SAMPLE_DEFAULT_CLI_VERSION,
|
SAMPLE_DEFAULT_CLI_VERSION,
|
||||||
|
undefined, // rawLanguages
|
||||||
|
false, // useOverlayAwareDefaultCliVersion
|
||||||
features,
|
features,
|
||||||
getRunnerLogger(true),
|
getRunnerLogger(true),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
t.is(result.toolsVersion, SAMPLE_DEFAULT_CLI_VERSION.cliVersion);
|
t.is(
|
||||||
|
result.toolsVersion,
|
||||||
|
SAMPLE_DEFAULT_CLI_VERSION.enabledVersions[0].cliVersion,
|
||||||
|
);
|
||||||
t.is(result.toolsSource, ToolsSource.Toolcache);
|
t.is(result.toolsSource, ToolsSource.Toolcache);
|
||||||
t.is(result.toolsDownloadStatusReport?.combinedDurationMs, undefined);
|
t.is(result.toolsDownloadStatusReport?.combinedDurationMs, undefined);
|
||||||
t.is(result.toolsDownloadStatusReport?.downloadDurationMs, undefined);
|
t.is(result.toolsDownloadStatusReport?.downloadDurationMs, undefined);
|
||||||
@@ -342,9 +358,15 @@ test.serial(
|
|||||||
tmpDir,
|
tmpDir,
|
||||||
util.GitHubVariant.GHES,
|
util.GitHubVariant.GHES,
|
||||||
{
|
{
|
||||||
cliVersion: defaults.cliVersion,
|
enabledVersions: [
|
||||||
tagName: defaults.bundleVersion,
|
{
|
||||||
|
cliVersion: defaults.cliVersion,
|
||||||
|
tagName: defaults.bundleVersion,
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
|
undefined, // rawLanguages
|
||||||
|
false, // useOverlayAwareDefaultCliVersion
|
||||||
features,
|
features,
|
||||||
getRunnerLogger(true),
|
getRunnerLogger(true),
|
||||||
false,
|
false,
|
||||||
@@ -384,9 +406,15 @@ test.serial(
|
|||||||
tmpDir,
|
tmpDir,
|
||||||
util.GitHubVariant.GHES,
|
util.GitHubVariant.GHES,
|
||||||
{
|
{
|
||||||
cliVersion: defaults.cliVersion,
|
enabledVersions: [
|
||||||
tagName: defaults.bundleVersion,
|
{
|
||||||
|
cliVersion: defaults.cliVersion,
|
||||||
|
tagName: defaults.bundleVersion,
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
|
undefined, // rawLanguages
|
||||||
|
false, // useOverlayAwareDefaultCliVersion
|
||||||
features,
|
features,
|
||||||
getRunnerLogger(true),
|
getRunnerLogger(true),
|
||||||
false,
|
false,
|
||||||
@@ -426,6 +454,8 @@ test.serial(
|
|||||||
tmpDir,
|
tmpDir,
|
||||||
util.GitHubVariant.DOTCOM,
|
util.GitHubVariant.DOTCOM,
|
||||||
SAMPLE_DEFAULT_CLI_VERSION,
|
SAMPLE_DEFAULT_CLI_VERSION,
|
||||||
|
undefined, // rawLanguages
|
||||||
|
false, // useOverlayAwareDefaultCliVersion
|
||||||
features,
|
features,
|
||||||
getRunnerLogger(true),
|
getRunnerLogger(true),
|
||||||
false,
|
false,
|
||||||
@@ -467,6 +497,8 @@ test.serial(
|
|||||||
tmpDir,
|
tmpDir,
|
||||||
util.GitHubVariant.DOTCOM,
|
util.GitHubVariant.DOTCOM,
|
||||||
SAMPLE_DEFAULT_CLI_VERSION,
|
SAMPLE_DEFAULT_CLI_VERSION,
|
||||||
|
undefined, // rawLanguages
|
||||||
|
false, // useOverlayAwareDefaultCliVersion
|
||||||
features,
|
features,
|
||||||
getRunnerLogger(true),
|
getRunnerLogger(true),
|
||||||
false,
|
false,
|
||||||
@@ -540,7 +572,7 @@ test.serial("getExtraOptions throws for bad content", (t) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Test macro for ensuring different variants of injected augmented configurations
|
// Test macro for ensuring different variants of injected augmented configurations
|
||||||
const injectedConfigMacro = test.macro({
|
const injectedConfigMacro = makeMacro({
|
||||||
exec: async (
|
exec: async (
|
||||||
t: ExecutionContext<unknown>,
|
t: ExecutionContext<unknown>,
|
||||||
augmentationProperties: AugmentationProperties,
|
augmentationProperties: AugmentationProperties,
|
||||||
@@ -590,9 +622,8 @@ const injectedConfigMacro = test.macro({
|
|||||||
`databaseInitCluster() injected config: ${providedTitle}`,
|
`databaseInitCluster() injected config: ${providedTitle}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
test.serial(
|
injectedConfigMacro.serial(
|
||||||
"basic",
|
"basic",
|
||||||
injectedConfigMacro,
|
|
||||||
{
|
{
|
||||||
...defaultAugmentationProperties,
|
...defaultAugmentationProperties,
|
||||||
},
|
},
|
||||||
@@ -600,9 +631,8 @@ test.serial(
|
|||||||
{},
|
{},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
injectedConfigMacro.serial(
|
||||||
"injected packs from input",
|
"injected packs from input",
|
||||||
injectedConfigMacro,
|
|
||||||
{
|
{
|
||||||
...defaultAugmentationProperties,
|
...defaultAugmentationProperties,
|
||||||
packsInput: ["xxx", "yyy"],
|
packsInput: ["xxx", "yyy"],
|
||||||
@@ -613,9 +643,8 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
injectedConfigMacro.serial(
|
||||||
"injected packs from input with existing packs combines",
|
"injected packs from input with existing packs combines",
|
||||||
injectedConfigMacro,
|
|
||||||
{
|
{
|
||||||
...defaultAugmentationProperties,
|
...defaultAugmentationProperties,
|
||||||
packsInputCombines: true,
|
packsInputCombines: true,
|
||||||
@@ -635,9 +664,8 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
injectedConfigMacro.serial(
|
||||||
"injected packs from input with existing packs overrides",
|
"injected packs from input with existing packs overrides",
|
||||||
injectedConfigMacro,
|
|
||||||
{
|
{
|
||||||
...defaultAugmentationProperties,
|
...defaultAugmentationProperties,
|
||||||
packsInput: ["xxx", "yyy"],
|
packsInput: ["xxx", "yyy"],
|
||||||
@@ -655,9 +683,8 @@ test.serial(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// similar, but with queries
|
// similar, but with queries
|
||||||
test.serial(
|
injectedConfigMacro.serial(
|
||||||
"injected queries from input",
|
"injected queries from input",
|
||||||
injectedConfigMacro,
|
|
||||||
{
|
{
|
||||||
...defaultAugmentationProperties,
|
...defaultAugmentationProperties,
|
||||||
queriesInput: [{ uses: "xxx" }, { uses: "yyy" }],
|
queriesInput: [{ uses: "xxx" }, { uses: "yyy" }],
|
||||||
@@ -675,9 +702,8 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
injectedConfigMacro.serial(
|
||||||
"injected queries from input overrides",
|
"injected queries from input overrides",
|
||||||
injectedConfigMacro,
|
|
||||||
{
|
{
|
||||||
...defaultAugmentationProperties,
|
...defaultAugmentationProperties,
|
||||||
queriesInput: [{ uses: "xxx" }, { uses: "yyy" }],
|
queriesInput: [{ uses: "xxx" }, { uses: "yyy" }],
|
||||||
@@ -699,9 +725,8 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
injectedConfigMacro.serial(
|
||||||
"injected queries from input combines",
|
"injected queries from input combines",
|
||||||
injectedConfigMacro,
|
|
||||||
{
|
{
|
||||||
...defaultAugmentationProperties,
|
...defaultAugmentationProperties,
|
||||||
queriesInputCombines: true,
|
queriesInputCombines: true,
|
||||||
@@ -727,9 +752,8 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
injectedConfigMacro.serial(
|
||||||
"injected queries from input combines 2",
|
"injected queries from input combines 2",
|
||||||
injectedConfigMacro,
|
|
||||||
{
|
{
|
||||||
...defaultAugmentationProperties,
|
...defaultAugmentationProperties,
|
||||||
queriesInputCombines: true,
|
queriesInputCombines: true,
|
||||||
@@ -749,9 +773,8 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
injectedConfigMacro.serial(
|
||||||
"injected queries and packs, but empty",
|
"injected queries and packs, but empty",
|
||||||
injectedConfigMacro,
|
|
||||||
{
|
{
|
||||||
...defaultAugmentationProperties,
|
...defaultAugmentationProperties,
|
||||||
queriesInputCombines: true,
|
queriesInputCombines: true,
|
||||||
@@ -768,9 +791,8 @@ test.serial(
|
|||||||
{},
|
{},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
injectedConfigMacro.serial(
|
||||||
"repo property queries have the highest precedence",
|
"repo property queries have the highest precedence",
|
||||||
injectedConfigMacro,
|
|
||||||
{
|
{
|
||||||
...defaultAugmentationProperties,
|
...defaultAugmentationProperties,
|
||||||
queriesInputCombines: true,
|
queriesInputCombines: true,
|
||||||
@@ -790,9 +812,8 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
injectedConfigMacro.serial(
|
||||||
"repo property queries combines with queries input",
|
"repo property queries combines with queries input",
|
||||||
injectedConfigMacro,
|
|
||||||
{
|
{
|
||||||
...defaultAugmentationProperties,
|
...defaultAugmentationProperties,
|
||||||
queriesInputCombines: false,
|
queriesInputCombines: false,
|
||||||
@@ -817,9 +838,8 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
injectedConfigMacro.serial(
|
||||||
"repo property queries combines everything else",
|
"repo property queries combines everything else",
|
||||||
injectedConfigMacro,
|
|
||||||
{
|
{
|
||||||
...defaultAugmentationProperties,
|
...defaultAugmentationProperties,
|
||||||
queriesInputCombines: true,
|
queriesInputCombines: true,
|
||||||
@@ -1052,7 +1072,7 @@ test.serial(
|
|||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
test.serial(
|
||||||
"Avoids duplicating --overwrite flag if specified in CODEQL_ACTION_EXTRA_OPTIONS",
|
"Avoids duplicating --force-overwrite flag if specified in CODEQL_ACTION_EXTRA_OPTIONS",
|
||||||
async (t) => {
|
async (t) => {
|
||||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||||
const codeqlObject = await stubCodeql();
|
const codeqlObject = await stubCodeql();
|
||||||
@@ -1060,7 +1080,7 @@ test.serial(
|
|||||||
sinon.stub(io, "which").resolves("");
|
sinon.stub(io, "which").resolves("");
|
||||||
|
|
||||||
process.env["CODEQL_ACTION_EXTRA_OPTIONS"] =
|
process.env["CODEQL_ACTION_EXTRA_OPTIONS"] =
|
||||||
'{ "database": { "init": ["--overwrite"] } }';
|
'{ "database": { "init": ["--force-overwrite"] } }';
|
||||||
|
|
||||||
await codeqlObject.databaseInitCluster(
|
await codeqlObject.databaseInitCluster(
|
||||||
stubConfig,
|
stubConfig,
|
||||||
@@ -1073,9 +1093,9 @@ test.serial(
|
|||||||
t.true(runnerConstructorStub.calledOnce);
|
t.true(runnerConstructorStub.calledOnce);
|
||||||
const args = runnerConstructorStub.firstCall.args[1] as string[];
|
const args = runnerConstructorStub.firstCall.args[1] as string[];
|
||||||
t.is(
|
t.is(
|
||||||
args.filter((option: string) => option === "--overwrite").length,
|
args.filter((option: string) => option === "--force-overwrite").length,
|
||||||
1,
|
1,
|
||||||
"--overwrite should only be passed once",
|
"--force-overwrite should only be passed once",
|
||||||
);
|
);
|
||||||
|
|
||||||
// Clean up
|
// Clean up
|
||||||
|
|||||||
+19
-18
@@ -277,7 +277,7 @@ let cachedCodeQL: CodeQL | undefined = undefined;
|
|||||||
* The version flags below can be used to conditionally enable certain features
|
* The version flags below can be used to conditionally enable certain features
|
||||||
* on versions newer than this.
|
* on versions newer than this.
|
||||||
*/
|
*/
|
||||||
const CODEQL_MINIMUM_VERSION = "2.17.6";
|
const CODEQL_MINIMUM_VERSION = "2.19.4";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This version will shortly become the oldest version of CodeQL that the Action will run with.
|
* This version will shortly become the oldest version of CodeQL that the Action will run with.
|
||||||
@@ -305,6 +305,8 @@ const EXTRACTION_DEBUG_MODE_VERBOSITY = "progress++";
|
|||||||
* @param tempDir
|
* @param tempDir
|
||||||
* @param variant
|
* @param variant
|
||||||
* @param defaultCliVersion
|
* @param defaultCliVersion
|
||||||
|
* @param rawLanguages Raw set of languages.
|
||||||
|
* @param useOverlayAwareDefaultCliVersion Whether to select an overlay-aware default CLI version.
|
||||||
* @param features Information about the features that are enabled.
|
* @param features Information about the features that are enabled.
|
||||||
* @param logger
|
* @param logger
|
||||||
* @param checkVersion Whether to check that CodeQL CLI meets the minimum
|
* @param checkVersion Whether to check that CodeQL CLI meets the minimum
|
||||||
@@ -317,6 +319,8 @@ export async function setupCodeQL(
|
|||||||
tempDir: string,
|
tempDir: string,
|
||||||
variant: util.GitHubVariant,
|
variant: util.GitHubVariant,
|
||||||
defaultCliVersion: CodeQLDefaultVersionInfo,
|
defaultCliVersion: CodeQLDefaultVersionInfo,
|
||||||
|
rawLanguages: string[] | undefined,
|
||||||
|
useOverlayAwareDefaultCliVersion: boolean,
|
||||||
features: FeatureEnablement,
|
features: FeatureEnablement,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
checkVersion: boolean,
|
checkVersion: boolean,
|
||||||
@@ -340,6 +344,8 @@ export async function setupCodeQL(
|
|||||||
tempDir,
|
tempDir,
|
||||||
variant,
|
variant,
|
||||||
defaultCliVersion,
|
defaultCliVersion,
|
||||||
|
rawLanguages,
|
||||||
|
useOverlayAwareDefaultCliVersion,
|
||||||
features,
|
features,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
@@ -586,13 +592,6 @@ async function getCodeQLForCmd(
|
|||||||
extraArgs.push(`--qlconfig-file=${qlconfigFile}`);
|
extraArgs.push(`--qlconfig-file=${qlconfigFile}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const overwriteFlag = isSupportedToolsFeature(
|
|
||||||
await this.getVersion(),
|
|
||||||
ToolsFeature.ForceOverwrite,
|
|
||||||
)
|
|
||||||
? "--force-overwrite"
|
|
||||||
: "--overwrite";
|
|
||||||
|
|
||||||
const overlayDatabaseMode = config.overlayDatabaseMode;
|
const overlayDatabaseMode = config.overlayDatabaseMode;
|
||||||
if (overlayDatabaseMode === OverlayDatabaseMode.Overlay) {
|
if (overlayDatabaseMode === OverlayDatabaseMode.Overlay) {
|
||||||
const overlayChangesFile = await writeOverlayChangesFile(
|
const overlayChangesFile = await writeOverlayChangesFile(
|
||||||
@@ -619,7 +618,7 @@ async function getCodeQLForCmd(
|
|||||||
"init",
|
"init",
|
||||||
...(overlayDatabaseMode === OverlayDatabaseMode.Overlay
|
...(overlayDatabaseMode === OverlayDatabaseMode.Overlay
|
||||||
? []
|
? []
|
||||||
: [overwriteFlag]),
|
: ["--force-overwrite"]),
|
||||||
"--db-cluster",
|
"--db-cluster",
|
||||||
config.dbLocation,
|
config.dbLocation,
|
||||||
`--source-root=${sourceRoot}`,
|
`--source-root=${sourceRoot}`,
|
||||||
@@ -630,7 +629,14 @@ async function getCodeQLForCmd(
|
|||||||
// Some user configs specify `--no-calculate-baseline` as an additional
|
// Some user configs specify `--no-calculate-baseline` as an additional
|
||||||
// argument to `codeql database init`. Therefore ignore the baseline file
|
// argument to `codeql database init`. Therefore ignore the baseline file
|
||||||
// options here to avoid specifying the same argument twice and erroring.
|
// options here to avoid specifying the same argument twice and erroring.
|
||||||
ignoringOptions: ["--overwrite", ...baselineFilesOptions],
|
//
|
||||||
|
// Ignore `--overwrite` to avoid passing both `--force-overwrite` and `--overwrite` if
|
||||||
|
// the user has configured `--overwrite`.
|
||||||
|
ignoringOptions: [
|
||||||
|
"--force-overwrite",
|
||||||
|
"--overwrite",
|
||||||
|
...baselineFilesOptions,
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
{ stdin: externalRepositoryToken },
|
{ stdin: externalRepositoryToken },
|
||||||
@@ -847,7 +853,7 @@ async function getCodeQLForCmd(
|
|||||||
"--sarif-group-rules-by-pack",
|
"--sarif-group-rules-by-pack",
|
||||||
"--sarif-include-query-help=always",
|
"--sarif-include-query-help=always",
|
||||||
"--sublanguage-file-coverage",
|
"--sublanguage-file-coverage",
|
||||||
...(await getJobRunUuidSarifOptions(this)),
|
...(await getJobRunUuidSarifOptions()),
|
||||||
...getExtraOptionsFromEnv(["database", "interpret-results"]),
|
...getExtraOptionsFromEnv(["database", "interpret-results"]),
|
||||||
];
|
];
|
||||||
if (sarifRunPropertyFlag !== undefined) {
|
if (sarifRunPropertyFlag !== undefined) {
|
||||||
@@ -1277,13 +1283,8 @@ function applyAutobuildAzurePipelinesTimeoutFix() {
|
|||||||
].join(" ");
|
].join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getJobRunUuidSarifOptions(codeql: CodeQL) {
|
async function getJobRunUuidSarifOptions() {
|
||||||
const jobRunUuid = process.env[EnvVar.JOB_RUN_UUID];
|
const jobRunUuid = process.env[EnvVar.JOB_RUN_UUID];
|
||||||
|
|
||||||
return jobRunUuid &&
|
return jobRunUuid ? [`--sarif-run-property=jobRunUuid=${jobRunUuid}`] : [];
|
||||||
(await codeql.supportsFeature(
|
|
||||||
ToolsFeature.DatabaseInterpretResultsSupportsSarifRunProperty,
|
|
||||||
))
|
|
||||||
? [`--sarif-run-property=jobRunUuid=${jobRunUuid}`]
|
|
||||||
: [];
|
|
||||||
}
|
}
|
||||||
|
|||||||
+155
-127
@@ -21,6 +21,7 @@ import { GitVersionInfo } from "./git-utils";
|
|||||||
import { BuiltInLanguage, Language } from "./languages";
|
import { BuiltInLanguage, Language } from "./languages";
|
||||||
import { getRunnerLogger } from "./logging";
|
import { getRunnerLogger } from "./logging";
|
||||||
import { CODEQL_OVERLAY_MINIMUM_VERSION } from "./overlay";
|
import { CODEQL_OVERLAY_MINIMUM_VERSION } from "./overlay";
|
||||||
|
import * as overlayDiagnostics from "./overlay/diagnostics";
|
||||||
import { OverlayDisabledReason } from "./overlay/diagnostics";
|
import { OverlayDisabledReason } from "./overlay/diagnostics";
|
||||||
import { OverlayDatabaseMode } from "./overlay/overlay-database-mode";
|
import { OverlayDatabaseMode } from "./overlay/overlay-database-mode";
|
||||||
import * as overlayStatus from "./overlay/status";
|
import * as overlayStatus from "./overlay/status";
|
||||||
@@ -34,6 +35,7 @@ import {
|
|||||||
LoggedMessage,
|
LoggedMessage,
|
||||||
mockCodeQLVersion,
|
mockCodeQLVersion,
|
||||||
createTestConfig,
|
createTestConfig,
|
||||||
|
makeMacro,
|
||||||
} from "./testing-utils";
|
} from "./testing-utils";
|
||||||
import {
|
import {
|
||||||
GitHubVariant,
|
GitHubVariant,
|
||||||
@@ -1034,10 +1036,9 @@ const defaultOverlayDatabaseModeTestSetup: OverlayDatabaseModeTestSetup = {
|
|||||||
repositoryProperties: {},
|
repositoryProperties: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkOverlayEnablementMacro = test.macro({
|
const checkOverlayEnablementMacro = makeMacro({
|
||||||
exec: async (
|
exec: async (
|
||||||
t: ExecutionContext,
|
t: ExecutionContext,
|
||||||
_title: string,
|
|
||||||
setupOverrides: Partial<OverlayDatabaseModeTestSetup>,
|
setupOverrides: Partial<OverlayDatabaseModeTestSetup>,
|
||||||
expected:
|
expected:
|
||||||
| {
|
| {
|
||||||
@@ -1131,11 +1132,10 @@ const checkOverlayEnablementMacro = test.macro({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
title: (_, title) => `checkOverlayEnablement: ${title}`,
|
title: (title) => `checkOverlayEnablement: ${title}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Environment variable override - Overlay",
|
"Environment variable override - Overlay",
|
||||||
{
|
{
|
||||||
overlayDatabaseEnvVar: "overlay",
|
overlayDatabaseEnvVar: "overlay",
|
||||||
@@ -1146,8 +1146,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Environment variable override - OverlayBase",
|
"Environment variable override - OverlayBase",
|
||||||
{
|
{
|
||||||
overlayDatabaseEnvVar: "overlay-base",
|
overlayDatabaseEnvVar: "overlay-base",
|
||||||
@@ -1158,8 +1157,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Environment variable override - None",
|
"Environment variable override - None",
|
||||||
{
|
{
|
||||||
overlayDatabaseEnvVar: "none",
|
overlayDatabaseEnvVar: "none",
|
||||||
@@ -1169,8 +1167,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Ignore invalid environment variable",
|
"Ignore invalid environment variable",
|
||||||
{
|
{
|
||||||
overlayDatabaseEnvVar: "invalid-mode",
|
overlayDatabaseEnvVar: "invalid-mode",
|
||||||
@@ -1180,8 +1177,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Ignore feature flag when analyzing non-default branch",
|
"Ignore feature flag when analyzing non-default branch",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1192,8 +1188,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Overlay-base database on default branch when feature enabled",
|
"Overlay-base database on default branch when feature enabled",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1206,15 +1201,14 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Overlay-base database on default branch when feature enabled with custom analysis",
|
"Overlay-base database on default branch when feature enabled with custom analysis",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
features: [Feature.OverlayAnalysis, Feature.OverlayAnalysisJavascript],
|
features: [Feature.OverlayAnalysis, Feature.OverlayAnalysisJavascript],
|
||||||
codeScanningConfig: {
|
codeScanningConfig: {
|
||||||
packs: ["some-custom-pack@1.0.0"],
|
packs: ["some-custom-pack@1.0.0"],
|
||||||
} as UserConfig,
|
},
|
||||||
isDefaultBranch: true,
|
isDefaultBranch: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1223,8 +1217,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Overlay-base database on default branch when code-scanning feature enabled",
|
"Overlay-base database on default branch when code-scanning feature enabled",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1240,8 +1233,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay-base database on default branch if runner disk space is too low",
|
"No overlay-base database on default branch if runner disk space is too low",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1260,8 +1252,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay-base database on default branch if we can't determine runner disk space",
|
"No overlay-base database on default branch if we can't determine runner disk space",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1277,8 +1268,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Overlay-base database on default branch if runner disk space is too low and skip resource checks flag is enabled",
|
"Overlay-base database on default branch if runner disk space is too low and skip resource checks flag is enabled",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1299,8 +1289,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay-base database on default branch if runner disk space is below v2 limit and v2 resource checks enabled",
|
"No overlay-base database on default branch if runner disk space is below v2 limit and v2 resource checks enabled",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1320,8 +1309,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Overlay-base database on default branch if runner disk space is between v2 and v1 limits and v2 resource checks enabled",
|
"Overlay-base database on default branch if runner disk space is between v2 and v1 limits and v2 resource checks enabled",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1342,8 +1330,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay-base database on default branch if runner disk space is between v2 and v1 limits and v2 resource checks not enabled",
|
"No overlay-base database on default branch if runner disk space is between v2 and v1 limits and v2 resource checks not enabled",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1362,8 +1349,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay-base database on default branch if memory flag is too low",
|
"No overlay-base database on default branch if memory flag is too low",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1379,8 +1365,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Overlay-base database on default branch if memory flag is too low but CodeQL >= 2.24.3",
|
"Overlay-base database on default branch if memory flag is too low but CodeQL >= 2.24.3",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1398,8 +1383,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Overlay-base database on default branch if memory flag is too low and skip resource checks flag is enabled",
|
"Overlay-base database on default branch if memory flag is too low and skip resource checks flag is enabled",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1417,8 +1401,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay-base database on default branch when cached status indicates previous failure",
|
"No overlay-base database on default branch when cached status indicates previous failure",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1435,8 +1418,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay analysis on PR when cached status indicates previous failure",
|
"No overlay analysis on PR when cached status indicates previous failure",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1453,8 +1435,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay-base database on default branch when code-scanning feature enabled with disable-default-queries",
|
"No overlay-base database on default branch when code-scanning feature enabled with disable-default-queries",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1464,7 +1445,7 @@ test.serial(
|
|||||||
],
|
],
|
||||||
codeScanningConfig: {
|
codeScanningConfig: {
|
||||||
"disable-default-queries": true,
|
"disable-default-queries": true,
|
||||||
} as UserConfig,
|
},
|
||||||
isDefaultBranch: true,
|
isDefaultBranch: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1472,8 +1453,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay-base database on default branch when code-scanning feature enabled with packs",
|
"No overlay-base database on default branch when code-scanning feature enabled with packs",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1483,7 +1463,7 @@ test.serial(
|
|||||||
],
|
],
|
||||||
codeScanningConfig: {
|
codeScanningConfig: {
|
||||||
packs: ["some-custom-pack@1.0.0"],
|
packs: ["some-custom-pack@1.0.0"],
|
||||||
} as UserConfig,
|
},
|
||||||
isDefaultBranch: true,
|
isDefaultBranch: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1491,8 +1471,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay-base database on default branch when code-scanning feature enabled with queries",
|
"No overlay-base database on default branch when code-scanning feature enabled with queries",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1502,7 +1481,7 @@ test.serial(
|
|||||||
],
|
],
|
||||||
codeScanningConfig: {
|
codeScanningConfig: {
|
||||||
queries: [{ uses: "some-query.ql" }],
|
queries: [{ uses: "some-query.ql" }],
|
||||||
} as UserConfig,
|
},
|
||||||
isDefaultBranch: true,
|
isDefaultBranch: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1510,8 +1489,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay-base database on default branch when code-scanning feature enabled with query-filters",
|
"No overlay-base database on default branch when code-scanning feature enabled with query-filters",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1521,7 +1499,7 @@ test.serial(
|
|||||||
],
|
],
|
||||||
codeScanningConfig: {
|
codeScanningConfig: {
|
||||||
"query-filters": [{ include: { "security-severity": "high" } }],
|
"query-filters": [{ include: { "security-severity": "high" } }],
|
||||||
} as UserConfig,
|
},
|
||||||
isDefaultBranch: true,
|
isDefaultBranch: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1529,8 +1507,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay-base database on default branch when only language-specific feature enabled",
|
"No overlay-base database on default branch when only language-specific feature enabled",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1542,8 +1519,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay-base database on default branch when only code-scanning feature enabled",
|
"No overlay-base database on default branch when only code-scanning feature enabled",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1555,8 +1531,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay-base database on default branch when language-specific feature disabled",
|
"No overlay-base database on default branch when language-specific feature disabled",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1568,8 +1543,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Overlay analysis on PR when feature enabled",
|
"Overlay analysis on PR when feature enabled",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1582,15 +1556,14 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Overlay analysis on PR when feature enabled with custom analysis",
|
"Overlay analysis on PR when feature enabled with custom analysis",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
features: [Feature.OverlayAnalysis, Feature.OverlayAnalysisJavascript],
|
features: [Feature.OverlayAnalysis, Feature.OverlayAnalysisJavascript],
|
||||||
codeScanningConfig: {
|
codeScanningConfig: {
|
||||||
packs: ["some-custom-pack@1.0.0"],
|
packs: ["some-custom-pack@1.0.0"],
|
||||||
} as UserConfig,
|
},
|
||||||
isPullRequest: true,
|
isPullRequest: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1599,8 +1572,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Overlay analysis on PR when code-scanning feature enabled",
|
"Overlay analysis on PR when code-scanning feature enabled",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1616,8 +1588,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay analysis on PR if runner disk space is too low",
|
"No overlay analysis on PR if runner disk space is too low",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1636,8 +1607,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Overlay analysis on PR if runner disk space is too low and skip resource checks flag is enabled",
|
"Overlay analysis on PR if runner disk space is too low and skip resource checks flag is enabled",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1658,8 +1628,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay analysis on PR if we can't determine runner disk space",
|
"No overlay analysis on PR if we can't determine runner disk space",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1675,8 +1644,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay analysis on PR if memory flag is too low",
|
"No overlay analysis on PR if memory flag is too low",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1692,8 +1660,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Overlay analysis on PR if memory flag is too low but CodeQL >= 2.24.3",
|
"Overlay analysis on PR if memory flag is too low but CodeQL >= 2.24.3",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1711,8 +1678,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Overlay analysis on PR if memory flag is too low and skip resource checks flag is enabled",
|
"Overlay analysis on PR if memory flag is too low and skip resource checks flag is enabled",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1730,8 +1696,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay analysis on PR when code-scanning feature enabled with disable-default-queries",
|
"No overlay analysis on PR when code-scanning feature enabled with disable-default-queries",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1741,7 +1706,7 @@ test.serial(
|
|||||||
],
|
],
|
||||||
codeScanningConfig: {
|
codeScanningConfig: {
|
||||||
"disable-default-queries": true,
|
"disable-default-queries": true,
|
||||||
} as UserConfig,
|
},
|
||||||
isPullRequest: true,
|
isPullRequest: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1749,8 +1714,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay analysis on PR when code-scanning feature enabled with packs",
|
"No overlay analysis on PR when code-scanning feature enabled with packs",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1760,7 +1724,7 @@ test.serial(
|
|||||||
],
|
],
|
||||||
codeScanningConfig: {
|
codeScanningConfig: {
|
||||||
packs: ["some-custom-pack@1.0.0"],
|
packs: ["some-custom-pack@1.0.0"],
|
||||||
} as UserConfig,
|
},
|
||||||
isPullRequest: true,
|
isPullRequest: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1768,8 +1732,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay analysis on PR when code-scanning feature enabled with queries",
|
"No overlay analysis on PR when code-scanning feature enabled with queries",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1779,7 +1742,7 @@ test.serial(
|
|||||||
],
|
],
|
||||||
codeScanningConfig: {
|
codeScanningConfig: {
|
||||||
queries: [{ uses: "some-query.ql" }],
|
queries: [{ uses: "some-query.ql" }],
|
||||||
} as UserConfig,
|
},
|
||||||
isPullRequest: true,
|
isPullRequest: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1787,8 +1750,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay analysis on PR when code-scanning feature enabled with query-filters",
|
"No overlay analysis on PR when code-scanning feature enabled with query-filters",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1798,7 +1760,7 @@ test.serial(
|
|||||||
],
|
],
|
||||||
codeScanningConfig: {
|
codeScanningConfig: {
|
||||||
"query-filters": [{ include: { "security-severity": "high" } }],
|
"query-filters": [{ include: { "security-severity": "high" } }],
|
||||||
} as UserConfig,
|
},
|
||||||
isPullRequest: true,
|
isPullRequest: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1806,8 +1768,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay analysis on PR when only language-specific feature enabled",
|
"No overlay analysis on PR when only language-specific feature enabled",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1819,8 +1780,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay analysis on PR when only code-scanning feature enabled",
|
"No overlay analysis on PR when only code-scanning feature enabled",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1832,8 +1792,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay analysis on PR when language-specific feature disabled",
|
"No overlay analysis on PR when language-specific feature disabled",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1845,8 +1804,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Overlay PR analysis by env",
|
"Overlay PR analysis by env",
|
||||||
{
|
{
|
||||||
overlayDatabaseEnvVar: "overlay",
|
overlayDatabaseEnvVar: "overlay",
|
||||||
@@ -1857,8 +1815,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Overlay PR analysis by env on a runner with low disk space",
|
"Overlay PR analysis by env on a runner with low disk space",
|
||||||
{
|
{
|
||||||
overlayDatabaseEnvVar: "overlay",
|
overlayDatabaseEnvVar: "overlay",
|
||||||
@@ -1870,8 +1827,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Overlay PR analysis by feature flag",
|
"Overlay PR analysis by feature flag",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1884,8 +1840,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Fallback due to autobuild with traced language",
|
"Fallback due to autobuild with traced language",
|
||||||
{
|
{
|
||||||
overlayDatabaseEnvVar: "overlay",
|
overlayDatabaseEnvVar: "overlay",
|
||||||
@@ -1897,8 +1852,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Fallback due to no build mode with traced language",
|
"Fallback due to no build mode with traced language",
|
||||||
{
|
{
|
||||||
overlayDatabaseEnvVar: "overlay",
|
overlayDatabaseEnvVar: "overlay",
|
||||||
@@ -1910,8 +1864,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Fallback due to old CodeQL version",
|
"Fallback due to old CodeQL version",
|
||||||
{
|
{
|
||||||
overlayDatabaseEnvVar: "overlay",
|
overlayDatabaseEnvVar: "overlay",
|
||||||
@@ -1922,8 +1875,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Fallback due to missing git root",
|
"Fallback due to missing git root",
|
||||||
{
|
{
|
||||||
overlayDatabaseEnvVar: "overlay",
|
overlayDatabaseEnvVar: "overlay",
|
||||||
@@ -1934,8 +1886,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Fallback due to old git version with submodules",
|
"Fallback due to old git version with submodules",
|
||||||
{
|
{
|
||||||
overlayDatabaseEnvVar: "overlay",
|
overlayDatabaseEnvVar: "overlay",
|
||||||
@@ -1947,8 +1898,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Fallback when git version cannot be determined and repo has submodules",
|
"Fallback when git version cannot be determined and repo has submodules",
|
||||||
{
|
{
|
||||||
overlayDatabaseEnvVar: "overlay",
|
overlayDatabaseEnvVar: "overlay",
|
||||||
@@ -1960,8 +1910,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Overlay enabled when git version cannot be determined and repo has no submodules",
|
"Overlay enabled when git version cannot be determined and repo has no submodules",
|
||||||
{
|
{
|
||||||
overlayDatabaseEnvVar: "overlay",
|
overlayDatabaseEnvVar: "overlay",
|
||||||
@@ -1974,8 +1923,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay when disabled via repository property",
|
"No overlay when disabled via repository property",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -1990,8 +1938,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Overlay not disabled when repository property is false",
|
"Overlay not disabled when repository property is false",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.javascript],
|
languages: [BuiltInLanguage.javascript],
|
||||||
@@ -2007,8 +1954,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"Environment variable override takes precedence over repository property",
|
"Environment variable override takes precedence over repository property",
|
||||||
{
|
{
|
||||||
overlayDatabaseEnvVar: "overlay",
|
overlayDatabaseEnvVar: "overlay",
|
||||||
@@ -2024,8 +1970,7 @@ test.serial(
|
|||||||
|
|
||||||
// Exercise language-specific overlay analysis features code paths
|
// Exercise language-specific overlay analysis features code paths
|
||||||
for (const language in BuiltInLanguage) {
|
for (const language in BuiltInLanguage) {
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
`Check default overlay analysis feature for ${language}`,
|
`Check default overlay analysis feature for ${language}`,
|
||||||
{
|
{
|
||||||
languages: [language],
|
languages: [language],
|
||||||
@@ -2042,8 +1987,7 @@ for (const language in BuiltInLanguage) {
|
|||||||
// overlay analysis enabled, even when the base overlay feature flag is on.
|
// overlay analysis enabled, even when the base overlay feature flag is on.
|
||||||
// Using swift here as it doesn't currently have overlay support — update this if
|
// Using swift here as it doesn't currently have overlay support — update this if
|
||||||
// swift gains overlay support.
|
// swift gains overlay support.
|
||||||
test.serial(
|
checkOverlayEnablementMacro.serial(
|
||||||
checkOverlayEnablementMacro,
|
|
||||||
"No overlay analysis for language without per-language overlay feature flag",
|
"No overlay analysis for language without per-language overlay feature flag",
|
||||||
{
|
{
|
||||||
languages: [BuiltInLanguage.swift],
|
languages: [BuiltInLanguage.swift],
|
||||||
@@ -2200,3 +2144,87 @@ test.serial(
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test("applyIncrementalAnalysisSettings: no-op when mode is not Overlay and diff ranges are unavailable", async (t) => {
|
||||||
|
const config = createTestConfig({});
|
||||||
|
config.overlayDatabaseMode = OverlayDatabaseMode.None;
|
||||||
|
const codeql = createStubCodeQL({});
|
||||||
|
const logger = getRunnerLogger(true);
|
||||||
|
|
||||||
|
await configUtils.applyIncrementalAnalysisSettings(
|
||||||
|
config,
|
||||||
|
false,
|
||||||
|
codeql,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
|
||||||
|
t.is(config.overlayDatabaseMode, OverlayDatabaseMode.None);
|
||||||
|
t.deepEqual(config.extraQueryExclusions, []);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("applyIncrementalAnalysisSettings: keeps overlay mode and adds exclusions when diff ranges are available", async (t) => {
|
||||||
|
const config = createTestConfig({
|
||||||
|
overlayDatabaseMode: OverlayDatabaseMode.Overlay,
|
||||||
|
});
|
||||||
|
const codeql = createStubCodeQL({});
|
||||||
|
const logger = getRunnerLogger(true);
|
||||||
|
|
||||||
|
await configUtils.applyIncrementalAnalysisSettings(
|
||||||
|
config,
|
||||||
|
true,
|
||||||
|
codeql,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
|
||||||
|
t.is(config.overlayDatabaseMode, OverlayDatabaseMode.Overlay);
|
||||||
|
t.deepEqual(config.extraQueryExclusions, [
|
||||||
|
{ exclude: { tags: "exclude-from-incremental" } },
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("applyIncrementalAnalysisSettings: disables overlay analysis when diff ranges are unavailable", async (t) => {
|
||||||
|
const config = createTestConfig({
|
||||||
|
overlayDatabaseMode: OverlayDatabaseMode.Overlay,
|
||||||
|
});
|
||||||
|
config.useOverlayDatabaseCaching = true;
|
||||||
|
const codeql = createStubCodeQL({});
|
||||||
|
const logger = getRunnerLogger(true);
|
||||||
|
const addDiagnosticsStub = sinon
|
||||||
|
.stub(overlayDiagnostics, "addOverlayDisablementDiagnostics")
|
||||||
|
.resolves();
|
||||||
|
|
||||||
|
await configUtils.applyIncrementalAnalysisSettings(
|
||||||
|
config,
|
||||||
|
false,
|
||||||
|
codeql,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
|
||||||
|
t.is(config.overlayDatabaseMode, OverlayDatabaseMode.None);
|
||||||
|
t.is(config.useOverlayDatabaseCaching, false);
|
||||||
|
t.deepEqual(config.extraQueryExclusions, []);
|
||||||
|
t.true(addDiagnosticsStub.calledOnce);
|
||||||
|
t.is(
|
||||||
|
addDiagnosticsStub.firstCall.args[2],
|
||||||
|
OverlayDisabledReason.DiffInformedAnalysisNotEnabled,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("applyIncrementalAnalysisSettings: adds exclusions for diff-informed-only runs", async (t) => {
|
||||||
|
const config = createTestConfig({});
|
||||||
|
config.overlayDatabaseMode = OverlayDatabaseMode.None;
|
||||||
|
const codeql = createStubCodeQL({});
|
||||||
|
const logger = getRunnerLogger(true);
|
||||||
|
|
||||||
|
await configUtils.applyIncrementalAnalysisSettings(
|
||||||
|
config,
|
||||||
|
true,
|
||||||
|
codeql,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
|
||||||
|
t.is(config.overlayDatabaseMode, OverlayDatabaseMode.None);
|
||||||
|
t.deepEqual(config.extraQueryExclusions, [
|
||||||
|
{ exclude: { tags: "exclude-from-incremental" } },
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|||||||
+56
-13
@@ -31,7 +31,7 @@ import {
|
|||||||
addNoLanguageDiagnostic,
|
addNoLanguageDiagnostic,
|
||||||
makeTelemetryDiagnostic,
|
makeTelemetryDiagnostic,
|
||||||
} from "./diagnostics";
|
} from "./diagnostics";
|
||||||
import { shouldPerformDiffInformedAnalysis } from "./diff-informed-analysis-utils";
|
import { prepareDiffInformedAnalysis } from "./diff-informed-analysis-utils";
|
||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
import * as errorMessages from "./error-messages";
|
import * as errorMessages from "./error-messages";
|
||||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||||
@@ -407,6 +407,7 @@ export async function getLanguages(
|
|||||||
return languages;
|
return languages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Splits the `languages` input into a list of raw languages without checking if they are supported by CodeQL. */
|
||||||
export function getRawLanguagesNoAutodetect(
|
export function getRawLanguagesNoAutodetect(
|
||||||
languagesInput: string | undefined,
|
languagesInput: string | undefined,
|
||||||
): string[] {
|
): string[] {
|
||||||
@@ -1076,6 +1077,48 @@ function hasQueryCustomisation(userConfig: UserConfig): boolean {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finalize the incremental-analysis configuration for this run.
|
||||||
|
*
|
||||||
|
* Overlay analysis has only been validated in combination with diff-informed
|
||||||
|
* analysis, so if `Overlay` mode was selected for a pull request but the diff
|
||||||
|
* ranges could not be computed, fall back to a full non-overlay analysis.
|
||||||
|
*
|
||||||
|
* Query exclusions for incremental-only queries are then applied whenever the
|
||||||
|
* diff ranges are available — which, after the fallback above, is exactly the
|
||||||
|
* set of runs where any kind of incremental analysis (overlay or
|
||||||
|
* diff-informed) is in effect.
|
||||||
|
*/
|
||||||
|
export async function applyIncrementalAnalysisSettings(
|
||||||
|
config: Config,
|
||||||
|
hasDiffRanges: boolean,
|
||||||
|
codeql: CodeQL,
|
||||||
|
logger: Logger,
|
||||||
|
): Promise<void> {
|
||||||
|
if (
|
||||||
|
config.overlayDatabaseMode === OverlayDatabaseMode.Overlay &&
|
||||||
|
!hasDiffRanges
|
||||||
|
) {
|
||||||
|
logger.info(
|
||||||
|
`Reverting overlay database mode to ${OverlayDatabaseMode.None} ` +
|
||||||
|
"because the PR diff ranges could not be computed.",
|
||||||
|
);
|
||||||
|
config.overlayDatabaseMode = OverlayDatabaseMode.None;
|
||||||
|
config.useOverlayDatabaseCaching = false;
|
||||||
|
await addOverlayDisablementDiagnostics(
|
||||||
|
config,
|
||||||
|
codeql,
|
||||||
|
OverlayDisabledReason.DiffInformedAnalysisNotEnabled,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasDiffRanges) {
|
||||||
|
config.extraQueryExclusions.push({
|
||||||
|
exclude: { tags: "exclude-from-incremental" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load and return the config.
|
* Load and return the config.
|
||||||
*
|
*
|
||||||
@@ -1230,18 +1273,18 @@ export async function initConfig(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
const hasDiffRanges = await prepareDiffInformedAnalysis(
|
||||||
config.overlayDatabaseMode === OverlayDatabaseMode.Overlay ||
|
inputs.codeql,
|
||||||
(await shouldPerformDiffInformedAnalysis(
|
inputs.features,
|
||||||
inputs.codeql,
|
logger,
|
||||||
inputs.features,
|
);
|
||||||
logger,
|
|
||||||
))
|
await applyIncrementalAnalysisSettings(
|
||||||
) {
|
config,
|
||||||
config.extraQueryExclusions.push({
|
hasDiffRanges,
|
||||||
exclude: { tags: "exclude-from-incremental" },
|
inputs.codeql,
|
||||||
});
|
logger,
|
||||||
}
|
);
|
||||||
|
|
||||||
if (await isTrapCachingEnabled(features, config.overlayDatabaseMode)) {
|
if (await isTrapCachingEnabled(features, config.overlayDatabaseMode)) {
|
||||||
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(
|
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
checkExpectedLogMessages,
|
checkExpectedLogMessages,
|
||||||
getRecordingLogger,
|
getRecordingLogger,
|
||||||
LoggedMessage,
|
LoggedMessage,
|
||||||
|
makeMacro,
|
||||||
} from "../testing-utils";
|
} from "../testing-utils";
|
||||||
import { ConfigurationError, prettyPrintPack } from "../util";
|
import { ConfigurationError, prettyPrintPack } from "../util";
|
||||||
|
|
||||||
@@ -15,7 +16,7 @@ import * as dbConfig from "./db-config";
|
|||||||
/**
|
/**
|
||||||
* Test macro for ensuring the packs block is valid
|
* Test macro for ensuring the packs block is valid
|
||||||
*/
|
*/
|
||||||
const parsePacksMacro = test.macro({
|
const parsePacksMacro = makeMacro({
|
||||||
exec: (
|
exec: (
|
||||||
t: ExecutionContext<unknown>,
|
t: ExecutionContext<unknown>,
|
||||||
packsInput: string,
|
packsInput: string,
|
||||||
@@ -33,7 +34,7 @@ const parsePacksMacro = test.macro({
|
|||||||
/**
|
/**
|
||||||
* Test macro for testing when the packs block is invalid
|
* Test macro for testing when the packs block is invalid
|
||||||
*/
|
*/
|
||||||
const parsePacksErrorMacro = test.macro({
|
const parsePacksErrorMacro = makeMacro({
|
||||||
exec: (
|
exec: (
|
||||||
t: ExecutionContext<unknown>,
|
t: ExecutionContext<unknown>,
|
||||||
packsInput: string,
|
packsInput: string,
|
||||||
@@ -49,34 +50,32 @@ const parsePacksErrorMacro = test.macro({
|
|||||||
/**
|
/**
|
||||||
* Test macro for testing when the packs block is invalid
|
* Test macro for testing when the packs block is invalid
|
||||||
*/
|
*/
|
||||||
const invalidPackNameMacro = test.macro({
|
const invalidPackNameMacro = makeMacro({
|
||||||
exec: (t: ExecutionContext, name: string) =>
|
exec: (t: ExecutionContext, arg: string) =>
|
||||||
parsePacksErrorMacro.exec(
|
parsePacksErrorMacro.fn(
|
||||||
t,
|
t,
|
||||||
name,
|
arg,
|
||||||
[BuiltInLanguage.cpp],
|
[BuiltInLanguage.cpp],
|
||||||
new RegExp(`^"${name}" is not a valid pack$`),
|
new RegExp(`^"${arg}" is not a valid pack$`),
|
||||||
),
|
),
|
||||||
title: (_providedTitle: string | undefined, arg: string | undefined) =>
|
title: (_providedTitle: string | undefined, arg: string | undefined) =>
|
||||||
`Invalid pack string: ${arg}`,
|
`Invalid pack string: ${arg}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
test("no packs", parsePacksMacro, "", [], undefined);
|
parsePacksMacro("no packs", "", [], undefined);
|
||||||
test("two packs", parsePacksMacro, "a/b,c/d@1.2.3", [BuiltInLanguage.cpp], {
|
parsePacksMacro("two packs", "a/b,c/d@1.2.3", [BuiltInLanguage.cpp], {
|
||||||
[BuiltInLanguage.cpp]: ["a/b", "c/d@1.2.3"],
|
[BuiltInLanguage.cpp]: ["a/b", "c/d@1.2.3"],
|
||||||
});
|
});
|
||||||
test(
|
parsePacksMacro(
|
||||||
"two packs with spaces",
|
"two packs with spaces",
|
||||||
parsePacksMacro,
|
|
||||||
" a/b , c/d@1.2.3 ",
|
" a/b , c/d@1.2.3 ",
|
||||||
[BuiltInLanguage.cpp],
|
[BuiltInLanguage.cpp],
|
||||||
{
|
{
|
||||||
[BuiltInLanguage.cpp]: ["a/b", "c/d@1.2.3"],
|
[BuiltInLanguage.cpp]: ["a/b", "c/d@1.2.3"],
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
test(
|
parsePacksErrorMacro(
|
||||||
"two packs with language",
|
"two packs with language",
|
||||||
parsePacksErrorMacro,
|
|
||||||
"a/b,c/d@1.2.3",
|
"a/b,c/d@1.2.3",
|
||||||
[BuiltInLanguage.cpp, BuiltInLanguage.java],
|
[BuiltInLanguage.cpp, BuiltInLanguage.java],
|
||||||
new RegExp(
|
new RegExp(
|
||||||
@@ -85,9 +84,8 @@ test(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
parsePacksMacro(
|
||||||
"packs with other valid names",
|
"packs with other valid names",
|
||||||
parsePacksMacro,
|
|
||||||
[
|
[
|
||||||
// ranges are ok
|
// ranges are ok
|
||||||
"c/d@1.0",
|
"c/d@1.0",
|
||||||
@@ -123,23 +121,23 @@ test(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test(invalidPackNameMacro, "c"); // all packs require at least a scope and a name
|
invalidPackNameMacro.test("c"); // all packs require at least a scope and a name
|
||||||
test(invalidPackNameMacro, "c-/d");
|
invalidPackNameMacro.test("c-/d");
|
||||||
test(invalidPackNameMacro, "-c/d");
|
invalidPackNameMacro.test("-c/d");
|
||||||
test(invalidPackNameMacro, "c/d_d");
|
invalidPackNameMacro.test("c/d_d");
|
||||||
test(invalidPackNameMacro, "c/d@@");
|
invalidPackNameMacro.test("c/d@@");
|
||||||
test(invalidPackNameMacro, "c/d@1.0.0:");
|
invalidPackNameMacro.test("c/d@1.0.0:");
|
||||||
test(invalidPackNameMacro, "c/d:");
|
invalidPackNameMacro.test("c/d:");
|
||||||
test(invalidPackNameMacro, "c/d:/a");
|
invalidPackNameMacro.test("c/d:/a");
|
||||||
test(invalidPackNameMacro, "@1.0.0:a");
|
invalidPackNameMacro.test("@1.0.0:a");
|
||||||
test(invalidPackNameMacro, "c/d@../a");
|
invalidPackNameMacro.test("c/d@../a");
|
||||||
test(invalidPackNameMacro, "c/d@b/../a");
|
invalidPackNameMacro.test("c/d@b/../a");
|
||||||
test(invalidPackNameMacro, "c/d:z@1");
|
invalidPackNameMacro.test("c/d:z@1");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test macro for pretty printing pack specs
|
* Test macro for pretty printing pack specs
|
||||||
*/
|
*/
|
||||||
const packSpecPrettyPrintingMacro = test.macro({
|
const packSpecPrettyPrintingMacro = makeMacro({
|
||||||
exec: (t: ExecutionContext, packStr: string, packObj: dbConfig.Pack) => {
|
exec: (t: ExecutionContext, packStr: string, packObj: dbConfig.Pack) => {
|
||||||
const parsed = dbConfig.parsePacksSpecification(packStr);
|
const parsed = dbConfig.parsePacksSpecification(packStr);
|
||||||
t.deepEqual(parsed, packObj, "parsed pack spec is correct");
|
t.deepEqual(parsed, packObj, "parsed pack spec is correct");
|
||||||
@@ -163,36 +161,35 @@ const packSpecPrettyPrintingMacro = test.macro({
|
|||||||
) => `Prettyprint pack spec: '${packStr}'`,
|
) => `Prettyprint pack spec: '${packStr}'`,
|
||||||
});
|
});
|
||||||
|
|
||||||
test(packSpecPrettyPrintingMacro, "a/b", {
|
packSpecPrettyPrintingMacro.test("a/b", {
|
||||||
name: "a/b",
|
name: "a/b",
|
||||||
version: undefined,
|
version: undefined,
|
||||||
path: undefined,
|
path: undefined,
|
||||||
});
|
});
|
||||||
test(packSpecPrettyPrintingMacro, "a/b@~1.2.3", {
|
packSpecPrettyPrintingMacro.test("a/b@~1.2.3", {
|
||||||
name: "a/b",
|
name: "a/b",
|
||||||
version: "~1.2.3",
|
version: "~1.2.3",
|
||||||
path: undefined,
|
path: undefined,
|
||||||
});
|
});
|
||||||
test(packSpecPrettyPrintingMacro, "a/b@~1.2.3:abc/def", {
|
packSpecPrettyPrintingMacro.test("a/b@~1.2.3:abc/def", {
|
||||||
name: "a/b",
|
name: "a/b",
|
||||||
version: "~1.2.3",
|
version: "~1.2.3",
|
||||||
path: "abc/def",
|
path: "abc/def",
|
||||||
});
|
});
|
||||||
test(packSpecPrettyPrintingMacro, "a/b:abc/def", {
|
packSpecPrettyPrintingMacro.test("a/b:abc/def", {
|
||||||
name: "a/b",
|
name: "a/b",
|
||||||
version: undefined,
|
version: undefined,
|
||||||
path: "abc/def",
|
path: "abc/def",
|
||||||
});
|
});
|
||||||
test(packSpecPrettyPrintingMacro, " a/b:abc/def ", {
|
packSpecPrettyPrintingMacro.test(" a/b:abc/def ", {
|
||||||
name: "a/b",
|
name: "a/b",
|
||||||
version: undefined,
|
version: undefined,
|
||||||
path: "abc/def",
|
path: "abc/def",
|
||||||
});
|
});
|
||||||
|
|
||||||
const calculateAugmentationMacro = test.macro({
|
const calculateAugmentationMacro = makeMacro({
|
||||||
exec: async (
|
exec: async (
|
||||||
t: ExecutionContext,
|
t: ExecutionContext,
|
||||||
_title: string,
|
|
||||||
rawPacksInput: string | undefined,
|
rawPacksInput: string | undefined,
|
||||||
rawQueriesInput: string | undefined,
|
rawQueriesInput: string | undefined,
|
||||||
languages: Language[],
|
languages: Language[],
|
||||||
@@ -207,11 +204,10 @@ const calculateAugmentationMacro = test.macro({
|
|||||||
);
|
);
|
||||||
t.deepEqual(actualAugmentationProperties, expectedAugmentationProperties);
|
t.deepEqual(actualAugmentationProperties, expectedAugmentationProperties);
|
||||||
},
|
},
|
||||||
title: (_, title) => `Calculate Augmentation: ${title}`,
|
title: (title) => `Calculate Augmentation: ${title}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
calculateAugmentationMacro(
|
||||||
calculateAugmentationMacro,
|
|
||||||
"All empty",
|
"All empty",
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
@@ -222,8 +218,7 @@ test(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
calculateAugmentationMacro(
|
||||||
calculateAugmentationMacro,
|
|
||||||
"With queries",
|
"With queries",
|
||||||
undefined,
|
undefined,
|
||||||
" a, b , c, d",
|
" a, b , c, d",
|
||||||
@@ -235,8 +230,7 @@ test(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
calculateAugmentationMacro(
|
||||||
calculateAugmentationMacro,
|
|
||||||
"With queries combining",
|
"With queries combining",
|
||||||
undefined,
|
undefined,
|
||||||
" + a, b , c, d ",
|
" + a, b , c, d ",
|
||||||
@@ -249,8 +243,7 @@ test(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
calculateAugmentationMacro(
|
||||||
calculateAugmentationMacro,
|
|
||||||
"With packs",
|
"With packs",
|
||||||
" codeql/a , codeql/b , codeql/c , codeql/d ",
|
" codeql/a , codeql/b , codeql/c , codeql/d ",
|
||||||
undefined,
|
undefined,
|
||||||
@@ -262,8 +255,7 @@ test(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
calculateAugmentationMacro(
|
||||||
calculateAugmentationMacro,
|
|
||||||
"With packs combining",
|
"With packs combining",
|
||||||
" + codeql/a, codeql/b, codeql/c, codeql/d",
|
" + codeql/a, codeql/b, codeql/c, codeql/d",
|
||||||
undefined,
|
undefined,
|
||||||
@@ -276,8 +268,7 @@ test(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
calculateAugmentationMacro(
|
||||||
calculateAugmentationMacro,
|
|
||||||
"With repo property queries",
|
"With repo property queries",
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
@@ -294,8 +285,7 @@ test(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
calculateAugmentationMacro(
|
||||||
calculateAugmentationMacro,
|
|
||||||
"With repo property queries combining",
|
"With repo property queries combining",
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
@@ -312,10 +302,9 @@ test(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const calculateAugmentationErrorMacro = test.macro({
|
const calculateAugmentationErrorMacro = makeMacro({
|
||||||
exec: async (
|
exec: async (
|
||||||
t: ExecutionContext,
|
t: ExecutionContext,
|
||||||
_title: string,
|
|
||||||
rawPacksInput: string | undefined,
|
rawPacksInput: string | undefined,
|
||||||
rawQueriesInput: string | undefined,
|
rawQueriesInput: string | undefined,
|
||||||
languages: Language[],
|
languages: Language[],
|
||||||
@@ -333,11 +322,10 @@ const calculateAugmentationErrorMacro = test.macro({
|
|||||||
{ message: expectedError },
|
{ message: expectedError },
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
title: (_, title) => `Calculate Augmentation Error: ${title}`,
|
title: (title) => `Calculate Augmentation Error: ${title}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
calculateAugmentationErrorMacro(
|
||||||
calculateAugmentationErrorMacro,
|
|
||||||
"Plus (+) with nothing else (queries)",
|
"Plus (+) with nothing else (queries)",
|
||||||
undefined,
|
undefined,
|
||||||
" + ",
|
" + ",
|
||||||
@@ -346,8 +334,7 @@ test(
|
|||||||
/The workflow property "queries" is invalid/,
|
/The workflow property "queries" is invalid/,
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
calculateAugmentationErrorMacro(
|
||||||
calculateAugmentationErrorMacro,
|
|
||||||
"Plus (+) with nothing else (packs)",
|
"Plus (+) with nothing else (packs)",
|
||||||
" + ",
|
" + ",
|
||||||
undefined,
|
undefined,
|
||||||
@@ -356,8 +343,7 @@ test(
|
|||||||
/The workflow property "packs" is invalid/,
|
/The workflow property "packs" is invalid/,
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
calculateAugmentationErrorMacro(
|
||||||
calculateAugmentationErrorMacro,
|
|
||||||
"Plus (+) with nothing else (repo property queries)",
|
"Plus (+) with nothing else (repo property queries)",
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
@@ -368,8 +354,7 @@ test(
|
|||||||
/The repository property "github-codeql-extra-queries" is invalid/,
|
/The repository property "github-codeql-extra-queries" is invalid/,
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
calculateAugmentationErrorMacro(
|
||||||
calculateAugmentationErrorMacro,
|
|
||||||
"Packs input with multiple languages",
|
"Packs input with multiple languages",
|
||||||
" + a/b, c/d ",
|
" + a/b, c/d ",
|
||||||
undefined,
|
undefined,
|
||||||
@@ -378,8 +363,7 @@ test(
|
|||||||
/Cannot specify a 'packs' input in a multi-language analysis/,
|
/Cannot specify a 'packs' input in a multi-language analysis/,
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
calculateAugmentationErrorMacro(
|
||||||
calculateAugmentationErrorMacro,
|
|
||||||
"Packs input with no languages",
|
"Packs input with no languages",
|
||||||
" + a/b, c/d ",
|
" + a/b, c/d ",
|
||||||
undefined,
|
undefined,
|
||||||
@@ -388,8 +372,7 @@ test(
|
|||||||
/No languages specified/,
|
/No languages specified/,
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
calculateAugmentationErrorMacro(
|
||||||
calculateAugmentationErrorMacro,
|
|
||||||
"Invalid packs",
|
"Invalid packs",
|
||||||
" a-pack-without-a-scope ",
|
" a-pack-without-a-scope ",
|
||||||
undefined,
|
undefined,
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ export function getArtifactSuffix(matrix: string | undefined): string {
|
|||||||
try {
|
try {
|
||||||
const matrixObject = JSON.parse(matrix);
|
const matrixObject = JSON.parse(matrix);
|
||||||
if (json.isObject(matrixObject)) {
|
if (json.isObject(matrixObject)) {
|
||||||
for (const matrixKey of Object.keys(matrixObject as object).sort())
|
for (const matrixKey of Object.keys(matrixObject).sort())
|
||||||
suffix += `-${matrixObject[matrixKey]}`;
|
suffix += `-${matrixObject[matrixKey]}`;
|
||||||
} else {
|
} else {
|
||||||
core.warning("User-specified `matrix` input is not an object.");
|
core.warning("User-specified `matrix` input is not an object.");
|
||||||
|
|||||||
+4
-4
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"bundleVersion": "codeql-bundle-v2.25.3",
|
"bundleVersion": "codeql-bundle-v2.25.4",
|
||||||
"cliVersion": "2.25.3",
|
"cliVersion": "2.25.4",
|
||||||
"priorBundleVersion": "codeql-bundle-v2.25.2",
|
"priorBundleVersion": "codeql-bundle-v2.25.3",
|
||||||
"priorCliVersion": "2.25.2"
|
"priorCliVersion": "2.25.3"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,17 +5,20 @@ import * as actionsUtil from "./actions-util";
|
|||||||
import type { PullRequestBranches } from "./actions-util";
|
import type { PullRequestBranches } from "./actions-util";
|
||||||
import * as apiClient from "./api-client";
|
import * as apiClient from "./api-client";
|
||||||
import {
|
import {
|
||||||
shouldPerformDiffInformedAnalysis,
|
getDiffInformedAnalysisBranches,
|
||||||
|
prepareDiffInformedAnalysis,
|
||||||
exportedForTesting,
|
exportedForTesting,
|
||||||
} from "./diff-informed-analysis-utils";
|
} from "./diff-informed-analysis-utils";
|
||||||
import { Feature, initFeatures } from "./feature-flags";
|
import { Feature, FeatureEnablement, initFeatures } from "./feature-flags";
|
||||||
import { getRunnerLogger } from "./logging";
|
import { getRunnerLogger } from "./logging";
|
||||||
import { parseRepositoryNwo } from "./repository";
|
import { parseRepositoryNwo } from "./repository";
|
||||||
import {
|
import {
|
||||||
setupTests,
|
setupTests,
|
||||||
|
createFeatures,
|
||||||
mockCodeQLVersion,
|
mockCodeQLVersion,
|
||||||
mockFeatureFlagApiEndpoint,
|
mockFeatureFlagApiEndpoint,
|
||||||
setupActionsVars,
|
setupActionsVars,
|
||||||
|
makeMacro,
|
||||||
} from "./testing-utils";
|
} from "./testing-utils";
|
||||||
import { GitHubVariant, withTmpDir } from "./util";
|
import { GitHubVariant, withTmpDir } from "./util";
|
||||||
import type { GitHubVersion } from "./util";
|
import type { GitHubVersion } from "./util";
|
||||||
@@ -42,10 +45,9 @@ const defaultTestCase: DiffInformedAnalysisTestCase = {
|
|||||||
codeQLVersion: "2.21.0",
|
codeQLVersion: "2.21.0",
|
||||||
};
|
};
|
||||||
|
|
||||||
const testShouldPerformDiffInformedAnalysis = test.macro({
|
const testShouldPerformDiffInformedAnalysis = makeMacro({
|
||||||
exec: async (
|
exec: async (
|
||||||
t: ExecutionContext,
|
t: ExecutionContext,
|
||||||
_title: string,
|
|
||||||
partialTestCase: Partial<DiffInformedAnalysisTestCase>,
|
partialTestCase: Partial<DiffInformedAnalysisTestCase>,
|
||||||
expectedResult: boolean,
|
expectedResult: boolean,
|
||||||
) => {
|
) => {
|
||||||
@@ -73,39 +75,34 @@ const testShouldPerformDiffInformedAnalysis = test.macro({
|
|||||||
[Feature.DiffInformedQueries]: testCase.featureEnabled,
|
[Feature.DiffInformedQueries]: testCase.featureEnabled,
|
||||||
});
|
});
|
||||||
|
|
||||||
const getGitHubVersionStub = sinon
|
sinon
|
||||||
.stub(apiClient, "getGitHubVersion")
|
.stub(apiClient, "getGitHubVersion")
|
||||||
.resolves(testCase.gitHubVersion);
|
.resolves(testCase.gitHubVersion);
|
||||||
const getPullRequestBranchesStub = sinon
|
sinon
|
||||||
.stub(actionsUtil, "getPullRequestBranches")
|
.stub(actionsUtil, "getPullRequestBranches")
|
||||||
.returns(testCase.pullRequestBranches);
|
.returns(testCase.pullRequestBranches);
|
||||||
|
|
||||||
const result = await shouldPerformDiffInformedAnalysis(
|
const branches = await getDiffInformedAnalysisBranches(
|
||||||
codeql,
|
codeql,
|
||||||
features,
|
features,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
|
|
||||||
t.is(result, expectedResult);
|
t.is(branches !== undefined, expectedResult);
|
||||||
|
|
||||||
delete process.env.CODEQL_ACTION_DIFF_INFORMED_QUERIES;
|
delete process.env.CODEQL_ACTION_DIFF_INFORMED_QUERIES;
|
||||||
|
|
||||||
getGitHubVersionStub.restore();
|
|
||||||
getPullRequestBranchesStub.restore();
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
title: (_, title) => `shouldPerformDiffInformedAnalysis: ${title}`,
|
title: (title) => `getDiffInformedAnalysisBranches: ${title}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
test.serial(
|
testShouldPerformDiffInformedAnalysis.serial(
|
||||||
testShouldPerformDiffInformedAnalysis,
|
|
||||||
"returns true in the default test case",
|
"returns true in the default test case",
|
||||||
{},
|
{},
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
testShouldPerformDiffInformedAnalysis.serial(
|
||||||
testShouldPerformDiffInformedAnalysis,
|
|
||||||
"returns false when feature flag is disabled from the API",
|
"returns false when feature flag is disabled from the API",
|
||||||
{
|
{
|
||||||
featureEnabled: false,
|
featureEnabled: false,
|
||||||
@@ -113,8 +110,7 @@ test.serial(
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
testShouldPerformDiffInformedAnalysis.serial(
|
||||||
testShouldPerformDiffInformedAnalysis,
|
|
||||||
"returns false when CODEQL_ACTION_DIFF_INFORMED_QUERIES is set to false",
|
"returns false when CODEQL_ACTION_DIFF_INFORMED_QUERIES is set to false",
|
||||||
{
|
{
|
||||||
featureEnabled: true,
|
featureEnabled: true,
|
||||||
@@ -123,8 +119,7 @@ test.serial(
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
testShouldPerformDiffInformedAnalysis.serial(
|
||||||
testShouldPerformDiffInformedAnalysis,
|
|
||||||
"returns true when CODEQL_ACTION_DIFF_INFORMED_QUERIES is set to true",
|
"returns true when CODEQL_ACTION_DIFF_INFORMED_QUERIES is set to true",
|
||||||
{
|
{
|
||||||
featureEnabled: false,
|
featureEnabled: false,
|
||||||
@@ -133,8 +128,7 @@ test.serial(
|
|||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
testShouldPerformDiffInformedAnalysis.serial(
|
||||||
testShouldPerformDiffInformedAnalysis,
|
|
||||||
"returns false for CodeQL version 2.20.0",
|
"returns false for CodeQL version 2.20.0",
|
||||||
{
|
{
|
||||||
codeQLVersion: "2.20.0",
|
codeQLVersion: "2.20.0",
|
||||||
@@ -142,8 +136,7 @@ test.serial(
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
testShouldPerformDiffInformedAnalysis.serial(
|
||||||
testShouldPerformDiffInformedAnalysis,
|
|
||||||
"returns false for invalid GHES version",
|
"returns false for invalid GHES version",
|
||||||
{
|
{
|
||||||
gitHubVersion: {
|
gitHubVersion: {
|
||||||
@@ -154,8 +147,7 @@ test.serial(
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
testShouldPerformDiffInformedAnalysis.serial(
|
||||||
testShouldPerformDiffInformedAnalysis,
|
|
||||||
"returns false for GHES version 3.18.5",
|
"returns false for GHES version 3.18.5",
|
||||||
{
|
{
|
||||||
gitHubVersion: {
|
gitHubVersion: {
|
||||||
@@ -166,8 +158,7 @@ test.serial(
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
testShouldPerformDiffInformedAnalysis.serial(
|
||||||
testShouldPerformDiffInformedAnalysis,
|
|
||||||
"returns true for GHES version 3.19.0",
|
"returns true for GHES version 3.19.0",
|
||||||
{
|
{
|
||||||
gitHubVersion: {
|
gitHubVersion: {
|
||||||
@@ -178,8 +169,7 @@ test.serial(
|
|||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
testShouldPerformDiffInformedAnalysis.serial(
|
||||||
testShouldPerformDiffInformedAnalysis,
|
|
||||||
"returns false when not a pull request",
|
"returns false when not a pull request",
|
||||||
{
|
{
|
||||||
pullRequestBranches: undefined,
|
pullRequestBranches: undefined,
|
||||||
@@ -187,6 +177,135 @@ test.serial(
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"prepareDiffInformedAnalysis: returns false when not a pull request",
|
||||||
|
async (t) => {
|
||||||
|
await withTmpDir(async (tmpDir) => {
|
||||||
|
setupActionsVars(tmpDir, tmpDir);
|
||||||
|
const logger = getRunnerLogger(true);
|
||||||
|
const codeql = mockCodeQLVersion("2.21.0");
|
||||||
|
const features = createFeatures([Feature.DiffInformedQueries]);
|
||||||
|
|
||||||
|
sinon.stub(actionsUtil, "getPullRequestBranches").returns(undefined);
|
||||||
|
sinon
|
||||||
|
.stub(apiClient, "getGitHubVersion")
|
||||||
|
.resolves({ type: GitHubVariant.DOTCOM });
|
||||||
|
|
||||||
|
const result = await prepareDiffInformedAnalysis(
|
||||||
|
codeql,
|
||||||
|
features,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
|
||||||
|
t.false(result);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"prepareDiffInformedAnalysis: returns false when applicability check throws",
|
||||||
|
async (t) => {
|
||||||
|
await withTmpDir(async (tmpDir) => {
|
||||||
|
setupActionsVars(tmpDir, tmpDir);
|
||||||
|
const logger = getRunnerLogger(true);
|
||||||
|
const codeql = mockCodeQLVersion("2.21.0");
|
||||||
|
// A features implementation whose getValue rejects, simulating an
|
||||||
|
// unexpected failure when determining whether diff-informed analysis
|
||||||
|
// should run.
|
||||||
|
const features: FeatureEnablement = {
|
||||||
|
getEnabledDefaultCliVersions: async () => {
|
||||||
|
throw new Error("not implemented");
|
||||||
|
},
|
||||||
|
getValue: async () => {
|
||||||
|
throw new Error("feature flag lookup failed");
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = await prepareDiffInformedAnalysis(
|
||||||
|
codeql,
|
||||||
|
features,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
|
||||||
|
t.false(result);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"prepareDiffInformedAnalysis: returns true when the diff is fetched successfully",
|
||||||
|
async (t) => {
|
||||||
|
await withTmpDir(async (tmpDir) => {
|
||||||
|
setupActionsVars(tmpDir, tmpDir);
|
||||||
|
const logger = getRunnerLogger(true);
|
||||||
|
const codeql = mockCodeQLVersion("2.21.0");
|
||||||
|
const features = createFeatures([Feature.DiffInformedQueries]);
|
||||||
|
|
||||||
|
sinon
|
||||||
|
.stub(actionsUtil, "getPullRequestBranches")
|
||||||
|
.returns({ base: "main", head: "feature" });
|
||||||
|
sinon
|
||||||
|
.stub(apiClient, "getGitHubVersion")
|
||||||
|
.resolves({ type: GitHubVariant.DOTCOM });
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||||
|
sinon.stub(apiClient, "getApiClient").returns({
|
||||||
|
rest: {
|
||||||
|
repos: {
|
||||||
|
compareCommitsWithBasehead: sinon
|
||||||
|
.stub()
|
||||||
|
.resolves({ data: { files: [] } }),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
const result = await prepareDiffInformedAnalysis(
|
||||||
|
codeql,
|
||||||
|
features,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
|
||||||
|
t.true(result);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"prepareDiffInformedAnalysis: returns false when the diff API call fails",
|
||||||
|
async (t) => {
|
||||||
|
await withTmpDir(async (tmpDir) => {
|
||||||
|
setupActionsVars(tmpDir, tmpDir);
|
||||||
|
const logger = getRunnerLogger(true);
|
||||||
|
const codeql = mockCodeQLVersion("2.21.0");
|
||||||
|
const features = createFeatures([Feature.DiffInformedQueries]);
|
||||||
|
|
||||||
|
sinon
|
||||||
|
.stub(actionsUtil, "getPullRequestBranches")
|
||||||
|
.returns({ base: "main", head: "feature" });
|
||||||
|
sinon
|
||||||
|
.stub(apiClient, "getGitHubVersion")
|
||||||
|
.resolves({ type: GitHubVariant.DOTCOM });
|
||||||
|
const notFoundError: any = new Error("Not Found");
|
||||||
|
notFoundError.status = 404;
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||||
|
sinon.stub(apiClient, "getApiClient").returns({
|
||||||
|
rest: {
|
||||||
|
repos: {
|
||||||
|
compareCommitsWithBasehead: sinon.stub().rejects(notFoundError),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
const result = await prepareDiffInformedAnalysis(
|
||||||
|
codeql,
|
||||||
|
features,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
|
||||||
|
t.false(result);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
function runGetDiffRanges(changes: number, patch: string[] | undefined): any {
|
function runGetDiffRanges(changes: number, patch: string[] | undefined): any {
|
||||||
return exportedForTesting.getDiffRanges(
|
return exportedForTesting.getDiffRanges(
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import type { PullRequestBranches } from "./actions-util";
|
|||||||
import { getApiClient, getGitHubVersion } from "./api-client";
|
import { getApiClient, getGitHubVersion } from "./api-client";
|
||||||
import type { CodeQL } from "./codeql";
|
import type { CodeQL } from "./codeql";
|
||||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||||
import { Logger } from "./logging";
|
import { Logger, withGroupAsync } from "./logging";
|
||||||
import { getRepositoryNwoFromEnv } from "./repository";
|
import { getRepositoryNwoFromEnv } from "./repository";
|
||||||
import { GitHubVariant, satisfiesGHESVersion } from "./util";
|
import { getErrorMessage, GitHubVariant, satisfiesGHESVersion } from "./util";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface is an abbreviated version of the file diff object returned by
|
* This interface is an abbreviated version of the file diff object returned by
|
||||||
@@ -21,20 +21,6 @@ interface FileDiff {
|
|||||||
patch?: string | undefined;
|
patch?: string | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the action should perform diff-informed analysis.
|
|
||||||
*/
|
|
||||||
export async function shouldPerformDiffInformedAnalysis(
|
|
||||||
codeql: CodeQL,
|
|
||||||
features: FeatureEnablement,
|
|
||||||
logger: Logger,
|
|
||||||
): Promise<boolean> {
|
|
||||||
return (
|
|
||||||
(await getDiffInformedAnalysisBranches(codeql, features, logger)) !==
|
|
||||||
undefined
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the branches to use for diff-informed analysis.
|
* Get the branches to use for diff-informed analysis.
|
||||||
*
|
*
|
||||||
@@ -69,6 +55,46 @@ export async function getDiffInformedAnalysisBranches(
|
|||||||
return branches;
|
return branches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares the diff ranges needed for diff-informed analysis for the current
|
||||||
|
* run.
|
||||||
|
*
|
||||||
|
* @returns `true` if the diff ranges were successfully computed and persisted
|
||||||
|
* and are therefore available for use, `false` otherwise.
|
||||||
|
*/
|
||||||
|
export async function prepareDiffInformedAnalysis(
|
||||||
|
codeql: CodeQL,
|
||||||
|
features: FeatureEnablement,
|
||||||
|
logger: Logger,
|
||||||
|
): Promise<boolean> {
|
||||||
|
let branches: PullRequestBranches | undefined;
|
||||||
|
try {
|
||||||
|
branches = await getDiffInformedAnalysisBranches(codeql, features, logger);
|
||||||
|
} catch (e) {
|
||||||
|
// If we cannot determine whether diff-informed analysis applies (for
|
||||||
|
// example, because a feature-flag lookup failed), treat it as not
|
||||||
|
// applicable rather than triggering the overlay fallback.
|
||||||
|
logger.warning(
|
||||||
|
`Failed to determine branch information for diff-informed analysis: ${getErrorMessage(e)}`,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!branches) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return await withGroupAsync("Computing PR diff ranges", async () => {
|
||||||
|
try {
|
||||||
|
return await computeAndPersistDiffRanges(branches, logger);
|
||||||
|
} catch (e) {
|
||||||
|
logger.warning(
|
||||||
|
`Failed to compute diff-informed analysis ranges: ${getErrorMessage(e)}`,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export interface DiffThunkRange {
|
export interface DiffThunkRange {
|
||||||
/** Relative path from the repository root, using forward slashes as separators. */
|
/** Relative path from the repository root, using forward slashes as separators. */
|
||||||
path: string;
|
path: string;
|
||||||
@@ -151,6 +177,33 @@ export async function getPullRequestEditedDiffRanges(
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compute and persist the diff ranges for a pull request. This fetches the
|
||||||
|
* diff from the GitHub API and writes it to the diff ranges JSON file so that
|
||||||
|
* CodeQL can use it for diff-informed analysis.
|
||||||
|
*
|
||||||
|
* @param branches The base and head branches of the pull request, as returned
|
||||||
|
* by `getDiffInformedAnalysisBranches`.
|
||||||
|
* @param logger
|
||||||
|
* @returns `true` if the diff ranges were successfully computed and persisted,
|
||||||
|
* otherwise `false`.
|
||||||
|
*/
|
||||||
|
export async function computeAndPersistDiffRanges(
|
||||||
|
branches: PullRequestBranches,
|
||||||
|
logger: Logger,
|
||||||
|
): Promise<boolean> {
|
||||||
|
const ranges = await getPullRequestEditedDiffRanges(branches, logger);
|
||||||
|
if (ranges === undefined) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
writeDiffRangesJsonFile(logger, ranges);
|
||||||
|
const distinctFiles = new Set(ranges.map((r) => r.path)).size;
|
||||||
|
logger.info(
|
||||||
|
`Persisted ${ranges.length} diff range(s) across ${distinctFiles} file(s).`,
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
async function getFileDiffsWithBasehead(
|
async function getFileDiffsWithBasehead(
|
||||||
branches: PullRequestBranches,
|
branches: PullRequestBranches,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export async function run__ACTION__() {
|
||||||
|
return await __ACTION__.runWrapper();
|
||||||
|
}
|
||||||
+27
-12
@@ -451,12 +451,16 @@ test.serial(`selects CLI from defaults.json on GHES`, async (t) => {
|
|||||||
await withTmpDir(async (tmpDir) => {
|
await withTmpDir(async (tmpDir) => {
|
||||||
const features = setUpFeatureFlagTests(tmpDir);
|
const features = setUpFeatureFlagTests(tmpDir);
|
||||||
|
|
||||||
const defaultCliVersion = await features.getDefaultCliVersion(
|
const defaultCliVersion = await features.getEnabledDefaultCliVersions(
|
||||||
GitHubVariant.GHES,
|
GitHubVariant.GHES,
|
||||||
);
|
);
|
||||||
t.deepEqual(defaultCliVersion, {
|
t.deepEqual(defaultCliVersion, {
|
||||||
cliVersion: defaults.cliVersion,
|
enabledVersions: [
|
||||||
tagName: defaults.bundleVersion,
|
{
|
||||||
|
cliVersion: defaults.cliVersion,
|
||||||
|
tagName: defaults.bundleVersion,
|
||||||
|
},
|
||||||
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -482,10 +486,13 @@ for (const variant of [GitHubVariant.DOTCOM, GitHubVariant.GHEC_DR]) {
|
|||||||
false;
|
false;
|
||||||
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
||||||
|
|
||||||
const defaultCliVersion = await features.getDefaultCliVersion(variant);
|
const defaultCliVersion =
|
||||||
|
await features.getEnabledDefaultCliVersions(variant);
|
||||||
t.deepEqual(defaultCliVersion, {
|
t.deepEqual(defaultCliVersion, {
|
||||||
cliVersion: "2.20.1",
|
enabledVersions: [
|
||||||
tagName: "codeql-bundle-v2.20.1",
|
{ cliVersion: "2.20.1", tagName: "codeql-bundle-v2.20.1" },
|
||||||
|
{ cliVersion: "2.20.0", tagName: "codeql-bundle-v2.20.0" },
|
||||||
|
],
|
||||||
toolsFeatureFlagsValid: true,
|
toolsFeatureFlagsValid: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -500,10 +507,15 @@ for (const variant of [GitHubVariant.DOTCOM, GitHubVariant.GHEC_DR]) {
|
|||||||
const expectedFeatureEnablement = initializeFeatures(true);
|
const expectedFeatureEnablement = initializeFeatures(true);
|
||||||
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
||||||
|
|
||||||
const defaultCliVersion = await features.getDefaultCliVersion(variant);
|
const defaultCliVersion =
|
||||||
|
await features.getEnabledDefaultCliVersions(variant);
|
||||||
t.deepEqual(defaultCliVersion, {
|
t.deepEqual(defaultCliVersion, {
|
||||||
cliVersion: defaults.cliVersion,
|
enabledVersions: [
|
||||||
tagName: defaults.bundleVersion,
|
{
|
||||||
|
cliVersion: defaults.cliVersion,
|
||||||
|
tagName: defaults.bundleVersion,
|
||||||
|
},
|
||||||
|
],
|
||||||
toolsFeatureFlagsValid: false,
|
toolsFeatureFlagsValid: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -529,10 +541,13 @@ for (const variant of [GitHubVariant.DOTCOM, GitHubVariant.GHEC_DR]) {
|
|||||||
] = true;
|
] = true;
|
||||||
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
||||||
|
|
||||||
const defaultCliVersion = await features.getDefaultCliVersion(variant);
|
const defaultCliVersion =
|
||||||
|
await features.getEnabledDefaultCliVersions(variant);
|
||||||
t.deepEqual(defaultCliVersion, {
|
t.deepEqual(defaultCliVersion, {
|
||||||
cliVersion: "2.20.1",
|
enabledVersions: [
|
||||||
tagName: "codeql-bundle-v2.20.1",
|
{ cliVersion: "2.20.1", tagName: "codeql-bundle-v2.20.1" },
|
||||||
|
{ cliVersion: "2.20.0", tagName: "codeql-bundle-v2.20.0" },
|
||||||
|
],
|
||||||
toolsFeatureFlagsValid: true,
|
toolsFeatureFlagsValid: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+85
-24
@@ -26,12 +26,38 @@ const DEFAULT_VERSION_FEATURE_FLAG_SUFFIX = "_enabled";
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The first version of the CodeQL Bundle that shipped with zstd-compressed bundles.
|
* The first version of the CodeQL Bundle that shipped with zstd-compressed bundles.
|
||||||
|
*
|
||||||
|
* This is now below the minimum version of CodeQL, but we keep this around because we currently set
|
||||||
|
* up CodeQL before checking that the version is new enough.
|
||||||
*/
|
*/
|
||||||
export const CODEQL_VERSION_ZSTD_BUNDLE = "2.19.0";
|
export const CODEQL_VERSION_ZSTD_BUNDLE = "2.19.0";
|
||||||
|
|
||||||
export interface CodeQLDefaultVersionInfo {
|
const LINKED_CODEQL_VERSION: CodeQLVersionInfo = {
|
||||||
|
cliVersion: defaults.cliVersion,
|
||||||
|
tagName: defaults.bundleVersion,
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface CodeQLVersionInfo {
|
||||||
|
/** The version number of the CodeQL CLI, e.g. `2.19.0`. */
|
||||||
cliVersion: string;
|
cliVersion: string;
|
||||||
|
/**
|
||||||
|
* The tag name of the CodeQL Bundle associated with this version, e.g. `codeql-bundle-v2.19.0`.
|
||||||
|
*/
|
||||||
tagName: string;
|
tagName: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CodeQLDefaultVersionInfo {
|
||||||
|
/**
|
||||||
|
* CodeQL CLI versions that are enabled as defaults, sorted from highest to lowest.
|
||||||
|
*
|
||||||
|
* Guaranteed to be non-empty. When feature flags are unavailable, this falls back to a single
|
||||||
|
* entry containing the version pinned in `defaults.json`.
|
||||||
|
*/
|
||||||
|
enabledVersions: CodeQLVersionInfo[];
|
||||||
|
/**
|
||||||
|
* If accessed, whether the tools feature flags are valid, i.e. contain at least one enabled
|
||||||
|
* version.
|
||||||
|
*/
|
||||||
toolsFeatureFlagsValid?: boolean;
|
toolsFeatureFlagsValid?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,6 +70,8 @@ export interface CodeQLDefaultVersionInfo {
|
|||||||
* Legacy features should end with `_enabled`.
|
* Legacy features should end with `_enabled`.
|
||||||
*/
|
*/
|
||||||
export enum Feature {
|
export enum Feature {
|
||||||
|
/** Controls whether we allow multiple values for the `analysis-kinds` input. */
|
||||||
|
AllowMultipleAnalysisKinds = "allow_multiple_analysis_kinds",
|
||||||
AllowToolcacheInput = "allow_toolcache_input",
|
AllowToolcacheInput = "allow_toolcache_input",
|
||||||
CleanupTrapCaches = "cleanup_trap_caches",
|
CleanupTrapCaches = "cleanup_trap_caches",
|
||||||
CppDependencyInstallation = "cpp_dependency_installation_enabled",
|
CppDependencyInstallation = "cpp_dependency_installation_enabled",
|
||||||
@@ -72,6 +100,19 @@ export enum Feature {
|
|||||||
OverlayAnalysisGo = "overlay_analysis_go",
|
OverlayAnalysisGo = "overlay_analysis_go",
|
||||||
OverlayAnalysisJava = "overlay_analysis_java",
|
OverlayAnalysisJava = "overlay_analysis_java",
|
||||||
OverlayAnalysisJavascript = "overlay_analysis_javascript",
|
OverlayAnalysisJavascript = "overlay_analysis_javascript",
|
||||||
|
/**
|
||||||
|
* When set, chooses the default CodeQL CLI version as the highest version that is both enabled by
|
||||||
|
* feature flags and present as an overlay-base database in the Actions cache for the configured
|
||||||
|
* languages. Falls back to the highest feature flagged version if no intersecting overlay-base
|
||||||
|
* database exists in the cache.
|
||||||
|
*/
|
||||||
|
OverlayAnalysisMatchCodeqlVersion = "overlay_analysis_match_codeql_version",
|
||||||
|
/**
|
||||||
|
* Like `OverlayAnalysisMatchCodeqlVersion`, but only logs a diagnostic with the version that
|
||||||
|
* would have been chosen instead of actually changing the default CodeQL CLI version.
|
||||||
|
* `OverlayAnalysisMatchCodeqlVersion` overrides this flag.
|
||||||
|
*/
|
||||||
|
OverlayAnalysisMatchCodeqlVersionDryRun = "overlay_analysis_match_codeql_version_dry_run",
|
||||||
OverlayAnalysisPython = "overlay_analysis_python",
|
OverlayAnalysisPython = "overlay_analysis_python",
|
||||||
/**
|
/**
|
||||||
* Controls whether lower disk space requirements are used for overlay hardware checks.
|
* Controls whether lower disk space requirements are used for overlay hardware checks.
|
||||||
@@ -124,6 +165,11 @@ export type FeatureConfig = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const featureConfig = {
|
export const featureConfig = {
|
||||||
|
[Feature.AllowMultipleAnalysisKinds]: {
|
||||||
|
defaultValue: false,
|
||||||
|
envVar: "CODEQL_ACTION_ALLOW_MULTIPLE_ANALYSIS_KINDS",
|
||||||
|
minimumVersion: undefined,
|
||||||
|
},
|
||||||
[Feature.AllowToolcacheInput]: {
|
[Feature.AllowToolcacheInput]: {
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
envVar: "CODEQL_ACTION_ALLOW_TOOLCACHE_INPUT",
|
envVar: "CODEQL_ACTION_ALLOW_TOOLCACHE_INPUT",
|
||||||
@@ -277,6 +323,16 @@ export const featureConfig = {
|
|||||||
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_DISABLE_TRAP_CACHING",
|
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_DISABLE_TRAP_CACHING",
|
||||||
minimumVersion: undefined,
|
minimumVersion: undefined,
|
||||||
},
|
},
|
||||||
|
[Feature.OverlayAnalysisMatchCodeqlVersion]: {
|
||||||
|
defaultValue: false,
|
||||||
|
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_MATCH_CODEQL_VERSION",
|
||||||
|
minimumVersion: undefined,
|
||||||
|
},
|
||||||
|
[Feature.OverlayAnalysisMatchCodeqlVersionDryRun]: {
|
||||||
|
defaultValue: false,
|
||||||
|
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_MATCH_CODEQL_VERSION_DRY_RUN",
|
||||||
|
minimumVersion: undefined,
|
||||||
|
},
|
||||||
[Feature.OverlayAnalysisResourceChecksV2]: {
|
[Feature.OverlayAnalysisResourceChecksV2]: {
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RESOURCE_CHECKS_V2",
|
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RESOURCE_CHECKS_V2",
|
||||||
@@ -346,8 +402,12 @@ export type FeatureWithoutCLI = {
|
|||||||
}[keyof typeof featureConfig];
|
}[keyof typeof featureConfig];
|
||||||
|
|
||||||
export interface FeatureEnablement {
|
export interface FeatureEnablement {
|
||||||
/** Gets the default version of the CodeQL tools. */
|
/**
|
||||||
getDefaultCliVersion(
|
* Returns the set of default CodeQL CLI versions to consider, sorted from
|
||||||
|
* highest to lowest. The first entry is the version that the CodeQL Action
|
||||||
|
* will use by default. The list is always non-empty.
|
||||||
|
*/
|
||||||
|
getEnabledDefaultCliVersions(
|
||||||
variant: util.GitHubVariant,
|
variant: util.GitHubVariant,
|
||||||
): Promise<CodeQLDefaultVersionInfo>;
|
): Promise<CodeQLDefaultVersionInfo>;
|
||||||
getValue(feature: FeatureWithoutCLI): Promise<boolean>;
|
getValue(feature: FeatureWithoutCLI): Promise<boolean>;
|
||||||
@@ -371,12 +431,11 @@ export const FEATURE_FLAGS_FILE_NAME = "cached-feature-flags.json";
|
|||||||
class OfflineFeatures implements FeatureEnablement {
|
class OfflineFeatures implements FeatureEnablement {
|
||||||
constructor(protected readonly logger: Logger) {}
|
constructor(protected readonly logger: Logger) {}
|
||||||
|
|
||||||
async getDefaultCliVersion(
|
async getEnabledDefaultCliVersions(
|
||||||
_variant: util.GitHubVariant,
|
_variant: util.GitHubVariant,
|
||||||
): Promise<CodeQLDefaultVersionInfo> {
|
): Promise<CodeQLDefaultVersionInfo> {
|
||||||
return {
|
return {
|
||||||
cliVersion: defaults.cliVersion,
|
enabledVersions: [LINKED_CODEQL_VERSION],
|
||||||
tagName: defaults.bundleVersion,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,7 +445,7 @@ class OfflineFeatures implements FeatureEnablement {
|
|||||||
getFeatureConfig(feature: Feature): FeatureConfig {
|
getFeatureConfig(feature: Feature): FeatureConfig {
|
||||||
// Narrow the type to FeatureConfig to avoid type errors. To avoid unsafe use of `as`, we
|
// Narrow the type to FeatureConfig to avoid type errors. To avoid unsafe use of `as`, we
|
||||||
// check that the required properties exist using `satisfies`.
|
// check that the required properties exist using `satisfies`.
|
||||||
return featureConfig[feature] satisfies FeatureConfig as FeatureConfig;
|
return featureConfig[feature] satisfies FeatureConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -518,13 +577,13 @@ class Features extends OfflineFeatures {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getDefaultCliVersion(
|
async getEnabledDefaultCliVersions(
|
||||||
variant: util.GitHubVariant,
|
variant: util.GitHubVariant,
|
||||||
): Promise<CodeQLDefaultVersionInfo> {
|
): Promise<CodeQLDefaultVersionInfo> {
|
||||||
if (supportsFeatureFlags(variant)) {
|
if (supportsFeatureFlags(variant)) {
|
||||||
return await this.gitHubFeatureFlags.getDefaultCliVersionFromFlags();
|
return await this.gitHubFeatureFlags.getEnabledDefaultCliVersionsFromFlags();
|
||||||
}
|
}
|
||||||
return super.getDefaultCliVersion(variant);
|
return super.getEnabledDefaultCliVersions(variant);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -600,16 +659,22 @@ class GitHubFeatureFlags {
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getDefaultCliVersionFromFlags(): Promise<CodeQLDefaultVersionInfo> {
|
/**
|
||||||
|
* Returns CLI versions enabled by `default_codeql_version_*_enabled` feature
|
||||||
|
* flags, sorted from highest to lowest. Falls back to the version pinned in
|
||||||
|
* `defaults.json` if no such flags are enabled.
|
||||||
|
*/
|
||||||
|
async getEnabledDefaultCliVersionsFromFlags(): Promise<CodeQLDefaultVersionInfo> {
|
||||||
const response = await this.getAllFeatures();
|
const response = await this.getAllFeatures();
|
||||||
|
|
||||||
const enabledFeatureFlagCliVersions = Object.entries(response)
|
const sortedCliVersions = Object.entries(response)
|
||||||
.map(([f, isEnabled]) =>
|
.map(([f, isEnabled]) =>
|
||||||
isEnabled ? this.getCliVersionFromFeatureFlag(f) : undefined,
|
isEnabled ? this.getCliVersionFromFeatureFlag(f) : undefined,
|
||||||
)
|
)
|
||||||
.filter((f): f is string => f !== undefined);
|
.filter((f): f is string => f !== undefined)
|
||||||
|
.sort(semver.rcompare);
|
||||||
|
|
||||||
if (enabledFeatureFlagCliVersions.length === 0) {
|
if (sortedCliVersions.length === 0) {
|
||||||
// We expect at least one default CLI version to be enabled on Dotcom at any time. However if
|
// We expect at least one default CLI version to be enabled on Dotcom at any time. However if
|
||||||
// the feature flags are misconfigured, rather than crashing, we fall back to the CLI version
|
// the feature flags are misconfigured, rather than crashing, we fall back to the CLI version
|
||||||
// shipped with the Action in defaults.json. This has the effect of immediately rolling out
|
// shipped with the Action in defaults.json. This has the effect of immediately rolling out
|
||||||
@@ -625,8 +690,7 @@ class GitHubFeatureFlags {
|
|||||||
`shipped with the Action. This is ${defaults.cliVersion}.`,
|
`shipped with the Action. This is ${defaults.cliVersion}.`,
|
||||||
);
|
);
|
||||||
const result: CodeQLDefaultVersionInfo = {
|
const result: CodeQLDefaultVersionInfo = {
|
||||||
cliVersion: defaults.cliVersion,
|
enabledVersions: [LINKED_CODEQL_VERSION],
|
||||||
tagName: defaults.bundleVersion,
|
|
||||||
};
|
};
|
||||||
if (this.hasAccessedRemoteFeatureFlags) {
|
if (this.hasAccessedRemoteFeatureFlags) {
|
||||||
result.toolsFeatureFlagsValid = false;
|
result.toolsFeatureFlagsValid = false;
|
||||||
@@ -634,17 +698,14 @@ class GitHubFeatureFlags {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const maxCliVersion = enabledFeatureFlagCliVersions.reduce(
|
|
||||||
(maxVersion, currentVersion) =>
|
|
||||||
currentVersion > maxVersion ? currentVersion : maxVersion,
|
|
||||||
enabledFeatureFlagCliVersions[0],
|
|
||||||
);
|
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
`Derived default CLI version of ${maxCliVersion} from feature flags.`,
|
`Derived default CLI version of ${sortedCliVersions[0]} from feature flags.`,
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
cliVersion: maxCliVersion,
|
enabledVersions: sortedCliVersions.map((cliVersion) => ({
|
||||||
tagName: `codeql-bundle-v${maxCliVersion}`,
|
cliVersion,
|
||||||
|
tagName: `codeql-bundle-v${cliVersion}`,
|
||||||
|
})),
|
||||||
toolsFeatureFlagsValid: true,
|
toolsFeatureFlagsValid: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+77
-14
@@ -33,7 +33,6 @@ test.serial(
|
|||||||
|
|
||||||
const actualRef = await gitUtils.getRef();
|
const actualRef = await gitUtils.getRef();
|
||||||
t.deepEqual(actualRef, expectedRef);
|
t.deepEqual(actualRef, expectedRef);
|
||||||
callback.restore();
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -54,7 +53,6 @@ test.serial(
|
|||||||
|
|
||||||
const actualRef = await gitUtils.getRef();
|
const actualRef = await gitUtils.getRef();
|
||||||
t.deepEqual(actualRef, expectedRef);
|
t.deepEqual(actualRef, expectedRef);
|
||||||
callback.restore();
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -73,7 +71,6 @@ test.serial(
|
|||||||
|
|
||||||
const actualRef = await gitUtils.getRef();
|
const actualRef = await gitUtils.getRef();
|
||||||
t.deepEqual(actualRef, "refs/pull/1/head");
|
t.deepEqual(actualRef, "refs/pull/1/head");
|
||||||
callback.restore();
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -100,8 +97,6 @@ test.serial(
|
|||||||
|
|
||||||
const actualRef = await gitUtils.getRef();
|
const actualRef = await gitUtils.getRef();
|
||||||
t.deepEqual(actualRef, "refs/pull/2/merge");
|
t.deepEqual(actualRef, "refs/pull/2/merge");
|
||||||
callback.restore();
|
|
||||||
getAdditionalInputStub.restore();
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -161,7 +156,6 @@ test.serial(
|
|||||||
"Both 'ref' and 'sha' are required if one of them is provided.",
|
"Both 'ref' and 'sha' are required if one of them is provided.",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
getAdditionalInputStub.restore();
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -188,7 +182,6 @@ test.serial(
|
|||||||
"Both 'ref' and 'sha' are required if one of them is provided.",
|
"Both 'ref' and 'sha' are required if one of them is provided.",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
getAdditionalInputStub.restore();
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -242,7 +235,6 @@ test.serial("isAnalyzingDefaultBranch()", async (t) => {
|
|||||||
process.env["GITHUB_EVENT_NAME"] = "schedule";
|
process.env["GITHUB_EVENT_NAME"] = "schedule";
|
||||||
process.env["GITHUB_REF"] = "refs/heads/main";
|
process.env["GITHUB_REF"] = "refs/heads/main";
|
||||||
t.deepEqual(await gitUtils.isAnalyzingDefaultBranch(), false);
|
t.deepEqual(await gitUtils.isAnalyzingDefaultBranch(), false);
|
||||||
getAdditionalInputStub.restore();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -254,8 +246,6 @@ test.serial("determineBaseBranchHeadCommitOid non-pullrequest", async (t) => {
|
|||||||
const result = await gitUtils.determineBaseBranchHeadCommitOid(__dirname);
|
const result = await gitUtils.determineBaseBranchHeadCommitOid(__dirname);
|
||||||
t.deepEqual(result, undefined);
|
t.deepEqual(result, undefined);
|
||||||
t.deepEqual(0, infoStub.callCount);
|
t.deepEqual(0, infoStub.callCount);
|
||||||
|
|
||||||
infoStub.restore();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test.serial(
|
test.serial(
|
||||||
@@ -276,8 +266,6 @@ test.serial(
|
|||||||
"git call failed. Will calculate the base branch SHA on the server. Error: " +
|
"git call failed. Will calculate the base branch SHA on the server. Error: " +
|
||||||
"The checkout path provided to the action does not appear to be a git repository.",
|
"The checkout path provided to the action does not appear to be a git repository.",
|
||||||
);
|
);
|
||||||
|
|
||||||
infoStub.restore();
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -301,10 +289,27 @@ test.serial("determineBaseBranchHeadCommitOid other error", async (t) => {
|
|||||||
"The checkout path provided to the action does not appear to be a git repository.",
|
"The checkout path provided to the action does not appear to be a git repository.",
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
infoStub.restore();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"determineBaseBranchHeadCommitOid accepts SHA-256 OIDs",
|
||||||
|
async (t) => {
|
||||||
|
const mergeSha = "a".repeat(64);
|
||||||
|
const baseOid = "b".repeat(64);
|
||||||
|
const headOid = "c".repeat(64);
|
||||||
|
|
||||||
|
process.env["GITHUB_EVENT_NAME"] = "pull_request";
|
||||||
|
process.env["GITHUB_SHA"] = mergeSha;
|
||||||
|
|
||||||
|
sinon
|
||||||
|
.stub(gitUtils as any, "runGitCommand")
|
||||||
|
.resolves(`commit ${mergeSha}\nparent ${baseOid}\nparent ${headOid}\n`);
|
||||||
|
|
||||||
|
const result = await gitUtils.determineBaseBranchHeadCommitOid(__dirname);
|
||||||
|
t.deepEqual(result, baseOid);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
test.serial("decodeGitFilePath unquoted strings", async (t) => {
|
test.serial("decodeGitFilePath unquoted strings", async (t) => {
|
||||||
t.deepEqual(gitUtils.decodeGitFilePath("foo"), "foo");
|
t.deepEqual(gitUtils.decodeGitFilePath("foo"), "foo");
|
||||||
t.deepEqual(gitUtils.decodeGitFilePath("foo bar"), "foo bar");
|
t.deepEqual(gitUtils.decodeGitFilePath("foo bar"), "foo bar");
|
||||||
@@ -436,6 +441,64 @@ test.serial("getFileOidsUnderPath handles quoted paths", async (t) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test.serial("getFileOidsUnderPath handles SHA-256 OIDs", async (t) => {
|
||||||
|
await withTmpDir(async (tmpDir) => {
|
||||||
|
const sha256OidA =
|
||||||
|
"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2c0d4b7e8f9a1234567890ab";
|
||||||
|
const sha256OidB =
|
||||||
|
"aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899";
|
||||||
|
|
||||||
|
sinon
|
||||||
|
.stub(gitUtils as any, "runGitCommand")
|
||||||
|
.callsFake(async (_cwd: any, args: any) => {
|
||||||
|
if (args[0] === "rev-parse") {
|
||||||
|
return `${tmpDir}\n`;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
`100644 ${sha256OidA} 0\tlib/sha256-file-a.js\n` +
|
||||||
|
`100644 ${sha256OidB} 0\tsrc/sha256-file-b.ts`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await gitUtils.getFileOidsUnderPath("/fake/path");
|
||||||
|
|
||||||
|
t.deepEqual(result, {
|
||||||
|
"lib/sha256-file-a.js": sha256OidA,
|
||||||
|
"src/sha256-file-b.ts": sha256OidB,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"getFileOidsUnderPath rejects OIDs of unsupported length",
|
||||||
|
async (t) => {
|
||||||
|
await withTmpDir(async (tmpDir) => {
|
||||||
|
// 50-char OID: not a valid SHA-1 (40) or SHA-256 (64) length. The regex
|
||||||
|
// must not accept this even though every character is a valid hex digit.
|
||||||
|
const invalidLine =
|
||||||
|
"100644 30d998ded095371488be3a729eb61d86ed721a1830d998ded0 0\tlib/bad.js";
|
||||||
|
sinon
|
||||||
|
.stub(gitUtils as any, "runGitCommand")
|
||||||
|
.callsFake(async (_cwd: any, args: any) => {
|
||||||
|
if (args[0] === "rev-parse") {
|
||||||
|
return `${tmpDir}\n`;
|
||||||
|
}
|
||||||
|
return invalidLine;
|
||||||
|
});
|
||||||
|
|
||||||
|
await t.throwsAsync(
|
||||||
|
async () => {
|
||||||
|
await gitUtils.getFileOidsUnderPath("/fake/path");
|
||||||
|
},
|
||||||
|
{
|
||||||
|
instanceOf: Error,
|
||||||
|
message: `Unexpected "git ls-files" output: ${invalidLine}`,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
test.serial("getFileOidsUnderPath handles empty output", async (t) => {
|
test.serial("getFileOidsUnderPath handles empty output", async (t) => {
|
||||||
await withTmpDir(async (tmpDir) => {
|
await withTmpDir(async (tmpDir) => {
|
||||||
sinon
|
sinon
|
||||||
|
|||||||
+6
-4
@@ -163,11 +163,12 @@ export const determineBaseBranchHeadCommitOid = async function (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let's confirm our assumptions: We had a merge commit and the parsed parent data looks correct
|
// Let's confirm our assumptions: We had a merge commit and the parsed parent
|
||||||
|
// data looks correct. OIDs are either 40 (SHA-1) or 64 (SHA-256) hex characters.
|
||||||
if (
|
if (
|
||||||
commitOid === mergeSha &&
|
commitOid === mergeSha &&
|
||||||
headOid.length === 40 &&
|
(headOid.length === 40 || headOid.length === 64) &&
|
||||||
baseOid.length === 40
|
(baseOid.length === 40 || baseOid.length === 64)
|
||||||
) {
|
) {
|
||||||
return baseOid;
|
return baseOid;
|
||||||
}
|
}
|
||||||
@@ -296,7 +297,8 @@ export const getFileOidsUnderPath = async function (
|
|||||||
// 100644 4c51bc1d9e86cd86e01b0f340cb8ce095c33b283 0\tsrc/git-utils.test.ts
|
// 100644 4c51bc1d9e86cd86e01b0f340cb8ce095c33b283 0\tsrc/git-utils.test.ts
|
||||||
// 100644 6b792ea543ce75d7a8a03df591e3c85311ecb64f 0\tsrc/git-utils.ts
|
// 100644 6b792ea543ce75d7a8a03df591e3c85311ecb64f 0\tsrc/git-utils.ts
|
||||||
// The fields are: <mode> <oid> <stage>\t<path>
|
// The fields are: <mode> <oid> <stage>\t<path>
|
||||||
const regex = /^[0-9]+ ([0-9a-f]{40}) [0-9]+\t(.+)$/;
|
// The OID is either 40 (SHA-1) or 64 (SHA-256) hex characters.
|
||||||
|
const regex = /^[0-9]+ ([0-9a-f]{40}|[0-9a-f]{64}) [0-9]+\t(.+)$/;
|
||||||
for (const line of stdout.split("\n")) {
|
for (const line of stdout.split("\n")) {
|
||||||
if (line) {
|
if (line) {
|
||||||
const match = line.match(regex);
|
const match = line.match(regex);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
createFeatures,
|
createFeatures,
|
||||||
createTestConfig,
|
createTestConfig,
|
||||||
DEFAULT_ACTIONS_VARS,
|
DEFAULT_ACTIONS_VARS,
|
||||||
|
makeMacro,
|
||||||
makeVersionInfo,
|
makeVersionInfo,
|
||||||
RecordingLogger,
|
RecordingLogger,
|
||||||
setupActionsVars,
|
setupActionsVars,
|
||||||
@@ -601,7 +602,7 @@ async function testFailedSarifUpload(
|
|||||||
uploadFiles.resolves({
|
uploadFiles.resolves({
|
||||||
sarifID: "42",
|
sarifID: "42",
|
||||||
statusReport: { raw_upload_size_bytes: 20, zipped_upload_size_bytes: 10 },
|
statusReport: { raw_upload_size_bytes: 20, zipped_upload_size_bytes: 10 },
|
||||||
} as uploadLib.UploadResult);
|
});
|
||||||
const waitForProcessing = sinon.stub(uploadLib, "waitForProcessing");
|
const waitForProcessing = sinon.stub(uploadLib, "waitForProcessing");
|
||||||
|
|
||||||
const features = [] as Feature[];
|
const features = [] as Feature[];
|
||||||
@@ -796,7 +797,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const skippedUploadTest = test.macro({
|
const skippedUploadTest = makeMacro({
|
||||||
exec: async (
|
exec: async (
|
||||||
t: ExecutionContext<unknown>,
|
t: ExecutionContext<unknown>,
|
||||||
config: Partial<configUtils.Config>,
|
config: Partial<configUtils.Config>,
|
||||||
@@ -823,9 +824,8 @@ const skippedUploadTest = test.macro({
|
|||||||
`tryUploadSarifIfRunFailed - skips upload ${providedTitle}`,
|
`tryUploadSarifIfRunFailed - skips upload ${providedTitle}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
test.serial(
|
skippedUploadTest.serial(
|
||||||
"without CodeQL command",
|
"without CodeQL command",
|
||||||
skippedUploadTest,
|
|
||||||
// No codeQLCmd
|
// No codeQLCmd
|
||||||
{
|
{
|
||||||
analysisKinds: [AnalysisKind.RiskAssessment],
|
analysisKinds: [AnalysisKind.RiskAssessment],
|
||||||
@@ -834,9 +834,8 @@ test.serial(
|
|||||||
"CodeQL command not found",
|
"CodeQL command not found",
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
skippedUploadTest.serial(
|
||||||
"if no language is configured",
|
"if no language is configured",
|
||||||
skippedUploadTest,
|
|
||||||
// No explicit language configuration
|
// No explicit language configuration
|
||||||
{
|
{
|
||||||
analysisKinds: [AnalysisKind.RiskAssessment],
|
analysisKinds: [AnalysisKind.RiskAssessment],
|
||||||
@@ -845,9 +844,8 @@ test.serial(
|
|||||||
"Unexpectedly, the configuration is not for a single language.",
|
"Unexpectedly, the configuration is not for a single language.",
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
skippedUploadTest.serial(
|
||||||
"if multiple languages is configured",
|
"if multiple languages is configured",
|
||||||
skippedUploadTest,
|
|
||||||
// Multiple explicit languages configured
|
// Multiple explicit languages configured
|
||||||
{
|
{
|
||||||
analysisKinds: [AnalysisKind.RiskAssessment],
|
analysisKinds: [AnalysisKind.RiskAssessment],
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ function getJobStatusFromEnvironment(): JobStatus | undefined {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runWrapper() {
|
export async function runWrapper() {
|
||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
const logger = getActionsLogger();
|
const logger = getActionsLogger();
|
||||||
try {
|
try {
|
||||||
@@ -222,5 +222,3 @@ async function runWrapper() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void runWrapper();
|
|
||||||
|
|||||||
+13
-50
@@ -37,11 +37,6 @@ import {
|
|||||||
makeDiagnostic,
|
makeDiagnostic,
|
||||||
makeTelemetryDiagnostic,
|
makeTelemetryDiagnostic,
|
||||||
} from "./diagnostics";
|
} from "./diagnostics";
|
||||||
import {
|
|
||||||
getDiffInformedAnalysisBranches,
|
|
||||||
getPullRequestEditedDiffRanges,
|
|
||||||
writeDiffRangesJsonFile,
|
|
||||||
} from "./diff-informed-analysis-utils";
|
|
||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
import { Feature, FeatureEnablement, initFeatures } from "./feature-flags";
|
import { Feature, FeatureEnablement, initFeatures } from "./feature-flags";
|
||||||
import {
|
import {
|
||||||
@@ -281,7 +276,7 @@ async function run(startedAt: Date) {
|
|||||||
// successful, the results are cached so that we don't duplicate the work in normal runs.
|
// successful, the results are cached so that we don't duplicate the work in normal runs.
|
||||||
let analysisKinds: AnalysisKind[] | undefined;
|
let analysisKinds: AnalysisKind[] | undefined;
|
||||||
try {
|
try {
|
||||||
analysisKinds = await getAnalysisKinds(logger);
|
analysisKinds = await getAnalysisKinds(logger, features);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`Failed to parse analysis kinds for 'starting' status report: ${getErrorMessage(err)}`,
|
`Failed to parse analysis kinds for 'starting' status report: ${getErrorMessage(err)}`,
|
||||||
@@ -298,16 +293,23 @@ async function run(startedAt: Date) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const codeQLDefaultVersionInfo = await features.getDefaultCliVersion(
|
const codeQLDefaultVersionInfo =
|
||||||
gitHubVersion.type,
|
await features.getEnabledDefaultCliVersions(gitHubVersion.type);
|
||||||
);
|
|
||||||
toolsFeatureFlagsValid = codeQLDefaultVersionInfo.toolsFeatureFlagsValid;
|
toolsFeatureFlagsValid = codeQLDefaultVersionInfo.toolsFeatureFlagsValid;
|
||||||
|
const rawLanguages = configUtils.getRawLanguagesNoAutodetect(
|
||||||
|
getOptionalInput("languages"),
|
||||||
|
);
|
||||||
|
const useOverlayAwareDefaultCliVersion =
|
||||||
|
analysisKinds?.length === 1 &&
|
||||||
|
analysisKinds[0] === AnalysisKind.CodeScanning;
|
||||||
const initCodeQLResult = await initCodeQL(
|
const initCodeQLResult = await initCodeQL(
|
||||||
getOptionalInput("tools"),
|
getOptionalInput("tools"),
|
||||||
apiDetails,
|
apiDetails,
|
||||||
getTemporaryDirectory(),
|
getTemporaryDirectory(),
|
||||||
gitHubVersion.type,
|
gitHubVersion.type,
|
||||||
codeQLDefaultVersionInfo,
|
codeQLDefaultVersionInfo,
|
||||||
|
rawLanguages,
|
||||||
|
useOverlayAwareDefaultCliVersion,
|
||||||
features,
|
features,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
@@ -346,7 +348,7 @@ async function run(startedAt: Date) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
analysisKinds = await getAnalysisKinds(logger);
|
analysisKinds = await getAnalysisKinds(logger, features);
|
||||||
const debugMode = getOptionalInput("debug") === "true" || core.isDebug();
|
const debugMode = getOptionalInput("debug") === "true" || core.isDebug();
|
||||||
const repositoryProperties = repositoryPropertiesResult.orElse({});
|
const repositoryProperties = repositoryPropertiesResult.orElse({});
|
||||||
const fileCoverageResult = await getFileCoverageInformationEnabled(
|
const fileCoverageResult = await getFileCoverageInformationEnabled(
|
||||||
@@ -427,7 +429,6 @@ async function run(startedAt: Date) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await checkInstallPython311(config.languages, codeql);
|
await checkInstallPython311(config.languages, codeql);
|
||||||
await computeAndPersistDiffRanges(codeql, features, logger);
|
|
||||||
} catch (unwrappedError) {
|
} catch (unwrappedError) {
|
||||||
const error = wrapError(unwrappedError);
|
const error = wrapError(unwrappedError);
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
@@ -823,42 +824,6 @@ async function loadRepositoryProperties(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute and persist diff ranges when diff-informed analysis is enabled
|
|
||||||
* (feature flag + PR context). This writes the standard pr-diff-range.json
|
|
||||||
* file for later reuse in the analyze step. Failures are logged but non-fatal.
|
|
||||||
*/
|
|
||||||
async function computeAndPersistDiffRanges(
|
|
||||||
codeql: CodeQL,
|
|
||||||
features: FeatureEnablement,
|
|
||||||
logger: Logger,
|
|
||||||
): Promise<void> {
|
|
||||||
await withGroupAsync("Computing PR diff ranges", async () => {
|
|
||||||
try {
|
|
||||||
const branches = await getDiffInformedAnalysisBranches(
|
|
||||||
codeql,
|
|
||||||
features,
|
|
||||||
logger,
|
|
||||||
);
|
|
||||||
if (!branches) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const ranges = await getPullRequestEditedDiffRanges(branches, logger);
|
|
||||||
if (ranges === undefined) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
writeDiffRangesJsonFile(logger, ranges);
|
|
||||||
const distinctFiles = new Set(ranges.map((r) => r.path)).size;
|
|
||||||
logger.info(
|
|
||||||
`Persisted ${ranges.length} diff range(s) across ${distinctFiles} file(s).`,
|
|
||||||
);
|
|
||||||
} catch (e) {
|
|
||||||
logger.warning(
|
|
||||||
`Failed to compute and persist PR diff ranges: ${getErrorMessage(e)}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async function recordZstdAvailability(
|
async function recordZstdAvailability(
|
||||||
config: configUtils.Config,
|
config: configUtils.Config,
|
||||||
zstdAvailability: ZstdAvailability,
|
zstdAvailability: ZstdAvailability,
|
||||||
@@ -873,7 +838,7 @@ async function recordZstdAvailability(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runWrapper() {
|
export async function runWrapper() {
|
||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
const logger = getActionsLogger();
|
const logger = getActionsLogger();
|
||||||
try {
|
try {
|
||||||
@@ -889,5 +854,3 @@ async function runWrapper() {
|
|||||||
}
|
}
|
||||||
await checkForTimeout();
|
await checkForTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void runWrapper();
|
|
||||||
|
|||||||
+15
-27
@@ -22,6 +22,7 @@ import {
|
|||||||
createTestConfig,
|
createTestConfig,
|
||||||
getRecordingLogger,
|
getRecordingLogger,
|
||||||
setupTests,
|
setupTests,
|
||||||
|
makeMacro,
|
||||||
} from "./testing-utils";
|
} from "./testing-utils";
|
||||||
import { ConfigurationError, withTmpDir } from "./util";
|
import { ConfigurationError, withTmpDir } from "./util";
|
||||||
|
|
||||||
@@ -158,10 +159,9 @@ type PackInfo = {
|
|||||||
qlpackFileName?: string;
|
qlpackFileName?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const testCheckPacksForOverlayCompatibility = test.macro({
|
const testCheckPacksForOverlayCompatibility = makeMacro({
|
||||||
exec: async (
|
exec: async (
|
||||||
t: ExecutionContext,
|
t: ExecutionContext,
|
||||||
_title: string,
|
|
||||||
{
|
{
|
||||||
cliOverlayVersion,
|
cliOverlayVersion,
|
||||||
languages,
|
languages,
|
||||||
@@ -234,11 +234,10 @@ const testCheckPacksForOverlayCompatibility = test.macro({
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
title: (_, title) => `checkPacksForOverlayCompatibility: ${title}`,
|
title: (title) => `checkPacksForOverlayCompatibility: ${title}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
testCheckPacksForOverlayCompatibility(
|
||||||
testCheckPacksForOverlayCompatibility,
|
|
||||||
"returns false when CLI does not support overlay",
|
"returns false when CLI does not support overlay",
|
||||||
{
|
{
|
||||||
cliOverlayVersion: undefined,
|
cliOverlayVersion: undefined,
|
||||||
@@ -253,8 +252,7 @@ test(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
testCheckPacksForOverlayCompatibility(
|
||||||
testCheckPacksForOverlayCompatibility,
|
|
||||||
"returns true when there are no query packs",
|
"returns true when there are no query packs",
|
||||||
{
|
{
|
||||||
cliOverlayVersion: 2,
|
cliOverlayVersion: 2,
|
||||||
@@ -264,8 +262,7 @@ test(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
testCheckPacksForOverlayCompatibility(
|
||||||
testCheckPacksForOverlayCompatibility,
|
|
||||||
"returns true when query pack has not been compiled",
|
"returns true when query pack has not been compiled",
|
||||||
{
|
{
|
||||||
cliOverlayVersion: 2,
|
cliOverlayVersion: 2,
|
||||||
@@ -281,8 +278,7 @@ test(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
testCheckPacksForOverlayCompatibility(
|
||||||
testCheckPacksForOverlayCompatibility,
|
|
||||||
"returns true when query pack has expected overlay version",
|
"returns true when query pack has expected overlay version",
|
||||||
{
|
{
|
||||||
cliOverlayVersion: 2,
|
cliOverlayVersion: 2,
|
||||||
@@ -297,8 +293,7 @@ test(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
testCheckPacksForOverlayCompatibility(
|
||||||
testCheckPacksForOverlayCompatibility,
|
|
||||||
"returns true when query packs for all languages to analyze are compatible",
|
"returns true when query packs for all languages to analyze are compatible",
|
||||||
{
|
{
|
||||||
cliOverlayVersion: 2,
|
cliOverlayVersion: 2,
|
||||||
@@ -317,8 +312,7 @@ test(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
testCheckPacksForOverlayCompatibility(
|
||||||
testCheckPacksForOverlayCompatibility,
|
|
||||||
"returns true when query pack for a language not analyzed is incompatible",
|
"returns true when query pack for a language not analyzed is incompatible",
|
||||||
{
|
{
|
||||||
cliOverlayVersion: 2,
|
cliOverlayVersion: 2,
|
||||||
@@ -337,8 +331,7 @@ test(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
testCheckPacksForOverlayCompatibility(
|
||||||
testCheckPacksForOverlayCompatibility,
|
|
||||||
"returns false when query pack for a language to analyze is incompatible",
|
"returns false when query pack for a language to analyze is incompatible",
|
||||||
{
|
{
|
||||||
cliOverlayVersion: 2,
|
cliOverlayVersion: 2,
|
||||||
@@ -357,8 +350,7 @@ test(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
testCheckPacksForOverlayCompatibility(
|
||||||
testCheckPacksForOverlayCompatibility,
|
|
||||||
"returns false when query pack is missing .packinfo",
|
"returns false when query pack is missing .packinfo",
|
||||||
{
|
{
|
||||||
cliOverlayVersion: 2,
|
cliOverlayVersion: 2,
|
||||||
@@ -377,8 +369,7 @@ test(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
testCheckPacksForOverlayCompatibility(
|
||||||
testCheckPacksForOverlayCompatibility,
|
|
||||||
"returns false when query pack has different overlay version",
|
"returns false when query pack has different overlay version",
|
||||||
{
|
{
|
||||||
cliOverlayVersion: 2,
|
cliOverlayVersion: 2,
|
||||||
@@ -397,8 +388,7 @@ test(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
testCheckPacksForOverlayCompatibility(
|
||||||
testCheckPacksForOverlayCompatibility,
|
|
||||||
"returns false when query pack is missing overlayVersion in .packinfo",
|
"returns false when query pack is missing overlayVersion in .packinfo",
|
||||||
{
|
{
|
||||||
cliOverlayVersion: 2,
|
cliOverlayVersion: 2,
|
||||||
@@ -417,8 +407,7 @@ test(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
testCheckPacksForOverlayCompatibility(
|
||||||
testCheckPacksForOverlayCompatibility,
|
|
||||||
"returns false when .packinfo is not valid JSON",
|
"returns false when .packinfo is not valid JSON",
|
||||||
{
|
{
|
||||||
cliOverlayVersion: 2,
|
cliOverlayVersion: 2,
|
||||||
@@ -437,8 +426,7 @@ test(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test(
|
testCheckPacksForOverlayCompatibility(
|
||||||
testCheckPacksForOverlayCompatibility,
|
|
||||||
"returns true when query pack uses codeql-pack.yml filename",
|
"returns true when query pack uses codeql-pack.yml filename",
|
||||||
{
|
{
|
||||||
cliOverlayVersion: 2,
|
cliOverlayVersion: 2,
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ export async function initCodeQL(
|
|||||||
tempDir: string,
|
tempDir: string,
|
||||||
variant: util.GitHubVariant,
|
variant: util.GitHubVariant,
|
||||||
defaultCliVersion: CodeQLDefaultVersionInfo,
|
defaultCliVersion: CodeQLDefaultVersionInfo,
|
||||||
|
rawLanguages: string[] | undefined,
|
||||||
|
useOverlayAwareDefaultCliVersion: boolean,
|
||||||
features: FeatureEnablement,
|
features: FeatureEnablement,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
): Promise<{
|
): Promise<{
|
||||||
@@ -61,6 +63,8 @@ export async function initCodeQL(
|
|||||||
tempDir,
|
tempDir,
|
||||||
variant,
|
variant,
|
||||||
defaultCliVersion,
|
defaultCliVersion,
|
||||||
|
rawLanguages,
|
||||||
|
useOverlayAwareDefaultCliVersion,
|
||||||
features,
|
features,
|
||||||
logger,
|
logger,
|
||||||
true,
|
true,
|
||||||
|
|||||||
+56
-60
@@ -13,6 +13,7 @@ import { BuiltInLanguage } from "../languages";
|
|||||||
import { getRunnerLogger } from "../logging";
|
import { getRunnerLogger } from "../logging";
|
||||||
import {
|
import {
|
||||||
createTestConfig,
|
createTestConfig,
|
||||||
|
makeMacro,
|
||||||
mockCodeQLVersion,
|
mockCodeQLVersion,
|
||||||
setupTests,
|
setupTests,
|
||||||
} from "../testing-utils";
|
} from "../testing-utils";
|
||||||
@@ -51,10 +52,9 @@ const defaultDownloadTestCase: DownloadOverlayBaseDatabaseTestCase = {
|
|||||||
resolveDatabaseOutput: { overlayBaseSpecifier: "20250626:XXX" },
|
resolveDatabaseOutput: { overlayBaseSpecifier: "20250626:XXX" },
|
||||||
};
|
};
|
||||||
|
|
||||||
const testDownloadOverlayBaseDatabaseFromCache = test.macro({
|
const testDownloadOverlayBaseDatabaseFromCache = makeMacro({
|
||||||
exec: async (
|
exec: async (
|
||||||
t,
|
t,
|
||||||
_title: string,
|
|
||||||
partialTestCase: Partial<DownloadOverlayBaseDatabaseTestCase>,
|
partialTestCase: Partial<DownloadOverlayBaseDatabaseTestCase>,
|
||||||
expectDownloadSuccess: boolean,
|
expectDownloadSuccess: boolean,
|
||||||
) => {
|
) => {
|
||||||
@@ -80,80 +80,59 @@ const testDownloadOverlayBaseDatabaseFromCache = test.macro({
|
|||||||
await fs.promises.writeFile(baseDatabaseOidsFile, JSON.stringify({}));
|
await fs.promises.writeFile(baseDatabaseOidsFile, JSON.stringify({}));
|
||||||
}
|
}
|
||||||
|
|
||||||
const stubs: sinon.SinonStub[] = [];
|
sinon.stub(apiClient, "getAutomationID").resolves("test-automation-id/");
|
||||||
|
|
||||||
const getAutomationIDStub = sinon
|
sinon.stub(utils, "isInTestMode").returns(testCase.isInTestMode);
|
||||||
.stub(apiClient, "getAutomationID")
|
|
||||||
.resolves("test-automation-id/");
|
|
||||||
stubs.push(getAutomationIDStub);
|
|
||||||
|
|
||||||
const isInTestModeStub = sinon
|
|
||||||
.stub(utils, "isInTestMode")
|
|
||||||
.returns(testCase.isInTestMode);
|
|
||||||
stubs.push(isInTestModeStub);
|
|
||||||
|
|
||||||
if (testCase.restoreCacheResult instanceof Error) {
|
if (testCase.restoreCacheResult instanceof Error) {
|
||||||
const restoreCacheStub = sinon
|
sinon
|
||||||
.stub(actionsCache, "restoreCache")
|
.stub(actionsCache, "restoreCache")
|
||||||
.rejects(testCase.restoreCacheResult);
|
.rejects(testCase.restoreCacheResult);
|
||||||
stubs.push(restoreCacheStub);
|
|
||||||
} else {
|
} else {
|
||||||
const restoreCacheStub = sinon
|
sinon
|
||||||
.stub(actionsCache, "restoreCache")
|
.stub(actionsCache, "restoreCache")
|
||||||
.resolves(testCase.restoreCacheResult);
|
.resolves(testCase.restoreCacheResult);
|
||||||
stubs.push(restoreCacheStub);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const tryGetFolderBytesStub = sinon
|
sinon
|
||||||
.stub(utils, "tryGetFolderBytes")
|
.stub(utils, "tryGetFolderBytes")
|
||||||
.resolves(testCase.tryGetFolderBytesSucceeds ? 1024 * 1024 : undefined);
|
.resolves(testCase.tryGetFolderBytesSucceeds ? 1024 * 1024 : undefined);
|
||||||
stubs.push(tryGetFolderBytesStub);
|
|
||||||
|
|
||||||
const codeql = mockCodeQLVersion(testCase.codeQLVersion);
|
const codeql = mockCodeQLVersion(testCase.codeQLVersion);
|
||||||
|
|
||||||
if (testCase.resolveDatabaseOutput instanceof Error) {
|
if (testCase.resolveDatabaseOutput instanceof Error) {
|
||||||
const resolveDatabaseStub = sinon
|
sinon
|
||||||
.stub(codeql, "resolveDatabase")
|
.stub(codeql, "resolveDatabase")
|
||||||
.rejects(testCase.resolveDatabaseOutput);
|
.rejects(testCase.resolveDatabaseOutput);
|
||||||
stubs.push(resolveDatabaseStub);
|
|
||||||
} else {
|
} else {
|
||||||
const resolveDatabaseStub = sinon
|
sinon
|
||||||
.stub(codeql, "resolveDatabase")
|
.stub(codeql, "resolveDatabase")
|
||||||
.resolves(testCase.resolveDatabaseOutput);
|
.resolves(testCase.resolveDatabaseOutput);
|
||||||
stubs.push(resolveDatabaseStub);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
const result = await downloadOverlayBaseDatabaseFromCache(
|
||||||
const result = await downloadOverlayBaseDatabaseFromCache(
|
codeql,
|
||||||
codeql,
|
config,
|
||||||
config,
|
logger,
|
||||||
logger,
|
);
|
||||||
);
|
|
||||||
|
|
||||||
if (expectDownloadSuccess) {
|
if (expectDownloadSuccess) {
|
||||||
t.truthy(result);
|
t.truthy(result);
|
||||||
} else {
|
} else {
|
||||||
t.is(result, undefined);
|
t.is(result, undefined);
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
for (const stub of stubs) {
|
|
||||||
stub.restore();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
title: (_, title) => `downloadOverlayBaseDatabaseFromCache: ${title}`,
|
title: (title) => `downloadOverlayBaseDatabaseFromCache: ${title}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
test.serial(
|
testDownloadOverlayBaseDatabaseFromCache.serial(
|
||||||
testDownloadOverlayBaseDatabaseFromCache,
|
|
||||||
"returns stats when successful",
|
"returns stats when successful",
|
||||||
{},
|
{},
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
testDownloadOverlayBaseDatabaseFromCache.serial(
|
||||||
testDownloadOverlayBaseDatabaseFromCache,
|
|
||||||
"returns undefined when mode is OverlayDatabaseMode.OverlayBase",
|
"returns undefined when mode is OverlayDatabaseMode.OverlayBase",
|
||||||
{
|
{
|
||||||
overlayDatabaseMode: OverlayDatabaseMode.OverlayBase,
|
overlayDatabaseMode: OverlayDatabaseMode.OverlayBase,
|
||||||
@@ -161,8 +140,7 @@ test.serial(
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
testDownloadOverlayBaseDatabaseFromCache.serial(
|
||||||
testDownloadOverlayBaseDatabaseFromCache,
|
|
||||||
"returns undefined when mode is OverlayDatabaseMode.None",
|
"returns undefined when mode is OverlayDatabaseMode.None",
|
||||||
{
|
{
|
||||||
overlayDatabaseMode: OverlayDatabaseMode.None,
|
overlayDatabaseMode: OverlayDatabaseMode.None,
|
||||||
@@ -170,8 +148,7 @@ test.serial(
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
testDownloadOverlayBaseDatabaseFromCache.serial(
|
||||||
testDownloadOverlayBaseDatabaseFromCache,
|
|
||||||
"returns undefined when caching is disabled",
|
"returns undefined when caching is disabled",
|
||||||
{
|
{
|
||||||
useOverlayDatabaseCaching: false,
|
useOverlayDatabaseCaching: false,
|
||||||
@@ -179,8 +156,7 @@ test.serial(
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
testDownloadOverlayBaseDatabaseFromCache.serial(
|
||||||
testDownloadOverlayBaseDatabaseFromCache,
|
|
||||||
"returns undefined in test mode",
|
"returns undefined in test mode",
|
||||||
{
|
{
|
||||||
isInTestMode: true,
|
isInTestMode: true,
|
||||||
@@ -188,8 +164,7 @@ test.serial(
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
testDownloadOverlayBaseDatabaseFromCache.serial(
|
||||||
testDownloadOverlayBaseDatabaseFromCache,
|
|
||||||
"returns undefined when cache miss",
|
"returns undefined when cache miss",
|
||||||
{
|
{
|
||||||
restoreCacheResult: undefined,
|
restoreCacheResult: undefined,
|
||||||
@@ -197,8 +172,7 @@ test.serial(
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
testDownloadOverlayBaseDatabaseFromCache.serial(
|
||||||
testDownloadOverlayBaseDatabaseFromCache,
|
|
||||||
"returns undefined when download fails",
|
"returns undefined when download fails",
|
||||||
{
|
{
|
||||||
restoreCacheResult: new Error("Download failed"),
|
restoreCacheResult: new Error("Download failed"),
|
||||||
@@ -206,8 +180,7 @@ test.serial(
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
testDownloadOverlayBaseDatabaseFromCache.serial(
|
||||||
testDownloadOverlayBaseDatabaseFromCache,
|
|
||||||
"returns undefined when downloaded database is invalid",
|
"returns undefined when downloaded database is invalid",
|
||||||
{
|
{
|
||||||
hasBaseDatabaseOidsFile: false,
|
hasBaseDatabaseOidsFile: false,
|
||||||
@@ -215,8 +188,7 @@ test.serial(
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
testDownloadOverlayBaseDatabaseFromCache.serial(
|
||||||
testDownloadOverlayBaseDatabaseFromCache,
|
|
||||||
"returns undefined when downloaded database doesn't have an overlayBaseSpecifier",
|
"returns undefined when downloaded database doesn't have an overlayBaseSpecifier",
|
||||||
{
|
{
|
||||||
resolveDatabaseOutput: {},
|
resolveDatabaseOutput: {},
|
||||||
@@ -224,8 +196,7 @@ test.serial(
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
testDownloadOverlayBaseDatabaseFromCache.serial(
|
||||||
testDownloadOverlayBaseDatabaseFromCache,
|
|
||||||
"returns undefined when resolving database metadata fails",
|
"returns undefined when resolving database metadata fails",
|
||||||
{
|
{
|
||||||
resolveDatabaseOutput: new Error("Failed to resolve database metadata"),
|
resolveDatabaseOutput: new Error("Failed to resolve database metadata"),
|
||||||
@@ -233,8 +204,7 @@ test.serial(
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
testDownloadOverlayBaseDatabaseFromCache.serial(
|
||||||
testDownloadOverlayBaseDatabaseFromCache,
|
|
||||||
"returns undefined when filesystem error occurs",
|
"returns undefined when filesystem error occurs",
|
||||||
{
|
{
|
||||||
tryGetFolderBytesSucceeds: false,
|
tryGetFolderBytesSucceeds: false,
|
||||||
@@ -391,6 +361,32 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"getCodeQlVersionsForOverlayBaseDatabases de-duplicates resolved language aliases",
|
||||||
|
async (t) => {
|
||||||
|
const logger = getRunnerLogger(true);
|
||||||
|
|
||||||
|
sinon.stub(apiClient, "getAutomationID").resolves("test-automation-id/");
|
||||||
|
const listActionsCachesStub = sinon
|
||||||
|
.stub(apiClient, "listActionsCaches")
|
||||||
|
.resolves([
|
||||||
|
{
|
||||||
|
key: "codeql-overlay-base-database-1-c5666c509a2d9895-javascript_python-2.25.0-abc123-1-1",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
const result = await getCodeQlVersionsForOverlayBaseDatabases(
|
||||||
|
["javascript", "typescript", "Python", "python"],
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
t.deepEqual(result, ["2.25.0"]);
|
||||||
|
sinon.assert.calledOnceWithExactly(
|
||||||
|
listActionsCachesStub,
|
||||||
|
"codeql-overlay-base-database-1-c5666c509a2d9895-javascript_python-",
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
test.serial(
|
test.serial(
|
||||||
"getCodeQlVersionsForOverlayBaseDatabases ignores nightly versions with build metadata",
|
"getCodeQlVersionsForOverlayBaseDatabases ignores nightly versions with build metadata",
|
||||||
async (t) => {
|
async (t) => {
|
||||||
|
|||||||
@@ -461,9 +461,10 @@ export async function getCodeQlVersionsForOverlayBaseDatabases(
|
|||||||
);
|
);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const cacheKeyPrefix = await getCacheKeyPrefixBase(
|
const dedupedLanguages = [
|
||||||
languages.filter((l) => l !== undefined),
|
...new Set(languages.filter((l) => l !== undefined)),
|
||||||
);
|
];
|
||||||
|
const cacheKeyPrefix = await getCacheKeyPrefixBase(dedupedLanguages);
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`Searching for overlay-base databases in Actions cache with ` +
|
`Searching for overlay-base databases in Actions cache with ` +
|
||||||
|
|||||||
@@ -39,6 +39,15 @@ export enum OverlayDisabledReason {
|
|||||||
NotPullRequestOrDefaultBranch = "not-pull-request-or-default-branch",
|
NotPullRequestOrDefaultBranch = "not-pull-request-or-default-branch",
|
||||||
/** The top-level overlay analysis feature flag is not enabled. */
|
/** The top-level overlay analysis feature flag is not enabled. */
|
||||||
OverallFeatureNotEnabled = "overall-feature-not-enabled",
|
OverallFeatureNotEnabled = "overall-feature-not-enabled",
|
||||||
|
/**
|
||||||
|
* Overlay analysis was selected for a pull request, but diff-informed
|
||||||
|
* analysis was not enabled for the run (for example, because the
|
||||||
|
* `DiffInformedQueries` feature flag is off, the GHES version is too old,
|
||||||
|
* or the PR diff ranges could not be computed). Overlay analysis has only
|
||||||
|
* been validated in combination with diff-informed analysis, so we fall
|
||||||
|
* back to a non-overlay analysis in this case.
|
||||||
|
*/
|
||||||
|
DiffInformedAnalysisNotEnabled = "diff-informed-analysis-not-enabled",
|
||||||
/** Overlay analysis was skipped because it previously failed with similar hardware resources. */
|
/** Overlay analysis was skipped because it previously failed with similar hardware resources. */
|
||||||
SkippedDueToCachedStatus = "skipped-due-to-cached-status",
|
SkippedDueToCachedStatus = "skipped-due-to-cached-status",
|
||||||
/** Disk usage could not be determined during the overlay status check. */
|
/** Disk usage could not be determined during the overlay status check. */
|
||||||
|
|||||||
+16
-56
@@ -50,31 +50,21 @@ test.serial(
|
|||||||
"modified.js": "ddd444", // Changed OID
|
"modified.js": "ddd444", // Changed OID
|
||||||
"added.js": "eee555", // New file
|
"added.js": "eee555", // New file
|
||||||
};
|
};
|
||||||
const getFileOidsStubForOverlay = sinon
|
sinon.stub(gitUtils, "getFileOidsUnderPath").resolves(currentOids);
|
||||||
.stub(gitUtils, "getFileOidsUnderPath")
|
|
||||||
.resolves(currentOids);
|
|
||||||
|
|
||||||
// Write the overlay changes file, which uses the mocked overlay OIDs
|
// Write the overlay changes file, which uses the mocked overlay OIDs
|
||||||
// and the base database OIDs file
|
// and the base database OIDs file
|
||||||
const diffRangeFilePath = path.join(tempDir, "pr-diff-range.json");
|
const diffRangeFilePath = path.join(tempDir, "pr-diff-range.json");
|
||||||
const getTempDirStub = sinon
|
sinon.stub(actionsUtil, "getTemporaryDirectory").returns(tempDir);
|
||||||
.stub(actionsUtil, "getTemporaryDirectory")
|
sinon
|
||||||
.returns(tempDir);
|
|
||||||
const getDiffRangesStub = sinon
|
|
||||||
.stub(actionsUtil, "getDiffRangesJsonFilePath")
|
.stub(actionsUtil, "getDiffRangesJsonFilePath")
|
||||||
.returns(diffRangeFilePath);
|
.returns(diffRangeFilePath);
|
||||||
const getGitRootStub = sinon
|
sinon.stub(gitUtils, "getGitRoot").resolves(sourceRoot);
|
||||||
.stub(gitUtils, "getGitRoot")
|
|
||||||
.resolves(sourceRoot);
|
|
||||||
const changesFilePath = await writeOverlayChangesFile(
|
const changesFilePath = await writeOverlayChangesFile(
|
||||||
config,
|
config,
|
||||||
sourceRoot,
|
sourceRoot,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
getFileOidsStubForOverlay.restore();
|
|
||||||
getTempDirStub.restore();
|
|
||||||
getDiffRangesStub.restore();
|
|
||||||
getGitRootStub.restore();
|
|
||||||
|
|
||||||
const fileContent = await fs.promises.readFile(changesFilePath, "utf-8");
|
const fileContent = await fs.promises.readFile(changesFilePath, "utf-8");
|
||||||
const parsedContent = JSON.parse(fileContent) as { changes: string[] };
|
const parsedContent = JSON.parse(fileContent) as { changes: string[] };
|
||||||
@@ -128,20 +118,14 @@ test.serial(
|
|||||||
"modified.js": "ddd444", // Changed OID
|
"modified.js": "ddd444", // Changed OID
|
||||||
"reverted.js": "eee555", // Same OID as base -- not detected by OID comparison
|
"reverted.js": "eee555", // Same OID as base -- not detected by OID comparison
|
||||||
};
|
};
|
||||||
const getFileOidsStubForOverlay = sinon
|
sinon.stub(gitUtils, "getFileOidsUnderPath").resolves(currentOids);
|
||||||
.stub(gitUtils, "getFileOidsUnderPath")
|
|
||||||
.resolves(currentOids);
|
|
||||||
|
|
||||||
const diffRangeFilePath = path.join(tempDir, "pr-diff-range.json");
|
const diffRangeFilePath = path.join(tempDir, "pr-diff-range.json");
|
||||||
const getTempDirStub = sinon
|
sinon.stub(actionsUtil, "getTemporaryDirectory").returns(tempDir);
|
||||||
.stub(actionsUtil, "getTemporaryDirectory")
|
sinon
|
||||||
.returns(tempDir);
|
|
||||||
const getDiffRangesStub = sinon
|
|
||||||
.stub(actionsUtil, "getDiffRangesJsonFilePath")
|
.stub(actionsUtil, "getDiffRangesJsonFilePath")
|
||||||
.returns(diffRangeFilePath);
|
.returns(diffRangeFilePath);
|
||||||
const getGitRootStub = sinon
|
sinon.stub(gitUtils, "getGitRoot").resolves(sourceRoot);
|
||||||
.stub(gitUtils, "getGitRoot")
|
|
||||||
.resolves(sourceRoot);
|
|
||||||
|
|
||||||
// Write a pr-diff-range.json file with diff ranges including
|
// Write a pr-diff-range.json file with diff ranges including
|
||||||
// "reverted.js" (unchanged OIDs) and "modified.js" (already in OID changes)
|
// "reverted.js" (unchanged OIDs) and "modified.js" (already in OID changes)
|
||||||
@@ -159,10 +143,6 @@ test.serial(
|
|||||||
sourceRoot,
|
sourceRoot,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
getFileOidsStubForOverlay.restore();
|
|
||||||
getTempDirStub.restore();
|
|
||||||
getDiffRangesStub.restore();
|
|
||||||
getGitRootStub.restore();
|
|
||||||
|
|
||||||
const fileContent = await fs.promises.readFile(changesFilePath, "utf-8");
|
const fileContent = await fs.promises.readFile(changesFilePath, "utf-8");
|
||||||
const parsedContent = JSON.parse(fileContent) as { changes: string[] };
|
const parsedContent = JSON.parse(fileContent) as { changes: string[] };
|
||||||
@@ -208,20 +188,14 @@ test.serial(
|
|||||||
"unchanged.js": "aaa111",
|
"unchanged.js": "aaa111",
|
||||||
"modified.js": "ddd444",
|
"modified.js": "ddd444",
|
||||||
};
|
};
|
||||||
const getFileOidsStubForOverlay = sinon
|
sinon.stub(gitUtils, "getFileOidsUnderPath").resolves(currentOids);
|
||||||
.stub(gitUtils, "getFileOidsUnderPath")
|
|
||||||
.resolves(currentOids);
|
|
||||||
|
|
||||||
const diffRangeFilePath = path.join(tempDir, "pr-diff-range.json");
|
const diffRangeFilePath = path.join(tempDir, "pr-diff-range.json");
|
||||||
const getTempDirStub = sinon
|
sinon.stub(actionsUtil, "getTemporaryDirectory").returns(tempDir);
|
||||||
.stub(actionsUtil, "getTemporaryDirectory")
|
sinon
|
||||||
.returns(tempDir);
|
|
||||||
const getDiffRangesStub = sinon
|
|
||||||
.stub(actionsUtil, "getDiffRangesJsonFilePath")
|
.stub(actionsUtil, "getDiffRangesJsonFilePath")
|
||||||
.returns(diffRangeFilePath);
|
.returns(diffRangeFilePath);
|
||||||
const getGitRootStub = sinon
|
sinon.stub(gitUtils, "getGitRoot").resolves(sourceRoot);
|
||||||
.stub(gitUtils, "getGitRoot")
|
|
||||||
.resolves(sourceRoot);
|
|
||||||
|
|
||||||
// No pr-diff-range.json file exists - should work the same as before
|
// No pr-diff-range.json file exists - should work the same as before
|
||||||
const changesFilePath = await writeOverlayChangesFile(
|
const changesFilePath = await writeOverlayChangesFile(
|
||||||
@@ -229,10 +203,6 @@ test.serial(
|
|||||||
sourceRoot,
|
sourceRoot,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
getFileOidsStubForOverlay.restore();
|
|
||||||
getTempDirStub.restore();
|
|
||||||
getDiffRangesStub.restore();
|
|
||||||
getGitRootStub.restore();
|
|
||||||
|
|
||||||
const fileContent = await fs.promises.readFile(changesFilePath, "utf-8");
|
const fileContent = await fs.promises.readFile(changesFilePath, "utf-8");
|
||||||
const parsedContent = JSON.parse(fileContent) as { changes: string[] };
|
const parsedContent = JSON.parse(fileContent) as { changes: string[] };
|
||||||
@@ -281,21 +251,15 @@ test.serial(
|
|||||||
"app.js": "aaa111",
|
"app.js": "aaa111",
|
||||||
"lib/util.js": "bbb222",
|
"lib/util.js": "bbb222",
|
||||||
};
|
};
|
||||||
const getFileOidsStubForOverlay = sinon
|
sinon.stub(gitUtils, "getFileOidsUnderPath").resolves(currentOids);
|
||||||
.stub(gitUtils, "getFileOidsUnderPath")
|
|
||||||
.resolves(currentOids);
|
|
||||||
|
|
||||||
const diffRangeFilePath = path.join(tempDir, "pr-diff-range.json");
|
const diffRangeFilePath = path.join(tempDir, "pr-diff-range.json");
|
||||||
const getTempDirStub = sinon
|
sinon.stub(actionsUtil, "getTemporaryDirectory").returns(tempDir);
|
||||||
.stub(actionsUtil, "getTemporaryDirectory")
|
sinon
|
||||||
.returns(tempDir);
|
|
||||||
const getDiffRangesStub = sinon
|
|
||||||
.stub(actionsUtil, "getDiffRangesJsonFilePath")
|
.stub(actionsUtil, "getDiffRangesJsonFilePath")
|
||||||
.returns(diffRangeFilePath);
|
.returns(diffRangeFilePath);
|
||||||
// getGitRoot returns the repo root (parent of sourceRoot)
|
// getGitRoot returns the repo root (parent of sourceRoot)
|
||||||
const getGitRootStub = sinon
|
sinon.stub(gitUtils, "getGitRoot").resolves(repoRoot);
|
||||||
.stub(gitUtils, "getGitRoot")
|
|
||||||
.resolves(repoRoot);
|
|
||||||
|
|
||||||
// Diff ranges use repo-root-relative paths (as returned by the GitHub compare API)
|
// Diff ranges use repo-root-relative paths (as returned by the GitHub compare API)
|
||||||
await fs.promises.writeFile(
|
await fs.promises.writeFile(
|
||||||
@@ -312,10 +276,6 @@ test.serial(
|
|||||||
sourceRoot,
|
sourceRoot,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
getFileOidsStubForOverlay.restore();
|
|
||||||
getTempDirStub.restore();
|
|
||||||
getDiffRangesStub.restore();
|
|
||||||
getGitRootStub.restore();
|
|
||||||
|
|
||||||
const fileContent = await fs.promises.readFile(changesFilePath, "utf-8");
|
const fileContent = await fs.promises.readFile(changesFilePath, "utf-8");
|
||||||
const parsedContent = JSON.parse(fileContent) as { changes: string[] };
|
const parsedContent = JSON.parse(fileContent) as { changes: string[] };
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ async function run(startedAt: Date) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runWrapper() {
|
export async function runWrapper() {
|
||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
const logger = getActionsLogger();
|
const logger = getActionsLogger();
|
||||||
try {
|
try {
|
||||||
@@ -137,5 +137,3 @@ async function runWrapper() {
|
|||||||
}
|
}
|
||||||
await checkForTimeout();
|
await checkForTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void runWrapper();
|
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ import {
|
|||||||
getRequiredInput,
|
getRequiredInput,
|
||||||
getTemporaryDirectory,
|
getTemporaryDirectory,
|
||||||
} from "./actions-util";
|
} from "./actions-util";
|
||||||
|
import { AnalysisKind, getAnalysisKinds } from "./analyses";
|
||||||
import { getGitHubVersion } from "./api-client";
|
import { getGitHubVersion } from "./api-client";
|
||||||
import { CodeQL } from "./codeql";
|
import { CodeQL } from "./codeql";
|
||||||
|
import { getRawLanguagesNoAutodetect } from "./config-utils";
|
||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
import { initFeatures } from "./feature-flags";
|
import { initFeatures } from "./feature-flags";
|
||||||
import { initCodeQL } from "./init";
|
import { initCodeQL } from "./init";
|
||||||
@@ -136,16 +138,22 @@ async function run(startedAt: Date): Promise<void> {
|
|||||||
if (statusReportBase !== undefined) {
|
if (statusReportBase !== undefined) {
|
||||||
await sendStatusReport(statusReportBase);
|
await sendStatusReport(statusReportBase);
|
||||||
}
|
}
|
||||||
const codeQLDefaultVersionInfo = await features.getDefaultCliVersion(
|
const codeQLDefaultVersionInfo =
|
||||||
gitHubVersion.type,
|
await features.getEnabledDefaultCliVersions(gitHubVersion.type);
|
||||||
);
|
|
||||||
toolsFeatureFlagsValid = codeQLDefaultVersionInfo.toolsFeatureFlagsValid;
|
toolsFeatureFlagsValid = codeQLDefaultVersionInfo.toolsFeatureFlagsValid;
|
||||||
|
const rawLanguages = getRawLanguagesNoAutodetect(
|
||||||
|
getOptionalInput("languages"),
|
||||||
|
);
|
||||||
|
const analysisKinds = await getAnalysisKinds(logger, features);
|
||||||
const initCodeQLResult = await initCodeQL(
|
const initCodeQLResult = await initCodeQL(
|
||||||
getOptionalInput("tools"),
|
getOptionalInput("tools"),
|
||||||
apiDetails,
|
apiDetails,
|
||||||
getTemporaryDirectory(),
|
getTemporaryDirectory(),
|
||||||
gitHubVersion.type,
|
gitHubVersion.type,
|
||||||
codeQLDefaultVersionInfo,
|
codeQLDefaultVersionInfo,
|
||||||
|
rawLanguages,
|
||||||
|
analysisKinds.length === 1 &&
|
||||||
|
analysisKinds[0] === AnalysisKind.CodeScanning,
|
||||||
features,
|
features,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
@@ -188,7 +196,7 @@ async function run(startedAt: Date): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Run the action and catch any unhandled errors. */
|
/** Run the action and catch any unhandled errors. */
|
||||||
async function runWrapper(): Promise<void> {
|
export async function runWrapper(): Promise<void> {
|
||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
const logger = getActionsLogger();
|
const logger = getActionsLogger();
|
||||||
try {
|
try {
|
||||||
@@ -204,5 +212,3 @@ async function runWrapper(): Promise<void> {
|
|||||||
}
|
}
|
||||||
await checkForTimeout();
|
await checkForTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void runWrapper();
|
|
||||||
|
|||||||
+315
-18
@@ -7,8 +7,9 @@ import * as sinon from "sinon";
|
|||||||
|
|
||||||
import * as actionsUtil from "./actions-util";
|
import * as actionsUtil from "./actions-util";
|
||||||
import * as api from "./api-client";
|
import * as api from "./api-client";
|
||||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
import { Feature } from "./feature-flags";
|
||||||
import { getRunnerLogger } from "./logging";
|
import { getRunnerLogger } from "./logging";
|
||||||
|
import { getCacheRestoreKeyPrefix } from "./overlay/caching";
|
||||||
import * as setupCodeql from "./setup-codeql";
|
import * as setupCodeql from "./setup-codeql";
|
||||||
import * as tar from "./tar";
|
import * as tar from "./tar";
|
||||||
import {
|
import {
|
||||||
@@ -18,8 +19,9 @@ import {
|
|||||||
SAMPLE_DOTCOM_API_DETAILS,
|
SAMPLE_DOTCOM_API_DETAILS,
|
||||||
checkExpectedLogMessages,
|
checkExpectedLogMessages,
|
||||||
createFeatures,
|
createFeatures,
|
||||||
|
createTestConfig,
|
||||||
getRecordingLogger,
|
getRecordingLogger,
|
||||||
initializeFeatures,
|
makeMacro,
|
||||||
mockBundleDownloadApi,
|
mockBundleDownloadApi,
|
||||||
setupActionsVars,
|
setupActionsVars,
|
||||||
setupTests,
|
setupTests,
|
||||||
@@ -33,14 +35,6 @@ import {
|
|||||||
|
|
||||||
setupTests(test);
|
setupTests(test);
|
||||||
|
|
||||||
// TODO: Remove when when we no longer need to pass in features (https://github.com/github/codeql-action/issues/2600)
|
|
||||||
const expectedFeatureEnablement: FeatureEnablement = initializeFeatures(
|
|
||||||
true,
|
|
||||||
) as FeatureEnablement;
|
|
||||||
expectedFeatureEnablement.getValue = function (feature: Feature) {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
||||||
return expectedFeatureEnablement[feature];
|
|
||||||
};
|
|
||||||
test.beforeEach(() => {
|
test.beforeEach(() => {
|
||||||
initializeEnvironment("1.2.3");
|
initializeEnvironment("1.2.3");
|
||||||
});
|
});
|
||||||
@@ -107,6 +101,8 @@ test.serial(
|
|||||||
const source = await setupCodeql.getCodeQLSource(
|
const source = await setupCodeql.getCodeQLSource(
|
||||||
`https://github.com/github/codeql-action/releases/download/${tagName}/codeql-bundle-linux64.tar.gz`,
|
`https://github.com/github/codeql-action/releases/download/${tagName}/codeql-bundle-linux64.tar.gz`,
|
||||||
SAMPLE_DEFAULT_CLI_VERSION,
|
SAMPLE_DEFAULT_CLI_VERSION,
|
||||||
|
undefined, // rawLanguages
|
||||||
|
false, // useOverlayAwareDefaultCliVersion
|
||||||
SAMPLE_DOTCOM_API_DETAILS,
|
SAMPLE_DOTCOM_API_DETAILS,
|
||||||
GitHubVariant.DOTCOM,
|
GitHubVariant.DOTCOM,
|
||||||
false,
|
false,
|
||||||
@@ -130,6 +126,8 @@ test.serial(
|
|||||||
const source = await setupCodeql.getCodeQLSource(
|
const source = await setupCodeql.getCodeQLSource(
|
||||||
"linked",
|
"linked",
|
||||||
SAMPLE_DEFAULT_CLI_VERSION,
|
SAMPLE_DEFAULT_CLI_VERSION,
|
||||||
|
undefined, // rawLanguages
|
||||||
|
false, // useOverlayAwareDefaultCliVersion
|
||||||
SAMPLE_DOTCOM_API_DETAILS,
|
SAMPLE_DOTCOM_API_DETAILS,
|
||||||
GitHubVariant.DOTCOM,
|
GitHubVariant.DOTCOM,
|
||||||
false,
|
false,
|
||||||
@@ -155,6 +153,8 @@ test.serial(
|
|||||||
const source = await setupCodeql.getCodeQLSource(
|
const source = await setupCodeql.getCodeQLSource(
|
||||||
"latest",
|
"latest",
|
||||||
SAMPLE_DEFAULT_CLI_VERSION,
|
SAMPLE_DEFAULT_CLI_VERSION,
|
||||||
|
undefined, // rawLanguages
|
||||||
|
false, // useOverlayAwareDefaultCliVersion
|
||||||
SAMPLE_DOTCOM_API_DETAILS,
|
SAMPLE_DOTCOM_API_DETAILS,
|
||||||
GitHubVariant.DOTCOM,
|
GitHubVariant.DOTCOM,
|
||||||
false,
|
false,
|
||||||
@@ -211,6 +211,8 @@ test.serial(
|
|||||||
"tmp/codeql_action_test/",
|
"tmp/codeql_action_test/",
|
||||||
GitHubVariant.DOTCOM,
|
GitHubVariant.DOTCOM,
|
||||||
SAMPLE_DEFAULT_CLI_VERSION,
|
SAMPLE_DEFAULT_CLI_VERSION,
|
||||||
|
undefined, // rawLanguages
|
||||||
|
false, // useOverlayAwareDefaultCliVersion
|
||||||
features,
|
features,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
@@ -266,6 +268,8 @@ test.serial(
|
|||||||
"tmp/codeql_action_test/",
|
"tmp/codeql_action_test/",
|
||||||
GitHubVariant.DOTCOM,
|
GitHubVariant.DOTCOM,
|
||||||
SAMPLE_DEFAULT_CLI_VERSION,
|
SAMPLE_DEFAULT_CLI_VERSION,
|
||||||
|
undefined, // rawLanguages
|
||||||
|
false, // useOverlayAwareDefaultCliVersion
|
||||||
features,
|
features,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
@@ -317,6 +321,8 @@ test.serial(
|
|||||||
const source = await setupCodeql.getCodeQLSource(
|
const source = await setupCodeql.getCodeQLSource(
|
||||||
"nightly",
|
"nightly",
|
||||||
SAMPLE_DEFAULT_CLI_VERSION,
|
SAMPLE_DEFAULT_CLI_VERSION,
|
||||||
|
undefined, // rawLanguages
|
||||||
|
false, // useOverlayAwareDefaultCliVersion
|
||||||
SAMPLE_DOTCOM_API_DETAILS,
|
SAMPLE_DOTCOM_API_DETAILS,
|
||||||
GitHubVariant.DOTCOM,
|
GitHubVariant.DOTCOM,
|
||||||
false,
|
false,
|
||||||
@@ -378,6 +384,8 @@ test.serial(
|
|||||||
const source = await setupCodeql.getCodeQLSource(
|
const source = await setupCodeql.getCodeQLSource(
|
||||||
undefined,
|
undefined,
|
||||||
SAMPLE_DEFAULT_CLI_VERSION,
|
SAMPLE_DEFAULT_CLI_VERSION,
|
||||||
|
undefined, // rawLanguages
|
||||||
|
false, // useOverlayAwareDefaultCliVersion
|
||||||
SAMPLE_DOTCOM_API_DETAILS,
|
SAMPLE_DOTCOM_API_DETAILS,
|
||||||
GitHubVariant.DOTCOM,
|
GitHubVariant.DOTCOM,
|
||||||
false,
|
false,
|
||||||
@@ -432,6 +440,8 @@ test.serial(
|
|||||||
const source = await setupCodeql.getCodeQLSource(
|
const source = await setupCodeql.getCodeQLSource(
|
||||||
"toolcache",
|
"toolcache",
|
||||||
SAMPLE_DEFAULT_CLI_VERSION,
|
SAMPLE_DEFAULT_CLI_VERSION,
|
||||||
|
undefined, // rawLanguages
|
||||||
|
false, // useOverlayAwareDefaultCliVersion
|
||||||
SAMPLE_DOTCOM_API_DETAILS,
|
SAMPLE_DOTCOM_API_DETAILS,
|
||||||
GitHubVariant.DOTCOM,
|
GitHubVariant.DOTCOM,
|
||||||
false,
|
false,
|
||||||
@@ -473,7 +483,7 @@ test.serial(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const toolcacheInputFallbackMacro = test.macro({
|
const toolcacheInputFallbackMacro = makeMacro({
|
||||||
exec: async (
|
exec: async (
|
||||||
t: ExecutionContext<unknown>,
|
t: ExecutionContext<unknown>,
|
||||||
featureList: Feature[],
|
featureList: Feature[],
|
||||||
@@ -499,6 +509,8 @@ const toolcacheInputFallbackMacro = test.macro({
|
|||||||
const source = await setupCodeql.getCodeQLSource(
|
const source = await setupCodeql.getCodeQLSource(
|
||||||
"toolcache",
|
"toolcache",
|
||||||
SAMPLE_DEFAULT_CLI_VERSION,
|
SAMPLE_DEFAULT_CLI_VERSION,
|
||||||
|
undefined, // rawLanguages
|
||||||
|
false, // useOverlayAwareDefaultCliVersion
|
||||||
SAMPLE_DOTCOM_API_DETAILS,
|
SAMPLE_DOTCOM_API_DETAILS,
|
||||||
GitHubVariant.DOTCOM,
|
GitHubVariant.DOTCOM,
|
||||||
false,
|
false,
|
||||||
@@ -514,7 +526,10 @@ const toolcacheInputFallbackMacro = test.macro({
|
|||||||
|
|
||||||
// Check that `sourceType` and `toolsVersion` match expectations.
|
// Check that `sourceType` and `toolsVersion` match expectations.
|
||||||
t.is(source.sourceType, "download");
|
t.is(source.sourceType, "download");
|
||||||
t.is(source.toolsVersion, SAMPLE_DEFAULT_CLI_VERSION.cliVersion);
|
t.is(
|
||||||
|
source.toolsVersion,
|
||||||
|
SAMPLE_DEFAULT_CLI_VERSION.enabledVersions[0].cliVersion,
|
||||||
|
);
|
||||||
|
|
||||||
// Check that key messages we would expect to find in the log are present.
|
// Check that key messages we would expect to find in the log are present.
|
||||||
for (const expectedMessage of expectedMessages) {
|
for (const expectedMessage of expectedMessages) {
|
||||||
@@ -533,9 +548,8 @@ const toolcacheInputFallbackMacro = test.macro({
|
|||||||
`getCodeQLSource falls back to downloading the CLI if ${providedTitle}`,
|
`getCodeQLSource falls back to downloading the CLI if ${providedTitle}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
test.serial(
|
toolcacheInputFallbackMacro.serial(
|
||||||
"the toolcache doesn't have a CodeQL CLI when tools == toolcache",
|
"the toolcache doesn't have a CodeQL CLI when tools == toolcache",
|
||||||
toolcacheInputFallbackMacro,
|
|
||||||
[Feature.AllowToolcacheInput],
|
[Feature.AllowToolcacheInput],
|
||||||
{ GITHUB_EVENT_NAME: "dynamic" },
|
{ GITHUB_EVENT_NAME: "dynamic" },
|
||||||
[],
|
[],
|
||||||
@@ -545,9 +559,8 @@ test.serial(
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
toolcacheInputFallbackMacro.serial(
|
||||||
"the workflow trigger is not `dynamic`",
|
"the workflow trigger is not `dynamic`",
|
||||||
toolcacheInputFallbackMacro,
|
|
||||||
[Feature.AllowToolcacheInput],
|
[Feature.AllowToolcacheInput],
|
||||||
{ GITHUB_EVENT_NAME: "pull_request" },
|
{ GITHUB_EVENT_NAME: "pull_request" },
|
||||||
[],
|
[],
|
||||||
@@ -556,9 +569,8 @@ test.serial(
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
test.serial(
|
toolcacheInputFallbackMacro.serial(
|
||||||
"the feature flag is not enabled",
|
"the feature flag is not enabled",
|
||||||
toolcacheInputFallbackMacro,
|
|
||||||
[],
|
[],
|
||||||
{ GITHUB_EVENT_NAME: "dynamic" },
|
{ GITHUB_EVENT_NAME: "dynamic" },
|
||||||
[],
|
[],
|
||||||
@@ -598,3 +610,288 @@ test.serial(
|
|||||||
t.is(setupCodeql.getLatestToolcacheVersion(getRunnerLogger(true)), "3.2.1");
|
t.is(setupCodeql.getLatestToolcacheVersion(getRunnerLogger(true)), "3.2.1");
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const overlayMatchEnabledVersions = {
|
||||||
|
enabledVersions: [
|
||||||
|
{ cliVersion: "2.20.2", tagName: "codeql-bundle-v2.20.2" },
|
||||||
|
{ cliVersion: "2.20.1", tagName: "codeql-bundle-v2.20.1" },
|
||||||
|
{ cliVersion: "2.20.0", tagName: "codeql-bundle-v2.20.0" },
|
||||||
|
],
|
||||||
|
toolsFeatureFlagsValid: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
async function fakeOverlayBaseCacheKey(
|
||||||
|
language: string,
|
||||||
|
cliVersion: string,
|
||||||
|
suffix: string,
|
||||||
|
): Promise<string> {
|
||||||
|
const prefix = await getCacheRestoreKeyPrefix(
|
||||||
|
createTestConfig({ languages: [language] }),
|
||||||
|
cliVersion,
|
||||||
|
);
|
||||||
|
return `${prefix}${suffix}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"getCodeQLSource uses overlay-aware default version when requested for a PR",
|
||||||
|
async (t) => {
|
||||||
|
await withTmpDir(async (tmpDir) => {
|
||||||
|
setupActionsVars(tmpDir, tmpDir);
|
||||||
|
process.env["CODE_SCANNING_REF"] = "refs/heads/feature-branch";
|
||||||
|
process.env["CODE_SCANNING_BASE_BRANCH"] = "main";
|
||||||
|
|
||||||
|
sinon.stub(api, "getAutomationID").resolves("test/");
|
||||||
|
const listStub = sinon.stub(api, "listActionsCaches").resolves([
|
||||||
|
{
|
||||||
|
key: await fakeOverlayBaseCacheKey("javascript", "2.20.1", "abc-1-1"),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
sinon
|
||||||
|
.stub(toolcache, "find")
|
||||||
|
.withArgs("CodeQL", "2.20.1")
|
||||||
|
.returns("/path/to/codeql-2.20.1");
|
||||||
|
|
||||||
|
const source = await setupCodeql.getCodeQLSource(
|
||||||
|
undefined,
|
||||||
|
overlayMatchEnabledVersions,
|
||||||
|
["javascript"],
|
||||||
|
true,
|
||||||
|
SAMPLE_DOTCOM_API_DETAILS,
|
||||||
|
GitHubVariant.DOTCOM,
|
||||||
|
false,
|
||||||
|
createFeatures([Feature.OverlayAnalysisMatchCodeqlVersion]),
|
||||||
|
getRunnerLogger(true),
|
||||||
|
);
|
||||||
|
|
||||||
|
t.assert(listStub.calledOnce);
|
||||||
|
t.is(source.sourceType, "toolcache");
|
||||||
|
t.is(source.toolsVersion, "2.20.1");
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"getCodeQLSource skips overlay-aware default version when not requested",
|
||||||
|
async (t) => {
|
||||||
|
await withTmpDir(async (tmpDir) => {
|
||||||
|
setupActionsVars(tmpDir, tmpDir);
|
||||||
|
process.env["CODE_SCANNING_REF"] = "refs/heads/feature-branch";
|
||||||
|
process.env["CODE_SCANNING_BASE_BRANCH"] = "main";
|
||||||
|
|
||||||
|
sinon.stub(api, "getAutomationID").resolves("test/");
|
||||||
|
const listStub = sinon.stub(api, "listActionsCaches").resolves([
|
||||||
|
{
|
||||||
|
key: await fakeOverlayBaseCacheKey("javascript", "2.20.1", "abc-1-1"),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
sinon
|
||||||
|
.stub(toolcache, "find")
|
||||||
|
.withArgs("CodeQL", "2.20.2")
|
||||||
|
.returns("/path/to/codeql-2.20.2");
|
||||||
|
|
||||||
|
const source = await setupCodeql.getCodeQLSource(
|
||||||
|
undefined,
|
||||||
|
overlayMatchEnabledVersions,
|
||||||
|
["javascript"],
|
||||||
|
false,
|
||||||
|
SAMPLE_DOTCOM_API_DETAILS,
|
||||||
|
GitHubVariant.DOTCOM,
|
||||||
|
false,
|
||||||
|
createFeatures([Feature.OverlayAnalysisMatchCodeqlVersion]),
|
||||||
|
getRunnerLogger(true),
|
||||||
|
);
|
||||||
|
|
||||||
|
t.assert(listStub.notCalled);
|
||||||
|
t.is(source.sourceType, "toolcache");
|
||||||
|
t.is(source.toolsVersion, "2.20.2");
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"getEnabledVersionsWithOverlayBaseDatabases returns flag-enabled versions present in cache, sorted desc",
|
||||||
|
async (t) => {
|
||||||
|
sinon.stub(api, "getAutomationID").resolves("test/");
|
||||||
|
sinon.stub(api, "listActionsCaches").resolves([
|
||||||
|
// Flag-enabled versions present in the cache, listed in non-descending
|
||||||
|
// order so the test exercises the sort.
|
||||||
|
{
|
||||||
|
key: await fakeOverlayBaseCacheKey("javascript", "2.20.0", "ghi-3-1"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: await fakeOverlayBaseCacheKey("javascript", "2.20.1", "def-2-1"),
|
||||||
|
},
|
||||||
|
// Newer than any flag-enabled version: should be filtered out.
|
||||||
|
{
|
||||||
|
key: await fakeOverlayBaseCacheKey("javascript", "2.21.0", "abc-1-1"),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
const result = await setupCodeql.getEnabledVersionsWithOverlayBaseDatabases(
|
||||||
|
overlayMatchEnabledVersions,
|
||||||
|
["javascript"],
|
||||||
|
createFeatures([Feature.OverlayAnalysisMatchCodeqlVersion]),
|
||||||
|
getRunnerLogger(true),
|
||||||
|
);
|
||||||
|
t.deepEqual(result, [
|
||||||
|
{ cliVersion: "2.20.1", tagName: "codeql-bundle-v2.20.1" },
|
||||||
|
{ cliVersion: "2.20.0", tagName: "codeql-bundle-v2.20.0" },
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"getEnabledVersionsWithOverlayBaseDatabases returns empty when no cached version is flag-enabled",
|
||||||
|
async (t) => {
|
||||||
|
sinon.stub(api, "getAutomationID").resolves("test/");
|
||||||
|
sinon.stub(api, "listActionsCaches").resolves([
|
||||||
|
{
|
||||||
|
key: await fakeOverlayBaseCacheKey("javascript", "2.19.0", "abc-1-1"),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
const result = await setupCodeql.getEnabledVersionsWithOverlayBaseDatabases(
|
||||||
|
overlayMatchEnabledVersions,
|
||||||
|
["javascript"],
|
||||||
|
createFeatures([Feature.OverlayAnalysisMatchCodeqlVersion]),
|
||||||
|
getRunnerLogger(true),
|
||||||
|
);
|
||||||
|
t.deepEqual(result, []);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const noLanguagesMacro = makeMacro({
|
||||||
|
exec: async (
|
||||||
|
t: ExecutionContext<unknown>,
|
||||||
|
rawLanguages: string[] | undefined,
|
||||||
|
) => {
|
||||||
|
const listStub = sinon.stub(api, "listActionsCaches").resolves([]);
|
||||||
|
|
||||||
|
const result = await setupCodeql.getEnabledVersionsWithOverlayBaseDatabases(
|
||||||
|
overlayMatchEnabledVersions,
|
||||||
|
rawLanguages,
|
||||||
|
createFeatures([Feature.OverlayAnalysisMatchCodeqlVersion]),
|
||||||
|
getRunnerLogger(true),
|
||||||
|
);
|
||||||
|
t.deepEqual(result, []);
|
||||||
|
t.assert(
|
||||||
|
listStub.notCalled,
|
||||||
|
"Should not list Actions caches without any rawLanguages.",
|
||||||
|
);
|
||||||
|
},
|
||||||
|
title: (providedTitle = "") =>
|
||||||
|
`getEnabledVersionsWithOverlayBaseDatabases does not list caches when rawLanguages is ${providedTitle}`,
|
||||||
|
});
|
||||||
|
|
||||||
|
noLanguagesMacro.serial("undefined", undefined);
|
||||||
|
noLanguagesMacro.serial("an empty array", []);
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"getEnabledVersionsWithOverlayBaseDatabases returns empty when listing caches throws",
|
||||||
|
async (t) => {
|
||||||
|
sinon.stub(api, "getAutomationID").resolves("test/");
|
||||||
|
sinon.stub(api, "listActionsCaches").rejects(new Error("listing failed"));
|
||||||
|
|
||||||
|
const result = await setupCodeql.getEnabledVersionsWithOverlayBaseDatabases(
|
||||||
|
overlayMatchEnabledVersions,
|
||||||
|
["javascript"],
|
||||||
|
createFeatures([Feature.OverlayAnalysisMatchCodeqlVersion]),
|
||||||
|
getRunnerLogger(true),
|
||||||
|
);
|
||||||
|
t.deepEqual(result, []);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"getEnabledVersionsWithOverlayBaseDatabases returns versions present in the cache",
|
||||||
|
async (t) => {
|
||||||
|
sinon.stub(api, "getAutomationID").resolves("test/");
|
||||||
|
sinon.stub(api, "listActionsCaches").resolves([
|
||||||
|
{
|
||||||
|
key: await fakeOverlayBaseCacheKey("javascript", "2.20.2", "abc-1-1"),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
const result = await setupCodeql.getEnabledVersionsWithOverlayBaseDatabases(
|
||||||
|
overlayMatchEnabledVersions,
|
||||||
|
["javascript"],
|
||||||
|
createFeatures([Feature.OverlayAnalysisMatchCodeqlVersion]),
|
||||||
|
getRunnerLogger(true),
|
||||||
|
);
|
||||||
|
t.deepEqual(result, [
|
||||||
|
{ cliVersion: "2.20.2", tagName: "codeql-bundle-v2.20.2" },
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"getEnabledVersionsWithOverlayBaseDatabases does not list caches when both gates are off",
|
||||||
|
async (t) => {
|
||||||
|
const listStub = sinon.stub(api, "listActionsCaches").resolves([]);
|
||||||
|
|
||||||
|
const result = await setupCodeql.getEnabledVersionsWithOverlayBaseDatabases(
|
||||||
|
overlayMatchEnabledVersions,
|
||||||
|
["javascript"],
|
||||||
|
createFeatures([]),
|
||||||
|
getRunnerLogger(true),
|
||||||
|
);
|
||||||
|
t.deepEqual(result, []);
|
||||||
|
t.assert(
|
||||||
|
listStub.notCalled,
|
||||||
|
"Should not list Actions caches when both gating feature flags are off.",
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"getEnabledVersionsWithOverlayBaseDatabases dry-run returns empty but lists caches",
|
||||||
|
async (t) => {
|
||||||
|
sinon.stub(api, "getAutomationID").resolves("test/");
|
||||||
|
const listStub = sinon.stub(api, "listActionsCaches").resolves([
|
||||||
|
{
|
||||||
|
key: await fakeOverlayBaseCacheKey("javascript", "2.20.1", "abc-1-1"),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
const result = await setupCodeql.getEnabledVersionsWithOverlayBaseDatabases(
|
||||||
|
overlayMatchEnabledVersions,
|
||||||
|
["javascript"],
|
||||||
|
createFeatures([Feature.OverlayAnalysisMatchCodeqlVersionDryRun]),
|
||||||
|
getRunnerLogger(true),
|
||||||
|
);
|
||||||
|
t.deepEqual(
|
||||||
|
result,
|
||||||
|
[],
|
||||||
|
"Dry-run should return an empty list so the caller falls back.",
|
||||||
|
);
|
||||||
|
t.assert(
|
||||||
|
listStub.calledOnce,
|
||||||
|
"Dry-run should still list Actions caches to populate the diagnostic.",
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"getEnabledVersionsWithOverlayBaseDatabases match flag wins over dry-run",
|
||||||
|
async (t) => {
|
||||||
|
sinon.stub(api, "getAutomationID").resolves("test/");
|
||||||
|
sinon.stub(api, "listActionsCaches").resolves([
|
||||||
|
{
|
||||||
|
key: await fakeOverlayBaseCacheKey("javascript", "2.20.1", "abc-1-1"),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
const result = await setupCodeql.getEnabledVersionsWithOverlayBaseDatabases(
|
||||||
|
overlayMatchEnabledVersions,
|
||||||
|
["javascript"],
|
||||||
|
createFeatures([
|
||||||
|
Feature.OverlayAnalysisMatchCodeqlVersion,
|
||||||
|
Feature.OverlayAnalysisMatchCodeqlVersionDryRun,
|
||||||
|
]),
|
||||||
|
getRunnerLogger(true),
|
||||||
|
);
|
||||||
|
t.deepEqual(result, [
|
||||||
|
{ cliVersion: "2.20.1", tagName: "codeql-bundle-v2.20.1" },
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|||||||
+155
-7
@@ -7,17 +7,27 @@ import { default as deepEqual } from "fast-deep-equal";
|
|||||||
import * as semver from "semver";
|
import * as semver from "semver";
|
||||||
import { v4 as uuidV4 } from "uuid";
|
import { v4 as uuidV4 } from "uuid";
|
||||||
|
|
||||||
import { isDynamicWorkflow, isRunningLocalAction } from "./actions-util";
|
import {
|
||||||
|
isAnalyzingPullRequest,
|
||||||
|
isDynamicWorkflow,
|
||||||
|
isRunningLocalAction,
|
||||||
|
} from "./actions-util";
|
||||||
import * as api from "./api-client";
|
import * as api from "./api-client";
|
||||||
import * as defaults from "./defaults.json";
|
import * as defaults from "./defaults.json";
|
||||||
import { addNoLanguageDiagnostic, makeDiagnostic } from "./diagnostics";
|
import {
|
||||||
|
addNoLanguageDiagnostic,
|
||||||
|
makeDiagnostic,
|
||||||
|
makeTelemetryDiagnostic,
|
||||||
|
} from "./diagnostics";
|
||||||
import {
|
import {
|
||||||
CODEQL_VERSION_ZSTD_BUNDLE,
|
CODEQL_VERSION_ZSTD_BUNDLE,
|
||||||
CodeQLDefaultVersionInfo,
|
CodeQLDefaultVersionInfo,
|
||||||
|
CodeQLVersionInfo,
|
||||||
Feature,
|
Feature,
|
||||||
FeatureEnablement,
|
FeatureEnablement,
|
||||||
} from "./feature-flags";
|
} from "./feature-flags";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
|
import { getCodeQlVersionsForOverlayBaseDatabases } from "./overlay/caching";
|
||||||
import * as tar from "./tar";
|
import * as tar from "./tar";
|
||||||
import {
|
import {
|
||||||
downloadAndExtract,
|
downloadAndExtract,
|
||||||
@@ -264,12 +274,131 @@ async function findOverridingToolsInCache(
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the sorted set of enabled versions that have cached overlay-base databases for the
|
||||||
|
* given languages, or an empty list if neither the `OverlayAnalysisMatchCodeqlVersion` nor the
|
||||||
|
* `OverlayAnalysisMatchCodeqlVersionDryRun` feature flag is enabled. When only the dry-run flag
|
||||||
|
* is enabled, this performs the lookup and emits a telemetry diagnostic with the version that
|
||||||
|
* would have been chosen, but still returns an empty list so the caller falls back.
|
||||||
|
*/
|
||||||
|
export async function getEnabledVersionsWithOverlayBaseDatabases(
|
||||||
|
defaultCliVersion: CodeQLDefaultVersionInfo,
|
||||||
|
rawLanguages: string[] | undefined,
|
||||||
|
features: FeatureEnablement,
|
||||||
|
logger: Logger,
|
||||||
|
): Promise<CodeQLVersionInfo[]> {
|
||||||
|
if (rawLanguages === undefined || rawLanguages.length === 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
const isEnabled = await features.getValue(
|
||||||
|
Feature.OverlayAnalysisMatchCodeqlVersion,
|
||||||
|
);
|
||||||
|
const isDryRun =
|
||||||
|
!isEnabled &&
|
||||||
|
(await features.getValue(Feature.OverlayAnalysisMatchCodeqlVersionDryRun));
|
||||||
|
if (!isEnabled && !isDryRun) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
let cachedVersions: string[] | undefined;
|
||||||
|
try {
|
||||||
|
cachedVersions = await getCodeQlVersionsForOverlayBaseDatabases(
|
||||||
|
rawLanguages,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
logger.warning(
|
||||||
|
"Could not list overlay-base databases in the Actions cache while choosing a default " +
|
||||||
|
`CodeQL CLI version, falling back to the highest enabled version. Details: ${util.getErrorMessage(e)}`,
|
||||||
|
);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cachedVersions === undefined || cachedVersions.length === 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const cachedVersionsSet = new Set(cachedVersions);
|
||||||
|
const overlayVersions = defaultCliVersion.enabledVersions.filter((v) =>
|
||||||
|
cachedVersionsSet.has(v.cliVersion),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (overlayVersions.length === 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const isCachedVersionDifferent =
|
||||||
|
overlayVersions[0].cliVersion !==
|
||||||
|
defaultCliVersion.enabledVersions[0].cliVersion;
|
||||||
|
|
||||||
|
if (isCachedVersionDifferent) {
|
||||||
|
addNoLanguageDiagnostic(
|
||||||
|
undefined,
|
||||||
|
makeTelemetryDiagnostic(
|
||||||
|
"codeql-action/overlay-aware-default-codeql-version",
|
||||||
|
"Overlay-aware default CodeQL version selection",
|
||||||
|
{
|
||||||
|
cachedVersions,
|
||||||
|
enabledVersions: defaultCliVersion.enabledVersions.map(
|
||||||
|
(v) => v.cliVersion,
|
||||||
|
),
|
||||||
|
isDryRun,
|
||||||
|
overlayAwareVersion: overlayVersions[0].cliVersion,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isDryRun) {
|
||||||
|
logger.debug(
|
||||||
|
`Overlay-aware default CodeQL version selection is running in dry-run mode. Would have used version ${overlayVersions[0].cliVersion}.`,
|
||||||
|
);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return overlayVersions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolves the newest enabled default CLI version that has a cached overlay-base database for the
|
||||||
|
* relevant languages, if running a Code Scanning analysis for a pull request and one exists.
|
||||||
|
* Otherwise, falls back to the newest enabled default CLI version.
|
||||||
|
*/
|
||||||
|
async function resolveDefaultCliVersion(
|
||||||
|
defaultCliVersion: CodeQLDefaultVersionInfo,
|
||||||
|
rawLanguages: string[] | undefined,
|
||||||
|
useOverlayAwareDefaultCliVersion: boolean,
|
||||||
|
features: FeatureEnablement,
|
||||||
|
logger: Logger,
|
||||||
|
): Promise<CodeQLVersionInfo> {
|
||||||
|
if (!useOverlayAwareDefaultCliVersion || !isAnalyzingPullRequest()) {
|
||||||
|
return defaultCliVersion.enabledVersions[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
const overlayVersions = await getEnabledVersionsWithOverlayBaseDatabases(
|
||||||
|
defaultCliVersion,
|
||||||
|
rawLanguages,
|
||||||
|
features,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
if (overlayVersions.length > 0) {
|
||||||
|
logger.info(
|
||||||
|
`Using CodeQL version ${overlayVersions[0].cliVersion} since this is the ` +
|
||||||
|
`highest enabled version that has a cached overlay-base database.`,
|
||||||
|
);
|
||||||
|
return overlayVersions[0];
|
||||||
|
}
|
||||||
|
return defaultCliVersion.enabledVersions[0];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines where the CodeQL CLI we want to use comes from. This can be from a local file,
|
* Determines where the CodeQL CLI we want to use comes from. This can be from a local file,
|
||||||
* the Actions toolcache, or a download.
|
* the Actions toolcache, or a download.
|
||||||
*
|
*
|
||||||
* @param toolsInput The argument provided for the `tools` input, if any.
|
* @param toolsInput The argument provided for the `tools` input, if any.
|
||||||
* @param defaultCliVersion The default CLI version that's linked to the CodeQL Action.
|
* @param defaultCliVersion The default CLI version that's linked to the CodeQL Action.
|
||||||
|
* @param rawLanguages Raw set of languages.
|
||||||
|
* @param useOverlayAwareDefaultCliVersion Whether to select an overlay-aware default CLI version.
|
||||||
* @param apiDetails Information about the GitHub API.
|
* @param apiDetails Information about the GitHub API.
|
||||||
* @param variant The GitHub variant we are running on.
|
* @param variant The GitHub variant we are running on.
|
||||||
* @param tarSupportsZstd Whether zstd is supported by `tar`.
|
* @param tarSupportsZstd Whether zstd is supported by `tar`.
|
||||||
@@ -281,6 +410,8 @@ async function findOverridingToolsInCache(
|
|||||||
export async function getCodeQLSource(
|
export async function getCodeQLSource(
|
||||||
toolsInput: string | undefined,
|
toolsInput: string | undefined,
|
||||||
defaultCliVersion: CodeQLDefaultVersionInfo,
|
defaultCliVersion: CodeQLDefaultVersionInfo,
|
||||||
|
rawLanguages: string[] | undefined,
|
||||||
|
useOverlayAwareDefaultCliVersion: boolean,
|
||||||
apiDetails: api.GitHubApiDetails,
|
apiDetails: api.GitHubApiDetails,
|
||||||
variant: util.GitHubVariant,
|
variant: util.GitHubVariant,
|
||||||
tarSupportsZstd: boolean,
|
tarSupportsZstd: boolean,
|
||||||
@@ -438,8 +569,15 @@ export async function getCodeQLSource(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cliVersion = defaultCliVersion.cliVersion;
|
const version = await resolveDefaultCliVersion(
|
||||||
tagName = defaultCliVersion.tagName;
|
defaultCliVersion,
|
||||||
|
rawLanguages,
|
||||||
|
useOverlayAwareDefaultCliVersion,
|
||||||
|
features,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
cliVersion = version.cliVersion;
|
||||||
|
tagName = version.tagName;
|
||||||
}
|
}
|
||||||
} else if (toolsInput !== undefined) {
|
} else if (toolsInput !== undefined) {
|
||||||
// If a tools URL was provided, then use that.
|
// If a tools URL was provided, then use that.
|
||||||
@@ -454,9 +592,15 @@ export async function getCodeQLSource(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, use the default CLI version passed in.
|
const version = await resolveDefaultCliVersion(
|
||||||
cliVersion = defaultCliVersion.cliVersion;
|
defaultCliVersion,
|
||||||
tagName = defaultCliVersion.tagName;
|
rawLanguages,
|
||||||
|
useOverlayAwareDefaultCliVersion,
|
||||||
|
features,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
cliVersion = version.cliVersion;
|
||||||
|
tagName = version.tagName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bundleVersion =
|
const bundleVersion =
|
||||||
@@ -791,6 +935,8 @@ export async function setupCodeQLBundle(
|
|||||||
tempDir: string,
|
tempDir: string,
|
||||||
variant: util.GitHubVariant,
|
variant: util.GitHubVariant,
|
||||||
defaultCliVersion: CodeQLDefaultVersionInfo,
|
defaultCliVersion: CodeQLDefaultVersionInfo,
|
||||||
|
rawLanguages: string[] | undefined,
|
||||||
|
useOverlayAwareDefaultCliVersion: boolean,
|
||||||
features: FeatureEnablement,
|
features: FeatureEnablement,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
): Promise<SetupCodeQLResult> {
|
): Promise<SetupCodeQLResult> {
|
||||||
@@ -804,6 +950,8 @@ export async function setupCodeQLBundle(
|
|||||||
const source = await getCodeQLSource(
|
const source = await getCodeQLSource(
|
||||||
toolsInput,
|
toolsInput,
|
||||||
defaultCliVersion,
|
defaultCliVersion,
|
||||||
|
rawLanguages,
|
||||||
|
useOverlayAwareDefaultCliVersion,
|
||||||
apiDetails,
|
apiDetails,
|
||||||
variant,
|
variant,
|
||||||
zstdAvailability.available,
|
zstdAvailability.available,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { uploadArtifacts } from "./debug-artifacts";
|
|||||||
import { getActionsLogger } from "./logging";
|
import { getActionsLogger } from "./logging";
|
||||||
import { checkGitHubVersionInRange, getErrorMessage } from "./util";
|
import { checkGitHubVersionInRange, getErrorMessage } from "./util";
|
||||||
|
|
||||||
async function runWrapper() {
|
export async function runWrapper() {
|
||||||
// To capture errors appropriately, keep as much code within the try-catch as
|
// To capture errors appropriately, keep as much code within the try-catch as
|
||||||
// possible, and only use safe functions outside.
|
// possible, and only use safe functions outside.
|
||||||
|
|
||||||
@@ -62,5 +62,3 @@ async function runWrapper() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void runWrapper();
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user