mirror of
https://github.com/github/codeql-action.git
synced 2026-05-22 22:08:56 +00:00
Merge pull request #3929 from github/backport-v3.36.0-7211b7c80
Merge releases/v4 into releases/v3
This commit is contained in:
@@ -41,7 +41,38 @@ runs:
|
||||
git add .
|
||||
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
|
||||
shell: bash
|
||||
@@ -60,8 +91,6 @@ runs:
|
||||
|
||||
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.
|
||||
- [ ] 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".
|
||||
@@ -74,7 +103,6 @@ runs:
|
||||
--head "${NEW_BRANCH}" \
|
||||
--base "${BASE_BRANCH}" \
|
||||
--title "${pr_title}" \
|
||||
--label "Rebuild" \
|
||||
--body "${pr_body}" \
|
||||
--assignee "${GITHUB_ACTOR}" \
|
||||
--draft
|
||||
|
||||
@@ -18,7 +18,7 @@ runs:
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 20
|
||||
node-version: 24
|
||||
cache: 'npm'
|
||||
|
||||
- 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.
|
||||
# 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'
|
||||
|
||||
# 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
|
||||
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.
|
||||
# Raises an error if git does not exit successfully (unless passed
|
||||
# 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")}.')
|
||||
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
|
||||
def branch_exists_on_remote(branch_name):
|
||||
return run_git('ls-remote', '--heads', ORIGIN, branch_name).strip() != ''
|
||||
@@ -87,9 +124,11 @@ def open_pr(
|
||||
body.append('Please do the following:')
|
||||
if len(conflicted_files) > 0:
|
||||
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:')
|
||||
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 ' +
|
||||
'branch to resolve the merge conflicts.')
|
||||
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(' - [ ] 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(' - [ ] 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.')
|
||||
|
||||
title = f'Merge {source_branch} into {target_branch}'
|
||||
labels = ['Rebuild'] if not is_primary_release else []
|
||||
|
||||
# Create the pull request
|
||||
# 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.
|
||||
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)}')
|
||||
|
||||
# Assign the conductor
|
||||
@@ -270,12 +303,6 @@ def update_changelog(version):
|
||||
def main():
|
||||
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(
|
||||
'--repository-nwo',
|
||||
type=str,
|
||||
@@ -313,7 +340,7 @@ def main():
|
||||
target_branch = args.target_branch
|
||||
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
|
||||
target_branch_major_version = target_branch.strip('releases/v')
|
||||
@@ -380,8 +407,9 @@ def main():
|
||||
# releases.
|
||||
run_git('revert', vOlder_update_commits[0], '--no-edit')
|
||||
|
||||
# Also revert the "Rebuild" commit created by Actions.
|
||||
rebuild_commit = run_git('log', '--grep', '^Rebuild$', '--format=%H').split()[0]
|
||||
# Also revert the "Rebuild" commit, whether created by this script or by the
|
||||
# `Rebuild Action` workflow.
|
||||
rebuild_commit = run_git('log', '--grep', f'^{REBUILD_COMMIT_MESSAGE}$', '--format=%H').split()[0]
|
||||
print(f' Reverting {rebuild_commit}')
|
||||
run_git('revert', rebuild_commit, '--no-edit')
|
||||
|
||||
@@ -396,9 +424,10 @@ def main():
|
||||
run_git('add', '.')
|
||||
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')
|
||||
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')
|
||||
|
||||
# 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('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)
|
||||
|
||||
# Open a PR to update the branch
|
||||
|
||||
+4
-4
@@ -49,10 +49,6 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.17.6
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.18.4
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.19.4
|
||||
- os: ubuntu-latest
|
||||
@@ -61,6 +57,10 @@ jobs:
|
||||
version: stable-v2.21.4
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.22.4
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.23.9
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.24.3
|
||||
- os: ubuntu-latest
|
||||
version: default
|
||||
- os: ubuntu-latest
|
||||
|
||||
+4
-4
@@ -49,10 +49,6 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.17.6
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.18.4
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.19.4
|
||||
- os: ubuntu-latest
|
||||
@@ -61,6 +57,10 @@ jobs:
|
||||
version: stable-v2.21.4
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.22.4
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.23.9
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.24.3
|
||||
- os: ubuntu-latest
|
||||
version: default
|
||||
- os: ubuntu-latest
|
||||
|
||||
+4
-4
@@ -49,10 +49,6 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.17.6
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.18.4
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.19.4
|
||||
- os: ubuntu-latest
|
||||
@@ -61,6 +57,10 @@ jobs:
|
||||
version: stable-v2.21.4
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.22.4
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.23.9
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.24.3
|
||||
- os: ubuntu-latest
|
||||
version: default
|
||||
- os: ubuntu-latest
|
||||
|
||||
+15
-15
@@ -59,41 +59,41 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
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
|
||||
version: stable-v2.19.4
|
||||
- os: macos-latest
|
||||
- os: macos-latest-xlarge
|
||||
version: stable-v2.19.4
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.20.7
|
||||
- os: macos-latest
|
||||
- os: macos-latest-xlarge
|
||||
version: stable-v2.20.7
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.21.4
|
||||
- os: macos-latest
|
||||
- os: macos-latest-xlarge
|
||||
version: stable-v2.21.4
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.22.4
|
||||
- os: macos-latest
|
||||
- os: macos-latest-xlarge
|
||||
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
|
||||
version: default
|
||||
- os: macos-latest
|
||||
- os: macos-latest-xlarge
|
||||
version: default
|
||||
- os: ubuntu-latest
|
||||
version: linked
|
||||
- os: macos-latest
|
||||
- os: macos-latest-xlarge
|
||||
version: linked
|
||||
- os: ubuntu-latest
|
||||
version: nightly-latest
|
||||
- os: macos-latest
|
||||
- os: macos-latest-xlarge
|
||||
version: nightly-latest
|
||||
name: Multi-language repository
|
||||
if: github.triggering_actor != 'dependabot[bot]'
|
||||
|
||||
Generated
+1
-1
@@ -40,7 +40,7 @@ jobs:
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.19.3
|
||||
version: stable-v2.19.4
|
||||
- os: ubuntu-latest
|
||||
version: stable-v2.22.1
|
||||
- os: ubuntu-latest
|
||||
|
||||
Generated
+1
-1
@@ -39,7 +39,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: macos-latest
|
||||
- os: macos-latest-xlarge
|
||||
version: nightly-latest
|
||||
name: Swift analysis using autobuild
|
||||
if: github.triggering_actor != 'dependabot[bot]'
|
||||
|
||||
@@ -9,6 +9,10 @@ on:
|
||||
# by other workflows.
|
||||
types: [opened, synchronize, reopened, ready_for_review]
|
||||
|
||||
concurrency:
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' || false }}
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
@@ -77,7 +77,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
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) }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
|
||||
@@ -24,6 +24,10 @@ on:
|
||||
- cron: '0 5 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' || false }}
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
@@ -20,6 +20,10 @@ on:
|
||||
- cron: '0 5 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' || false }}
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
@@ -19,6 +19,10 @@ on:
|
||||
- cron: '0 5 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' || false }}
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
@@ -48,6 +48,9 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0 # ensure we have all tags and can push commits
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 24
|
||||
cache: 'npm'
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
+116
-32
@@ -10,6 +10,10 @@ on:
|
||||
types: [checks_requested]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' || false }}
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
@@ -29,6 +33,10 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 45
|
||||
|
||||
concurrency:
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' || false }}
|
||||
group: pr-checks-unit-tests-${{ github.ref }}-${{ github.event_name }}-${{ matrix.os }}-node${{ matrix['node-version'] }}
|
||||
|
||||
steps:
|
||||
- name: Prepare git (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
@@ -67,22 +75,21 @@ jobs:
|
||||
sarif_file: eslint.sarif
|
||||
category: eslint
|
||||
|
||||
# Verifying the PR checks are up-to-date requires Node 24. The PR checks are not dependent
|
||||
# on the main codebase and therefore do not need to be run as part of the same matrix that
|
||||
# we use for the `unit-tests` job.
|
||||
verify-pr-checks:
|
||||
name: Verify PR checks
|
||||
# These checks do not need to be run as part of the same matrix that we use for the `unit-tests`
|
||||
# job.
|
||||
other-checks:
|
||||
name: Other checks
|
||||
if: github.triggering_actor != 'dependabot[bot]'
|
||||
permissions:
|
||||
contents: read
|
||||
runs-on: ubuntu-slim
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
steps:
|
||||
- name: Prepare git (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
run: git config --global core.autocrlf false
|
||||
concurrency:
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' || false }}
|
||||
group: pr-checks-pr-checks-${{ github.ref }}-${{ github.event_name }}
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
|
||||
@@ -93,34 +100,22 @@ jobs:
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
id: install-deps
|
||||
run: npm ci
|
||||
|
||||
- name: Verify PR checks up to date
|
||||
if: always()
|
||||
if: ${{ !cancelled() && steps.install-deps.outcome == 'success' }}
|
||||
run: .github/workflows/script/verify-pr-checks.sh
|
||||
|
||||
- name: Run pr-checks tests
|
||||
if: always()
|
||||
if: ${{ !cancelled() && steps.install-deps.outcome == 'success' }}
|
||||
working-directory: pr-checks
|
||||
run: npx tsx --test
|
||||
|
||||
check-node-version:
|
||||
if: github.triggering_actor != 'dependabot[bot]'
|
||||
name: Check Action Node versions
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
env:
|
||||
BASE_REF: ${{ github.base_ref }}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- id: head-version
|
||||
name: Verify all Actions use the same Node version
|
||||
- name: Verify all Actions use the same Node version
|
||||
id: head-version
|
||||
run: |
|
||||
NODE_VERSION=$(find . -name "action.yml" -exec yq -e '.runs.using' {} \; | grep node | sort | uniq)
|
||||
NODE_VERSION=$(find . -path "*/node_modules" -prune -o -name "action.yml" -exec yq -o=json '.runs.using' {} \; | jq -rs '[.[] | select(. != null and startswith("node"))] | unique | .[]')
|
||||
echo "NODE_VERSION: ${NODE_VERSION}"
|
||||
if [[ $(echo "$NODE_VERSION" | wc -l) -gt 1 ]]; then
|
||||
echo "::error::More than one node version used in 'action.yml' files."
|
||||
@@ -128,22 +123,111 @@ jobs:
|
||||
fi
|
||||
echo "node_version=${NODE_VERSION}" >> $GITHUB_OUTPUT
|
||||
|
||||
- id: checkout-base
|
||||
name: 'Backport: Check out base ref'
|
||||
- name: Fetch base commit
|
||||
id: fetch-base
|
||||
# Forks and Dependabot PRs don't have permission to write comments, so skip the repo size
|
||||
# check in those cases.
|
||||
if: >-
|
||||
github.event_name == 'pull_request' &&
|
||||
github.event.pull_request.head.repo.full_name == github.repository &&
|
||||
github.event.pull_request.user.login != 'dependabot[bot]'
|
||||
env:
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
# Compare against the merge base so the size delta reflects only the commits actually
|
||||
# added by this PR, ignoring any changes that have landed on the base branch since the
|
||||
# PR branched off.
|
||||
merge_base=$(gh api "repos/$GITHUB_REPOSITORY/compare/$BASE_SHA...$HEAD_SHA" --jq '.merge_base_commit.sha')
|
||||
echo "merge_base=$merge_base" >> "$GITHUB_OUTPUT"
|
||||
git fetch --no-tags --depth=1 origin "$merge_base" "$HEAD_SHA"
|
||||
|
||||
- name: Check repo size
|
||||
if: steps.fetch-base.outcome == 'success'
|
||||
working-directory: pr-checks
|
||||
env:
|
||||
BASE_REF: ${{ github.event.pull_request.base.ref }}
|
||||
BASE_SHA: ${{ steps.fetch-base.outputs.merge_base }}
|
||||
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
run: npx tsx check-repo-size.ts --output-dir "$RUNNER_TEMP/repo-size"
|
||||
|
||||
- name: Upload repo size comment
|
||||
if: steps.fetch-base.outcome == 'success'
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: repo-size-comment
|
||||
path: ${{ runner.temp }}/repo-size/
|
||||
if-no-files-found: error
|
||||
|
||||
- name: 'Backport: Check out base ref'
|
||||
id: checkout-base
|
||||
if: ${{ startsWith(github.head_ref, 'backport-') }}
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ env.BASE_REF }}
|
||||
ref: ${{ github.base_ref }}
|
||||
|
||||
- name: 'Backport: Verify Node versions unchanged'
|
||||
if: steps.checkout-base.outcome == 'success'
|
||||
env:
|
||||
HEAD_VERSION: ${{ steps.head-version.outputs.node_version }}
|
||||
run: |
|
||||
BASE_VERSION=$(find . -name "action.yml" -exec yq -e '.runs.using' {} \; | grep node | sort | uniq)
|
||||
BASE_VERSION=$(find . -path "*/node_modules" -prune -o -name "action.yml" -exec yq -o=json '.runs.using' {} \; | jq -rs '[.[] | select(. != null and startswith("node"))] | unique | .[]')
|
||||
echo "HEAD_VERSION: ${HEAD_VERSION}"
|
||||
echo "BASE_VERSION: ${BASE_VERSION}"
|
||||
if [[ "$BASE_VERSION" != "$HEAD_VERSION" ]]; then
|
||||
echo "::error::Cannot change the Node version of an Action in a backport PR."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
post-repo-size-comment:
|
||||
name: Post repo size comment
|
||||
needs: other-checks
|
||||
# Keep write permissions isolated from the job that checks out and tests PR code. This job only
|
||||
# posts the candidate comment body produced by the read-only `pr-checks` job.
|
||||
if: >-
|
||||
github.event_name == 'pull_request' &&
|
||||
github.event.pull_request.head.repo.full_name == github.repository &&
|
||||
github.event.pull_request.user.login != 'dependabot[bot]' &&
|
||||
needs.other-checks.result == 'success'
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
runs-on: ubuntu-slim
|
||||
timeout-minutes: 10
|
||||
|
||||
concurrency:
|
||||
cancel-in-progress: true
|
||||
group: check-repo-size-${{ github.event.pull_request.number }}
|
||||
|
||||
steps:
|
||||
- name: Download repo size comment
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: repo-size-comment
|
||||
path: repo-size-comment
|
||||
|
||||
- name: Post repo size comment
|
||||
env:
|
||||
COMMENT_MARKER: "<!-- repo-size-diff-bot -->"
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
run: |
|
||||
significant=$(jq -r '.significant' repo-size-comment/metadata.json)
|
||||
comment_id=$(
|
||||
gh api "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \
|
||||
--paginate \
|
||||
--jq ".[] | select(.body | contains(\"$COMMENT_MARKER\")) | .id" \
|
||||
| head -n 1
|
||||
)
|
||||
|
||||
if [[ -n "$comment_id" ]]; then
|
||||
echo "Updating existing comment $comment_id."
|
||||
gh api --method PATCH "repos/$GITHUB_REPOSITORY/issues/comments/$comment_id" --field body=@repo-size-comment/body.md
|
||||
elif [[ "$significant" == "true" ]]; then
|
||||
echo "Creating new repo size comment."
|
||||
gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" --field body=@repo-size-comment/body.md
|
||||
else
|
||||
echo "Skipping repo size comment because the delta is below the threshold and no sticky comment exists."
|
||||
fi
|
||||
|
||||
@@ -14,6 +14,10 @@ on:
|
||||
- cron: '0 0 * * 1'
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' || false }}
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
@@ -17,6 +17,10 @@ on:
|
||||
- cron: '0 5 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' || false }}
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
@@ -18,6 +18,11 @@ on:
|
||||
schedule:
|
||||
- cron: '0 5 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' || false }}
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
@@ -64,11 +64,12 @@ jobs:
|
||||
|
||||
- name: Update current release branch
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
echo SOURCE_BRANCH=${REF_NAME}
|
||||
echo TARGET_BRANCH=releases/${MAJOR_VERSION}
|
||||
python .github/update-release-branch.py \
|
||||
--github-token ${{ secrets.GITHUB_TOKEN }} \
|
||||
--repository-nwo ${{ github.repository }} \
|
||||
--source-branch '${{ env.REF_NAME }}' \
|
||||
--target-branch 'releases/${{ env.MAJOR_VERSION }}' \
|
||||
@@ -107,11 +108,12 @@ jobs:
|
||||
- uses: ./.github/actions/release-initialise
|
||||
|
||||
- name: Update older release branch
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
echo SOURCE_BRANCH=${SOURCE_BRANCH}
|
||||
echo TARGET_BRANCH=${TARGET_BRANCH}
|
||||
python .github/update-release-branch.py \
|
||||
--github-token ${{ secrets.GITHUB_TOKEN }} \
|
||||
--repository-nwo ${{ github.repository }} \
|
||||
--source-branch ${SOURCE_BRANCH} \
|
||||
--target-branch ${TARGET_BRANCH} \
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
See the [releases page](https://github.com/github/codeql-action/releases) for the relevant changes to the CodeQL CLI and language packs.
|
||||
|
||||
## 3.36.0 - 22 May 2026
|
||||
|
||||
- _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)
|
||||
- Update default CodeQL bundle version to [2.25.5](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.25.5). [#3926](https://github.com/github/codeql-action/pull/3926)
|
||||
|
||||
## 3.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)
|
||||
|
||||
+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:
|
||||
|
||||
- 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.
|
||||
- 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.
|
||||
|
||||
@@ -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.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.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).
|
||||
|
||||
|
||||
@@ -65,12 +65,22 @@ 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 identifies files,
|
||||
* and re-exports their `runWrapper` functions with suitable aliases.
|
||||
* A tiny stub file is emitted for each Action entrypoint. Each stub imports the shared bundle
|
||||
* and calls the respective entry point.
|
||||
* 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}
|
||||
*/
|
||||
@@ -83,7 +93,7 @@ const entryPointsPlugin = {
|
||||
const toPascal = (s) =>
|
||||
s.replace(/(^|-)([a-z0-9])/gi, (_, __, c) => c.toUpperCase());
|
||||
|
||||
// Find the source files containing action entry points.
|
||||
// Find the source files containing Action entry points.
|
||||
build.onStart(() => {
|
||||
const actionFiles = globSync("src/*-action{,-post}.ts");
|
||||
for (const actionFile of actionFiles) {
|
||||
@@ -112,7 +122,7 @@ const entryPointsPlugin = {
|
||||
return { path: SHARED_ENTRYPOINT, namespace };
|
||||
});
|
||||
|
||||
// Generate the virtual `entry-points` file based on the actions we discovered.
|
||||
// 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";
|
||||
@@ -127,7 +137,7 @@ const entryPointsPlugin = {
|
||||
const imports = actionsSorted
|
||||
.map(
|
||||
(action) =>
|
||||
`import * as ${action.pascalCaseName} from "./src/${basename(action.path)}"`,
|
||||
`import * as ${action.pascalCaseName} from "./src/${basename(action.path)}";`,
|
||||
)
|
||||
.join("\n");
|
||||
const wrappers = actionsSorted
|
||||
@@ -136,43 +146,63 @@ const entryPointsPlugin = {
|
||||
)
|
||||
.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${wrappers}\n`,
|
||||
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 (result) => {
|
||||
// Read the entry point template.
|
||||
const templatePath = "action-entry.js.tpl";
|
||||
const template = await readFile(join(SRC_DIR, templatePath), "utf-8");
|
||||
|
||||
const makeHeader = (sourceFile) =>
|
||||
// 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`;
|
||||
|
||||
// Write entry point stubs for each action.
|
||||
// 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(action.path) +
|
||||
template.replaceAll("__ACTION__", action.pascalCaseName),
|
||||
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({
|
||||
// Include upload-lib.ts as an entry point for use in testing environments.
|
||||
entryPoints: [
|
||||
{ in: SHARED_ENTRYPOINT, out: SHARED_ENTRYPOINT },
|
||||
join(SRC_DIR, "upload-lib.ts"),
|
||||
],
|
||||
entryPoints: [{ in: SHARED_ENTRYPOINT, out: SHARED_ENTRYPOINT }],
|
||||
bundle: true,
|
||||
format: "cjs",
|
||||
outdir: OUT_DIR,
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"bundleVersion": "codeql-bundle-v2.25.4",
|
||||
"cliVersion": "2.25.4",
|
||||
"priorBundleVersion": "codeql-bundle-v2.25.3",
|
||||
"priorCliVersion": "2.25.3"
|
||||
"bundleVersion": "codeql-bundle-v2.25.5",
|
||||
"cliVersion": "2.25.5",
|
||||
"priorBundleVersion": "codeql-bundle-v2.25.4",
|
||||
"priorCliVersion": "2.25.4"
|
||||
}
|
||||
|
||||
Generated
+72
-30
@@ -31025,13 +31025,15 @@ var require_brace_expansion = __commonJS({
|
||||
parts.push.apply(parts, p);
|
||||
return parts;
|
||||
}
|
||||
function expandTop(str2) {
|
||||
function expandTop(str2, options) {
|
||||
if (!str2)
|
||||
return [];
|
||||
options = options || {};
|
||||
var max = options.max == null ? Infinity : options.max;
|
||||
if (str2.substr(0, 2) === "{}") {
|
||||
str2 = "\\{\\}" + str2.substr(2);
|
||||
}
|
||||
return expand2(escapeBraces(str2), true).map(unescapeBraces);
|
||||
return expand2(escapeBraces(str2), max, true).map(unescapeBraces);
|
||||
}
|
||||
function embrace(str2) {
|
||||
return "{" + str2 + "}";
|
||||
@@ -31045,7 +31047,7 @@ var require_brace_expansion = __commonJS({
|
||||
function gte6(i, y) {
|
||||
return i >= y;
|
||||
}
|
||||
function expand2(str2, isTop) {
|
||||
function expand2(str2, max, isTop) {
|
||||
var expansions = [];
|
||||
var m = balanced("{", "}", str2);
|
||||
if (!m || /\$$/.test(m.pre)) return [str2];
|
||||
@@ -31056,7 +31058,7 @@ var require_brace_expansion = __commonJS({
|
||||
if (!isSequence && !isOptions) {
|
||||
if (m.post.match(/,(?!,).*\}/)) {
|
||||
str2 = m.pre + "{" + m.body + escClose + m.post;
|
||||
return expand2(str2);
|
||||
return expand2(str2, max, true);
|
||||
}
|
||||
return [str2];
|
||||
}
|
||||
@@ -31066,9 +31068,9 @@ var require_brace_expansion = __commonJS({
|
||||
} else {
|
||||
n = parseCommaParts(m.body);
|
||||
if (n.length === 1) {
|
||||
n = expand2(n[0], false).map(embrace);
|
||||
n = expand2(n[0], max, false).map(embrace);
|
||||
if (n.length === 1) {
|
||||
var post = m.post.length ? expand2(m.post, false) : [""];
|
||||
var post = m.post.length ? expand2(m.post, max, false) : [""];
|
||||
return post.map(function(p) {
|
||||
return m.pre + n[0] + p;
|
||||
});
|
||||
@@ -31076,7 +31078,7 @@ var require_brace_expansion = __commonJS({
|
||||
}
|
||||
}
|
||||
var pre = m.pre;
|
||||
var post = m.post.length ? expand2(m.post, false) : [""];
|
||||
var post = m.post.length ? expand2(m.post, max, false) : [""];
|
||||
var N;
|
||||
if (isSequence) {
|
||||
var x = numeric(n[0]);
|
||||
@@ -31114,11 +31116,11 @@ var require_brace_expansion = __commonJS({
|
||||
}
|
||||
} else {
|
||||
N = concatMap(n, function(el) {
|
||||
return expand2(el, false);
|
||||
return expand2(el, max, false);
|
||||
});
|
||||
}
|
||||
for (var j = 0; j < N.length; j++) {
|
||||
for (var k = 0; k < post.length; k++) {
|
||||
for (var k = 0; k < post.length && expansions.length < max; k++) {
|
||||
var expansion = pre + N[j] + post[k];
|
||||
if (!isTop || isSequence || expansion)
|
||||
expansions.push(expansion);
|
||||
@@ -102244,7 +102246,7 @@ var require_commonjs19 = __commonJS({
|
||||
}
|
||||
const pad = n.some(isPadded);
|
||||
N = [];
|
||||
for (let i = x; test(i, y); i += incr) {
|
||||
for (let i = x; test(i, y) && N.length < max; i += incr) {
|
||||
let c;
|
||||
if (isAlphaSequence) {
|
||||
c = String.fromCharCode(i);
|
||||
@@ -144948,7 +144950,8 @@ __export(entry_points_exports, {
|
||||
runStartProxyAction: () => runStartProxyAction,
|
||||
runStartProxyPostAction: () => runStartProxyPostAction,
|
||||
runUploadSarifAction: () => runUploadSarifAction,
|
||||
runUploadSarifPostAction: () => runUploadSarifPostAction
|
||||
runUploadSarifPostAction: () => runUploadSarifPostAction,
|
||||
uploadLib: () => upload_lib_exports
|
||||
});
|
||||
module.exports = __toCommonJS(entry_points_exports);
|
||||
|
||||
@@ -148304,7 +148307,7 @@ function getDiffRangesJsonFilePath() {
|
||||
return path2.join(getTemporaryDirectory(), PR_DIFF_RANGE_JSON_FILENAME);
|
||||
}
|
||||
function getActionVersion() {
|
||||
return "3.35.5";
|
||||
return "3.36.0";
|
||||
}
|
||||
function getWorkflowEventName() {
|
||||
return getRequiredEnvParam("GITHUB_EVENT_NAME");
|
||||
@@ -148868,8 +148871,8 @@ function wrapApiConfigurationError(e) {
|
||||
}
|
||||
|
||||
// src/defaults.json
|
||||
var bundleVersion = "codeql-bundle-v2.25.4";
|
||||
var cliVersion = "2.25.4";
|
||||
var bundleVersion = "codeql-bundle-v2.25.5";
|
||||
var cliVersion = "2.25.5";
|
||||
|
||||
// src/overlay/index.ts
|
||||
var fs4 = __toESM(require("fs"));
|
||||
@@ -148973,7 +148976,7 @@ var determineBaseBranchHeadCommitOid = async function(checkoutPathOverride) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (commitOid === mergeSha && headOid.length === 40 && baseOid.length === 40) {
|
||||
if (commitOid === mergeSha && (headOid.length === 40 || headOid.length === 64) && (baseOid.length === 40 || baseOid.length === 64)) {
|
||||
return baseOid;
|
||||
}
|
||||
return void 0;
|
||||
@@ -149039,7 +149042,7 @@ var getFileOidsUnderPath = async function(basePath) {
|
||||
"Cannot list Git OIDs of tracked files."
|
||||
);
|
||||
const fileOidMap = {};
|
||||
const regex = /^[0-9]+ ([0-9a-f]{40}) [0-9]+\t(.+)$/;
|
||||
const regex = /^[0-9]+ ([0-9a-f]{40}|[0-9a-f]{64}) [0-9]+\t(.+)$/;
|
||||
for (const line of stdout.split("\n")) {
|
||||
if (line) {
|
||||
const match = line.match(regex);
|
||||
@@ -149856,6 +149859,12 @@ async function parseAnalysisKinds(input) {
|
||||
);
|
||||
}
|
||||
var cachedAnalysisKinds;
|
||||
function isOnlyCodeScanningEnabled(analysisKinds) {
|
||||
return analysisKinds.length === 1 && analysisKinds[0] === "code-scanning" /* CodeScanning */;
|
||||
}
|
||||
function makeAnalysisKindUsageError(message) {
|
||||
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}`;
|
||||
}
|
||||
async function getAnalysisKinds(logger, features, skipCache = false) {
|
||||
if (!skipCache && cachedAnalysisKinds !== void 0) {
|
||||
return cachedAnalysisKinds;
|
||||
@@ -149863,6 +149872,14 @@ async function getAnalysisKinds(logger, features, skipCache = false) {
|
||||
const analysisKinds = await parseAnalysisKinds(
|
||||
getRequiredInput("analysis-kinds")
|
||||
);
|
||||
if (!isInTestMode() && !isDynamicWorkflow() && !isOnlyCodeScanningEnabled(analysisKinds)) {
|
||||
const codeQualityHint = analysisKinds.includes("code-quality" /* 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}`
|
||||
)
|
||||
);
|
||||
}
|
||||
const qualityQueriesInput = getOptionalInput("quality-queries");
|
||||
if (qualityQueriesInput !== void 0) {
|
||||
logger.warning(
|
||||
@@ -149884,7 +149901,9 @@ async function getAnalysisKinds(logger, features, skipCache = false) {
|
||||
}
|
||||
if (!isInTestMode() && analysisKinds.length > 1 && !await features.getValue("allow_multiple_analysis_kinds" /* AllowMultipleAnalysisKinds */)) {
|
||||
logger.error(
|
||||
"The `analysis-kinds` input is experimental and for GitHub-internal use only. Its behaviour may change at any time or be removed entirely. Specifying multiple values as input is no longer supported. Continuing with only `analysis-kinds: code-scanning`."
|
||||
makeAnalysisKindUsageError(
|
||||
"Specifying multiple values as input is no longer supported. Continuing with only `analysis-kinds: code-scanning`."
|
||||
)
|
||||
);
|
||||
cachedAnalysisKinds = ["code-scanning" /* CodeScanning */];
|
||||
return cachedAnalysisKinds;
|
||||
@@ -153719,7 +153738,7 @@ async function getCombinedTracerConfig(codeql, config) {
|
||||
|
||||
// src/codeql.ts
|
||||
var cachedCodeQL = void 0;
|
||||
var CODEQL_MINIMUM_VERSION = "2.17.6";
|
||||
var CODEQL_MINIMUM_VERSION = "2.19.4";
|
||||
var CODEQL_NEXT_MINIMUM_VERSION = "2.19.4";
|
||||
var GHES_VERSION_MOST_RECENTLY_DEPRECATED = "3.15";
|
||||
var GHES_MOST_RECENT_DEPRECATION_DATE = "2026-04-09";
|
||||
@@ -153846,10 +153865,6 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
||||
if (qlconfigFile !== void 0) {
|
||||
extraArgs.push(`--qlconfig-file=${qlconfigFile}`);
|
||||
}
|
||||
const overwriteFlag = isSupportedToolsFeature(
|
||||
await this.getVersion(),
|
||||
"forceOverwrite" /* ForceOverwrite */
|
||||
) ? "--force-overwrite" : "--overwrite";
|
||||
const overlayDatabaseMode = config.overlayDatabaseMode;
|
||||
if (overlayDatabaseMode === "overlay" /* Overlay */) {
|
||||
const overlayChangesFile = await writeOverlayChangesFile(
|
||||
@@ -153870,7 +153885,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
||||
[
|
||||
"database",
|
||||
"init",
|
||||
...overlayDatabaseMode === "overlay" /* Overlay */ ? [] : [overwriteFlag],
|
||||
...overlayDatabaseMode === "overlay" /* Overlay */ ? [] : ["--force-overwrite"],
|
||||
"--db-cluster",
|
||||
config.dbLocation,
|
||||
`--source-root=${sourceRoot}`,
|
||||
@@ -153881,7 +153896,14 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
||||
// Some user configs specify `--no-calculate-baseline` as an additional
|
||||
// argument to `codeql database init`. Therefore ignore the baseline file
|
||||
// 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 }
|
||||
@@ -154046,7 +154068,7 @@ ${output}`
|
||||
"--sarif-group-rules-by-pack",
|
||||
"--sarif-include-query-help=always",
|
||||
"--sublanguage-file-coverage",
|
||||
...await getJobRunUuidSarifOptions(this),
|
||||
...await getJobRunUuidSarifOptions(),
|
||||
...getExtraOptionsFromEnv(["database", "interpret-results"])
|
||||
];
|
||||
if (sarifRunPropertyFlag !== void 0) {
|
||||
@@ -154327,11 +154349,9 @@ function applyAutobuildAzurePipelinesTimeoutFix() {
|
||||
"-Dmaven.wagon.http.pool=false"
|
||||
].join(" ");
|
||||
}
|
||||
async function getJobRunUuidSarifOptions(codeql) {
|
||||
async function getJobRunUuidSarifOptions() {
|
||||
const jobRunUuid = process.env["JOB_RUN_UUID" /* JOB_RUN_UUID */];
|
||||
return jobRunUuid && await codeql.supportsFeature(
|
||||
"databaseInterpretResultsSupportsSarifRunProperty" /* DatabaseInterpretResultsSupportsSarifRunProperty */
|
||||
) ? [`--sarif-run-property=jobRunUuid=${jobRunUuid}`] : [];
|
||||
return jobRunUuid ? [`--sarif-run-property=jobRunUuid=${jobRunUuid}`] : [];
|
||||
}
|
||||
|
||||
// src/autobuild.ts
|
||||
@@ -155483,6 +155503,27 @@ async function sendUnhandledErrorStatusReport(actionName, actionStartedAt, error
|
||||
}
|
||||
|
||||
// src/upload-lib.ts
|
||||
var upload_lib_exports = {};
|
||||
__export(upload_lib_exports, {
|
||||
buildPayload: () => buildPayload,
|
||||
filterAlertsByDiffRange: () => filterAlertsByDiffRange,
|
||||
findSarifFilesInDir: () => findSarifFilesInDir,
|
||||
getGroupedSarifFilePaths: () => getGroupedSarifFilePaths,
|
||||
populateRunAutomationDetails: () => populateRunAutomationDetails,
|
||||
postProcessSarifFiles: () => postProcessSarifFiles,
|
||||
readSarifFileOrThrow: () => readSarifFileOrThrow,
|
||||
shouldConsiderConfigurationError: () => shouldConsiderConfigurationError,
|
||||
shouldConsiderInvalidRequest: () => shouldConsiderInvalidRequest,
|
||||
shouldShowCombineSarifFilesDeprecationWarning: () => shouldShowCombineSarifFilesDeprecationWarning,
|
||||
throwIfCombineSarifFilesDisabled: () => throwIfCombineSarifFilesDisabled,
|
||||
uploadFiles: () => uploadFiles,
|
||||
uploadPayload: () => uploadPayload,
|
||||
uploadPostProcessedFiles: () => uploadPostProcessedFiles,
|
||||
validateSarifFileSchema: () => validateSarifFileSchema,
|
||||
validateUniqueCategory: () => validateUniqueCategory,
|
||||
waitForProcessing: () => waitForProcessing,
|
||||
writePostProcessedFiles: () => writePostProcessedFiles
|
||||
});
|
||||
var fs21 = __toESM(require("fs"));
|
||||
var path18 = __toESM(require("path"));
|
||||
var url = __toESM(require("url"));
|
||||
@@ -161270,7 +161311,8 @@ async function runUploadSarifPostAction() {
|
||||
runStartProxyAction,
|
||||
runStartProxyPostAction,
|
||||
runUploadSarifAction,
|
||||
runUploadSarifPostAction
|
||||
runUploadSarifPostAction,
|
||||
uploadLib
|
||||
});
|
||||
/*! Bundled license information:
|
||||
|
||||
|
||||
Generated
+3
-93733
File diff suppressed because one or more lines are too long
Generated
+216
-318
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "codeql",
|
||||
"version": "4.35.5",
|
||||
"version": "4.36.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "codeql",
|
||||
"version": "4.35.5",
|
||||
"version": "4.36.0",
|
||||
"license": "MIT",
|
||||
"workspaces": [
|
||||
"pr-checks"
|
||||
@@ -36,7 +36,7 @@
|
||||
"uuid": "^14.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ava/typescript": "7.0.0",
|
||||
"@ava/typescript": "6.0.0",
|
||||
"@eslint/compat": "^2.0.5",
|
||||
"@microsoft/eslint-formatter-sarif": "^3.1.0",
|
||||
"@octokit/types": "^16.0.0",
|
||||
@@ -48,7 +48,7 @@
|
||||
"@types/sarif": "^2.1.7",
|
||||
"@types/semver": "^7.7.1",
|
||||
"@types/sinon": "^21.0.1",
|
||||
"ava": "^7.0.0",
|
||||
"ava": "^6.4.1",
|
||||
"esbuild": "^0.28.0",
|
||||
"eslint": "^9.39.4",
|
||||
"eslint-import-resolver-typescript": "^4.4.4",
|
||||
@@ -59,7 +59,7 @@
|
||||
"glob": "^11.1.0",
|
||||
"globals": "^17.6.0",
|
||||
"nock": "^14.0.12",
|
||||
"sinon": "^21.1.2",
|
||||
"sinon": "^22.0.0",
|
||||
"typescript": "^6.0.3",
|
||||
"typescript-eslint": "^8.59.2"
|
||||
}
|
||||
@@ -450,17 +450,17 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@ava/typescript": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@ava/typescript/-/typescript-7.0.0.tgz",
|
||||
"integrity": "sha512-0ktzq4/9ya2QoAuVWzl3McpLV9W//Tj+oMonQ4ucgm5l6tQ46aaju/rJL9kzeY5MkG6wzXvFt/MmaLqf9uNC9w==",
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@ava/typescript/-/typescript-6.0.0.tgz",
|
||||
"integrity": "sha512-+8oDYc4J5cCaWZh1VUbyc+cegGplJO9FqHpqR4LVAVx8fRLVRaYlC4yyA6cqHJ1vWP23Ff/ECS5U68Zz6OLZlg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"escape-string-regexp": "^5.0.0",
|
||||
"execa": "^9.6.1"
|
||||
"execa": "^9.6.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^22.20 || ^24.12 || >=25"
|
||||
"node": "^20.8 || ^22 || >=24"
|
||||
}
|
||||
},
|
||||
"node_modules/@ava/typescript/node_modules/escape-string-regexp": {
|
||||
@@ -2379,9 +2379,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@sinonjs/fake-timers": {
|
||||
"version": "15.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-15.3.2.tgz",
|
||||
"integrity": "sha512-mrn35Jl2pCpns+mE3HaZa1yPN5EYCRgiMI+135COjr2hr8Cls9DXqIZ57vZe2cz7y2XVSq92tcs6kGQcT1J8Rw==",
|
||||
"version": "15.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-15.4.0.tgz",
|
||||
"integrity": "sha512-DsG+8/LscQIQg68J6Ef3dv10u6nVyetYn923s3/sus5eaGfTo1of5WMZSLf0UJc9KDuKPilPH0UDJCjvNbDNCA==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
@@ -3172,9 +3172,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@vercel/nft": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@vercel/nft/-/nft-1.3.2.tgz",
|
||||
"integrity": "sha512-HC8venRc4Ya7vNeBsJneKHHMDDWpQie7VaKhAIOst3MKO+DES+Y/SbzSp8mFkD7OzwAE2HhHkeSuSmwS20mz3A==",
|
||||
"version": "0.29.4",
|
||||
"resolved": "https://registry.npmjs.org/@vercel/nft/-/nft-0.29.4.tgz",
|
||||
"integrity": "sha512-6lLqMNX3TuycBPABycx7A9F1bHQR7kiQln6abjFbPrf5C/05qHM9M5E4PeTE59c7z8g6vHnx1Ioihb2AQl7BTA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -3185,7 +3185,7 @@
|
||||
"async-sema": "^3.1.1",
|
||||
"bindings": "^1.4.0",
|
||||
"estree-walker": "2.0.2",
|
||||
"glob": "^13.0.0",
|
||||
"glob": "^10.4.5",
|
||||
"graceful-fs": "^4.2.9",
|
||||
"node-gyp-build": "^4.2.2",
|
||||
"picomatch": "^4.0.2",
|
||||
@@ -3195,7 +3195,7 @@
|
||||
"nft": "out/cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/abbrev": {
|
||||
@@ -3561,57 +3561,58 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/ava": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ava/-/ava-7.0.0.tgz",
|
||||
"integrity": "sha512-4sRJO/gehlfAgSbuH02mClDDiyymnuFmirE3KqPXl2pic1FaFTZaAACKqr85WT4o08iLjViMR9gmMkxzbZ3AgA==",
|
||||
"version": "6.4.1",
|
||||
"resolved": "https://registry.npmjs.org/ava/-/ava-6.4.1.tgz",
|
||||
"integrity": "sha512-vxmPbi1gZx9zhAjHBgw81w/iEDKcrokeRk/fqDTyA2DQygZ0o+dUGRHFOtX8RA5N0heGJTTsIk7+xYxitDb61Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vercel/nft": "^1.3.2",
|
||||
"acorn": "^8.16.0",
|
||||
"acorn-walk": "^8.3.5",
|
||||
"ansi-styles": "^6.2.3",
|
||||
"@vercel/nft": "^0.29.4",
|
||||
"acorn": "^8.15.0",
|
||||
"acorn-walk": "^8.3.4",
|
||||
"ansi-styles": "^6.2.1",
|
||||
"arrgv": "^1.0.2",
|
||||
"arrify": "^3.0.0",
|
||||
"callsites": "^4.2.0",
|
||||
"cbor": "^10.0.11",
|
||||
"chalk": "^5.6.2",
|
||||
"cbor": "^10.0.9",
|
||||
"chalk": "^5.4.1",
|
||||
"chunkd": "^2.0.1",
|
||||
"ci-info": "^4.4.0",
|
||||
"ci-info": "^4.3.0",
|
||||
"ci-parallel-vars": "^1.0.1",
|
||||
"cli-truncate": "^5.1.1",
|
||||
"cli-truncate": "^4.0.0",
|
||||
"code-excerpt": "^4.0.0",
|
||||
"common-path-prefix": "^3.0.0",
|
||||
"concordance": "^5.0.4",
|
||||
"currently-unhandled": "^0.4.1",
|
||||
"debug": "^4.4.3",
|
||||
"debug": "^4.4.1",
|
||||
"emittery": "^1.2.0",
|
||||
"figures": "^6.1.0",
|
||||
"globby": "^16.1.1",
|
||||
"globby": "^14.1.0",
|
||||
"ignore-by-default": "^2.1.0",
|
||||
"indent-string": "^5.0.0",
|
||||
"is-plain-object": "^5.0.0",
|
||||
"is-promise": "^4.0.0",
|
||||
"matcher": "^6.0.0",
|
||||
"memoize": "^10.2.0",
|
||||
"matcher": "^5.0.0",
|
||||
"memoize": "^10.1.0",
|
||||
"ms": "^2.1.3",
|
||||
"p-map": "^7.0.4",
|
||||
"p-map": "^7.0.3",
|
||||
"package-config": "^5.0.0",
|
||||
"picomatch": "^4.0.3",
|
||||
"plur": "^6.0.0",
|
||||
"pretty-ms": "^9.3.0",
|
||||
"picomatch": "^4.0.2",
|
||||
"plur": "^5.1.0",
|
||||
"pretty-ms": "^9.2.0",
|
||||
"resolve-cwd": "^3.0.0",
|
||||
"stack-utils": "^2.0.6",
|
||||
"strip-ansi": "^7.1.0",
|
||||
"supertap": "^3.0.1",
|
||||
"temp-dir": "^3.0.0",
|
||||
"write-file-atomic": "^7.0.0",
|
||||
"yargs": "^18.0.0"
|
||||
"write-file-atomic": "^6.0.0",
|
||||
"yargs": "^17.7.2"
|
||||
},
|
||||
"bin": {
|
||||
"ava": "entrypoints/cli.mjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.19 || ^22.20 || ^24.12 || >=25"
|
||||
"node": "^18.18 || ^20.8 || ^22 || ^23 || >=24"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@ava/typescript": "*"
|
||||
@@ -3622,6 +3623,19 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/ava/node_modules/ansi-regex": {
|
||||
"version": "6.2.2",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz",
|
||||
"integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/ansi-regex?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/ava/node_modules/callsites": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/callsites/-/callsites-4.2.0.tgz",
|
||||
@@ -3652,6 +3666,22 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/ava/node_modules/strip-ansi": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz",
|
||||
"integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-regex": "^6.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/available-typed-arrays": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz",
|
||||
@@ -3765,9 +3795,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "1.1.13",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.13.tgz",
|
||||
"integrity": "sha512-9ZLprWS6EENmhEOpjCYW2c8VkmOvckIJZfkr7rBW6dObmfgJ/L1GpSYW5Hpo9lDz4D1+n0Ckz8rU7FwHDQiG/w==",
|
||||
"version": "1.1.14",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.14.tgz",
|
||||
"integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"balanced-match": "^1.0.0",
|
||||
@@ -4016,17 +4046,17 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/cli-truncate": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-5.2.0.tgz",
|
||||
"integrity": "sha512-xRwvIOMGrfOAnM1JYtqQImuaNtDEv9v6oIYAs4LIHwTiKee8uwvIi363igssOC0O5U04i4AlENs79LQLu9tEMw==",
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-4.0.0.tgz",
|
||||
"integrity": "sha512-nPdaFdQ0h/GEigbPClz11D0v/ZJEwxmeVZGeMo3Z5StPtUTkA9o1lD6QwoirYiSDzbcwn2XcjwmCp68W1IS4TA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"slice-ansi": "^8.0.0",
|
||||
"string-width": "^8.2.0"
|
||||
"slice-ansi": "^5.0.0",
|
||||
"string-width": "^7.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
@@ -4045,18 +4075,26 @@
|
||||
"url": "https://github.com/chalk/ansi-regex?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/cli-truncate/node_modules/emoji-regex": {
|
||||
"version": "10.6.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz",
|
||||
"integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/cli-truncate/node_modules/string-width": {
|
||||
"version": "8.2.0",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-8.2.0.tgz",
|
||||
"integrity": "sha512-6hJPQ8N0V0P3SNmP6h2J99RLuzrWz2gvT7VnK5tKvrNqJoyS9W4/Fb8mo31UiPvy00z7DQXkP2hnKBVav76thw==",
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
|
||||
"integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"get-east-asian-width": "^1.5.0",
|
||||
"strip-ansi": "^7.1.2"
|
||||
"emoji-regex": "^10.3.0",
|
||||
"get-east-asian-width": "^1.0.0",
|
||||
"strip-ansi": "^7.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
@@ -4079,72 +4117,18 @@
|
||||
}
|
||||
},
|
||||
"node_modules/cliui": {
|
||||
"version": "9.0.1",
|
||||
"resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz",
|
||||
"integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==",
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
|
||||
"integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"string-width": "^7.2.0",
|
||||
"strip-ansi": "^7.1.0",
|
||||
"wrap-ansi": "^9.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/cliui/node_modules/ansi-regex": {
|
||||
"version": "6.2.2",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz",
|
||||
"integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/ansi-regex?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/cliui/node_modules/emoji-regex": {
|
||||
"version": "10.6.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz",
|
||||
"integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/cliui/node_modules/string-width": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
|
||||
"integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"emoji-regex": "^10.3.0",
|
||||
"get-east-asian-width": "^1.0.0",
|
||||
"strip-ansi": "^7.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/cliui/node_modules/strip-ansi": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz",
|
||||
"integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-regex": "^6.2.2"
|
||||
"string-width": "^4.2.0",
|
||||
"strip-ansi": "^6.0.1",
|
||||
"wrap-ansi": "^7.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/code-excerpt": {
|
||||
@@ -4458,9 +4442,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/diff": {
|
||||
"version": "8.0.4",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-8.0.4.tgz",
|
||||
"integrity": "sha512-DPi0FmjiSU5EvQV0++GFDOJ9ASQUVFh5kD+OzOnYdi7n3Wpm9hWWGfB/O2blfHcMVTL5WkQXSnRiK9makhrcnw==",
|
||||
"version": "9.0.0",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-9.0.0.tgz",
|
||||
"integrity": "sha512-svtcdpS8CgJyqAjEQIXdb3OjhFVVYjzGAPO8WGCmRbrml64SPw/jJD4GoE98aR7r25A0XcgrK3F02yw9R/vhQw==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
@@ -5138,9 +5122,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-import-x/node_modules/brace-expansion": {
|
||||
"version": "5.0.5",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.5.tgz",
|
||||
"integrity": "sha512-VZznLgtwhn+Mact9tfiwx64fA9erHH/MCXEUfB/0bX/6Fz6ny5EGTXYltMocqg4xFAQZtnO3DHWWXi8RiuN7cQ==",
|
||||
"version": "5.0.6",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.6.tgz",
|
||||
"integrity": "sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -5939,9 +5923,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/get-east-asian-width": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.5.0.tgz",
|
||||
"integrity": "sha512-CQ+bEO+Tva/qlmw24dCejulK5pMzVnUOFOijVogd3KQs07HnRIgp8TGipvCCRT06xeYEbpbgwaCxglFyiuIcmA==",
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.6.0.tgz",
|
||||
"integrity": "sha512-QRbvDIbx6YklUe6RxeTeleMR0yv3cYH6PsPZHcnVn7xv7zO1BHN8r0XETu8n6Ye3Q+ahtSarc3WgtNWmehIBfA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -6094,9 +6078,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/glob/node_modules/brace-expansion": {
|
||||
"version": "5.0.5",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.5.tgz",
|
||||
"integrity": "sha512-VZznLgtwhn+Mact9tfiwx64fA9erHH/MCXEUfB/0bX/6Fz6ny5EGTXYltMocqg4xFAQZtnO3DHWWXi8RiuN7cQ==",
|
||||
"version": "5.0.6",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.6.tgz",
|
||||
"integrity": "sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"balanced-match": "^4.0.2"
|
||||
@@ -6151,21 +6135,34 @@
|
||||
}
|
||||
},
|
||||
"node_modules/globby": {
|
||||
"version": "16.1.1",
|
||||
"resolved": "https://registry.npmjs.org/globby/-/globby-16.1.1.tgz",
|
||||
"integrity": "sha512-dW7vl+yiAJSp6aCekaVnVJxurRv7DCOLyXqEG3RYMYUg7AuJ2jCqPkZTA8ooqC2vtnkaMcV5WfFBMuEnTu1OQg==",
|
||||
"version": "14.1.0",
|
||||
"resolved": "https://registry.npmjs.org/globby/-/globby-14.1.0.tgz",
|
||||
"integrity": "sha512-0Ia46fDOaT7k4og1PDW4YbodWWr3scS2vAr2lTbsplOt2WkKp0vQbkI9wKis/T5LV/dqPjO3bpS/z6GTJB82LA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@sindresorhus/merge-streams": "^4.0.0",
|
||||
"@sindresorhus/merge-streams": "^2.1.0",
|
||||
"fast-glob": "^3.3.3",
|
||||
"ignore": "^7.0.5",
|
||||
"is-path-inside": "^4.0.0",
|
||||
"ignore": "^7.0.3",
|
||||
"path-type": "^6.0.0",
|
||||
"slash": "^5.1.0",
|
||||
"unicorn-magic": "^0.4.0"
|
||||
"unicorn-magic": "^0.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/globby/node_modules/@sindresorhus/merge-streams": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-2.3.0.tgz",
|
||||
"integrity": "sha512-LtoMMhxAlorcGhmFYI+LhPgbPZCkgP6ra1YL604EeF6U98pLlQ3iWIGMdWSC+vWmPBWBNgmDBAhnAobLROJmwg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
@@ -6181,32 +6178,6 @@
|
||||
"node": ">= 4"
|
||||
}
|
||||
},
|
||||
"node_modules/globby/node_modules/is-path-inside": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-4.0.0.tgz",
|
||||
"integrity": "sha512-lJJV/5dYS+RcL8uQdBDW9c9uWFLLBNRyFhnAKXw5tVqLlKZ4RMGZKv+YQ/IA3OhD+RpbJa1LLFM1FQPGyIXvOA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/globby/node_modules/unicorn-magic": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.4.0.tgz",
|
||||
"integrity": "sha512-wH590V9VNgYH9g3lH9wWjTrUoKsjLF6sGLjhR4sH1LWpLmCOH0Zf7PukhDA8BiS7KHe4oPNkcTHqYkj7SOGUOw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/gopd": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
|
||||
@@ -6471,16 +6442,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/irregular-plurals": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/irregular-plurals/-/irregular-plurals-4.2.0.tgz",
|
||||
"integrity": "sha512-bW9UXHL7bnUcNtTo+9ccSngbxc+V40H32IgvdVin0Xs8gbo+AVYD5g/72ce/54Kjfhq66vcZr8H8TKEvsifeOw==",
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/irregular-plurals/-/irregular-plurals-3.5.0.tgz",
|
||||
"integrity": "sha512-1ANGLZ+Nkv1ptFb2pa8oG8Lem4krflKuX/gINiHJHjJUKaJHk/SXk5x6K3J+39/p0h1RQ2saROclJJ+QLvETCQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18.20"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/is-array-buffer": {
|
||||
@@ -7251,16 +7219,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/matcher": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/matcher/-/matcher-6.0.0.tgz",
|
||||
"integrity": "sha512-TzDerdcNtI79w7Av4GT57bLdElPA/VAkjqdMZv8yhuc8geU2z0ljW9anXbX/55aHEMTpYypZb1lxsA/46r9oOQ==",
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/matcher/-/matcher-5.0.0.tgz",
|
||||
"integrity": "sha512-s2EMBOWtXFc8dgqvoAzKJXxNHibcdJMV0gwqKUaw9E2JBJuGUK7DrNKrA6g/i+v72TT16+6sVm5mS3thaMLQUw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"escape-string-regexp": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
@@ -7881,6 +7849,19 @@
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/path-type": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/path-type/-/path-type-6.0.0.tgz",
|
||||
"integrity": "sha512-Vj7sf++t5pBD637NSfkxpHSMfWaeig5+DKWLhcqIYx6mWQz5hdJTGDVMQiJcw1ZYkhs7AazKDGpRVji1LJCZUQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/picocolors": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
||||
@@ -7902,16 +7883,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/plur": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/plur/-/plur-6.0.0.tgz",
|
||||
"integrity": "sha512-Y9wXQivjRX0REtwpA9+n0bYYypWESn3cWtW2vazymw711qn+AQXxzZjRqhANYGBLIMC1UzVdpwe/1hHQwHfwng==",
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/plur/-/plur-5.1.0.tgz",
|
||||
"integrity": "sha512-VP/72JeXqak2KiOzjgKtQen5y3IZHn+9GOuLDafPv0eXa47xq0At93XahYBs26MsifCQ4enGKwbjBTKgb9QJXg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"irregular-plurals": "^4.2.0"
|
||||
"irregular-plurals": "^3.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
@@ -8128,6 +8109,16 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/require-directory": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
|
||||
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/requireindex": {
|
||||
"version": "1.1.0",
|
||||
"dev": true,
|
||||
@@ -8511,16 +8502,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/sinon": {
|
||||
"version": "21.1.2",
|
||||
"resolved": "https://registry.npmjs.org/sinon/-/sinon-21.1.2.tgz",
|
||||
"integrity": "sha512-FS6mN+/bx7e2ajpXkEmOcWB6xBzWiuNoAQT18/+a20SS4U7FSYl8Ms7N6VTUxN/1JAjkx7aXp+THMC8xdpp0gA==",
|
||||
"version": "22.0.0",
|
||||
"resolved": "https://registry.npmjs.org/sinon/-/sinon-22.0.0.tgz",
|
||||
"integrity": "sha512-sq/6DpdXOrLyfbKlXLg/Usc7xu8YXPeLkOFZRvA3bNUSA2lhbrZ06yuXbH1fkzBPCbz9O10+7hznzUsjaYNm0Q==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"@sinonjs/commons": "^3.0.1",
|
||||
"@sinonjs/fake-timers": "^15.3.2",
|
||||
"@sinonjs/fake-timers": "^15.4.0",
|
||||
"@sinonjs/samsam": "^10.0.2",
|
||||
"diff": "^8.0.4"
|
||||
"diff": "^9.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@@ -8541,33 +8532,30 @@
|
||||
}
|
||||
},
|
||||
"node_modules/slice-ansi": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-8.0.0.tgz",
|
||||
"integrity": "sha512-stxByr12oeeOyY2BlviTNQlYV5xOj47GirPr4yA1hE9JCtxfQN0+tVbkxwCtYDQWhEKWFHsEK48ORg5jrouCAg==",
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-5.0.0.tgz",
|
||||
"integrity": "sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-styles": "^6.2.3",
|
||||
"is-fullwidth-code-point": "^5.1.0"
|
||||
"ansi-styles": "^6.0.0",
|
||||
"is-fullwidth-code-point": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/slice-ansi?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/slice-ansi/node_modules/is-fullwidth-code-point": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-5.1.0.tgz",
|
||||
"integrity": "sha512-5XHYaSyiqADb4RnZ1Bdad6cPp8Toise4TzEjcOYDHZkTCbKgiUl7WTUCpNWHuxmDt91wnsZBc9xinNzopv3JMQ==",
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz",
|
||||
"integrity": "sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"get-east-asian-width": "^1.3.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
@@ -8962,9 +8950,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/tar": {
|
||||
"version": "7.5.11",
|
||||
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.11.tgz",
|
||||
"integrity": "sha512-ChjMH33/KetonMTAtpYdgUFr0tbz69Fp2v7zWxQfYZX4g5ZN2nOBXm1R2xyA+lMIKrLKIoKAwFj93jE/avX9cQ==",
|
||||
"version": "7.5.15",
|
||||
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.15.tgz",
|
||||
"integrity": "sha512-dzGK0boVlC4W5QFuQN1EFSl3bIDYsk7Tj40U6eIBnK2k/8ml7TZ5agbI5j5+qnoVcAA+rNtBml8SEiLxZpNqRQ==",
|
||||
"dev": true,
|
||||
"license": "BlueOak-1.0.0",
|
||||
"dependencies": {
|
||||
@@ -10104,18 +10092,18 @@
|
||||
}
|
||||
},
|
||||
"node_modules/wrap-ansi": {
|
||||
"version": "9.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz",
|
||||
"integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==",
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
|
||||
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-styles": "^6.2.1",
|
||||
"string-width": "^7.0.0",
|
||||
"strip-ansi": "^7.1.0"
|
||||
"ansi-styles": "^4.0.0",
|
||||
"string-width": "^4.1.0",
|
||||
"strip-ansi": "^6.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
|
||||
@@ -10154,58 +10142,20 @@
|
||||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/wrap-ansi/node_modules/ansi-regex": {
|
||||
"version": "6.2.2",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz",
|
||||
"integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/ansi-regex?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/wrap-ansi/node_modules/emoji-regex": {
|
||||
"version": "10.6.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz",
|
||||
"integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/wrap-ansi/node_modules/string-width": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
|
||||
"integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
|
||||
"node_modules/wrap-ansi/node_modules/ansi-styles": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"emoji-regex": "^10.3.0",
|
||||
"get-east-asian-width": "^1.0.0",
|
||||
"strip-ansi": "^7.1.0"
|
||||
"color-convert": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
"node": ">=8"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/wrap-ansi/node_modules/strip-ansi": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz",
|
||||
"integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-regex": "^6.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
|
||||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/wrappy": {
|
||||
@@ -10213,16 +10163,17 @@
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/write-file-atomic": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-7.0.1.tgz",
|
||||
"integrity": "sha512-OTIk8iR8/aCRWBqvxrzxR0hgxWpnYBblY1S5hDWBQfk/VFmJwzmJgQFN3WsoUKHISv2eAwe+PpbUzyL1CKTLXg==",
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-6.0.0.tgz",
|
||||
"integrity": "sha512-GmqrO8WJ1NuzJ2DrziEI2o57jKAVIQNf8a18W3nCYU3H7PNWqCCVTeH6/NQE93CIllIgQS98rrmVkYgTX9fFJQ==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"imurmurhash": "^0.1.4",
|
||||
"signal-exit": "^4.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.17.0 || >=22.9.0"
|
||||
"node": "^18.17.0 || >=20.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/xml-naming": {
|
||||
@@ -10276,85 +10227,32 @@
|
||||
}
|
||||
},
|
||||
"node_modules/yargs": {
|
||||
"version": "18.0.0",
|
||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-18.0.0.tgz",
|
||||
"integrity": "sha512-4UEqdc2RYGHZc7Doyqkrqiln3p9X2DZVxaGbwhn2pi7MrRagKaOcIKe8L3OxYcbhXLgLFUS3zAYuQjKBQgmuNg==",
|
||||
"version": "17.7.2",
|
||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz",
|
||||
"integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cliui": "^9.0.1",
|
||||
"cliui": "^8.0.1",
|
||||
"escalade": "^3.1.1",
|
||||
"get-caller-file": "^2.0.5",
|
||||
"string-width": "^7.2.0",
|
||||
"require-directory": "^2.1.1",
|
||||
"string-width": "^4.2.3",
|
||||
"y18n": "^5.0.5",
|
||||
"yargs-parser": "^22.0.0"
|
||||
"yargs-parser": "^21.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.19.0 || ^22.12.0 || >=23"
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/yargs-parser": {
|
||||
"version": "22.0.0",
|
||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz",
|
||||
"integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==",
|
||||
"version": "21.1.1",
|
||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz",
|
||||
"integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": "^20.19.0 || ^22.12.0 || >=23"
|
||||
}
|
||||
},
|
||||
"node_modules/yargs/node_modules/ansi-regex": {
|
||||
"version": "6.2.2",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz",
|
||||
"integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/ansi-regex?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/yargs/node_modules/emoji-regex": {
|
||||
"version": "10.6.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz",
|
||||
"integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/yargs/node_modules/string-width": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
|
||||
"integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"emoji-regex": "^10.3.0",
|
||||
"get-east-asian-width": "^1.0.0",
|
||||
"strip-ansi": "^7.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/yargs/node_modules/strip-ansi": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz",
|
||||
"integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-regex": "^6.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/yocto-queue": {
|
||||
|
||||
+6
-5
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "codeql",
|
||||
"version": "3.35.5",
|
||||
"version": "3.36.0",
|
||||
"private": true,
|
||||
"description": "CodeQL action",
|
||||
"scripts": {
|
||||
@@ -12,7 +12,8 @@
|
||||
"ava": "npm run transpile && ava --verbose",
|
||||
"test": "npm run ava -- src/",
|
||||
"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",
|
||||
"workspaces": [
|
||||
@@ -43,7 +44,7 @@
|
||||
"uuid": "^14.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ava/typescript": "7.0.0",
|
||||
"@ava/typescript": "6.0.0",
|
||||
"@eslint/compat": "^2.0.5",
|
||||
"@microsoft/eslint-formatter-sarif": "^3.1.0",
|
||||
"@octokit/types": "^16.0.0",
|
||||
@@ -55,7 +56,7 @@
|
||||
"@types/sarif": "^2.1.7",
|
||||
"@types/semver": "^7.7.1",
|
||||
"@types/sinon": "^21.0.1",
|
||||
"ava": "^7.0.0",
|
||||
"ava": "^6.4.1",
|
||||
"esbuild": "^0.28.0",
|
||||
"eslint": "^9.39.4",
|
||||
"eslint-import-resolver-typescript": "^4.4.4",
|
||||
@@ -66,7 +67,7 @@
|
||||
"glob": "^11.1.0",
|
||||
"globals": "^17.6.0",
|
||||
"nock": "^14.0.12",
|
||||
"sinon": "^21.1.2",
|
||||
"sinon": "^22.0.0",
|
||||
"typescript": "^6.0.3",
|
||||
"typescript-eslint": "^8.59.2"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,259 @@
|
||||
#!/usr/bin/env npx tsx
|
||||
|
||||
/*
|
||||
Tests for check-repo-size.ts.
|
||||
*/
|
||||
|
||||
import * as assert from "node:assert/strict";
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { randomBytes } from "node:crypto";
|
||||
import * as fs from "node:fs";
|
||||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import { afterEach, beforeEach, describe, it } from "node:test";
|
||||
|
||||
import {
|
||||
COMMENT_MARKER,
|
||||
DEFAULT_BASE_REF,
|
||||
buildCommentBody,
|
||||
formatBytes,
|
||||
formatPercent,
|
||||
isDeltaSignificant,
|
||||
measureArchiveSize,
|
||||
readArgs,
|
||||
} from "./check-repo-size";
|
||||
|
||||
describe("formatBytes", async () => {
|
||||
const cases: Array<[number, boolean, string]> = [
|
||||
// Unsigned values, including sub-KiB amounts which round to 0.00.
|
||||
[0, false, "0.00 KiB"],
|
||||
[512, false, "0.50 KiB"],
|
||||
[1024, false, "1.00 KiB"],
|
||||
[1024 * 1024, false, "1024.00 KiB"],
|
||||
[2 * 1024 * 1024, false, "2048.00 KiB"],
|
||||
// Negative values always use a leading minus.
|
||||
[-2 * 1024 * 1024, false, "-2048.00 KiB"],
|
||||
// signed=true prepends a + to non-negative values.
|
||||
[0, true, "+0.00 KiB"],
|
||||
[2 * 1024 * 1024, true, "+2048.00 KiB"],
|
||||
[-2 * 1024 * 1024, true, "-2048.00 KiB"],
|
||||
];
|
||||
for (const [bytes, signed, expected] of cases) {
|
||||
await it(`formats ${bytes} (signed=${signed}) as ${expected}`, () => {
|
||||
assert.equal(formatBytes(bytes, signed), expected);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe("formatPercent", async () => {
|
||||
await it("formats positive fractions with a leading +", () => {
|
||||
assert.equal(formatPercent(0.1), "+10.00%");
|
||||
assert.equal(formatPercent(0.0123), "+1.23%");
|
||||
});
|
||||
|
||||
await it("formats negative fractions with a leading -", () => {
|
||||
assert.equal(formatPercent(-0.1), "-10.00%");
|
||||
});
|
||||
|
||||
await it("formats zero without a sign", () => {
|
||||
assert.equal(formatPercent(0), "0.00%");
|
||||
});
|
||||
});
|
||||
|
||||
describe("isDeltaSignificant", async () => {
|
||||
const cases: Array<[number, number, number, boolean]> = [
|
||||
// At and above threshold (both signs).
|
||||
[100, 1000, 0.1, true],
|
||||
[101, 1000, 0.1, true],
|
||||
[-100, 1000, 0.1, true],
|
||||
// Below threshold (both signs, plus exact zero).
|
||||
[99, 1000, 0.1, false],
|
||||
[-99, 1000, 0.1, false],
|
||||
[0, 1000, 0.1, false],
|
||||
];
|
||||
for (const [delta, base, fraction, expected] of cases) {
|
||||
await it(`returns ${expected} for delta=${delta}, base=${base}, fraction=${fraction}`, () => {
|
||||
assert.equal(isDeltaSignificant(delta, base, fraction), expected);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe("buildCommentBody", async () => {
|
||||
await it("includes the marker, the base/PR/delta rows, and the run URL", () => {
|
||||
const body = buildCommentBody({
|
||||
baseRef: "main",
|
||||
baseSize: 2_000_000,
|
||||
prSize: 2_300_000,
|
||||
runUrl: "https://example.test/run",
|
||||
});
|
||||
|
||||
assert.match(body, new RegExp(`^${escapeRegExp(COMMENT_MARKER)}`));
|
||||
assert.match(body, /Base \(`main`\) \| 1953\.13 KiB \(2000000 bytes\)/);
|
||||
assert.match(body, /This PR \| 2246\.09 KiB \(2300000 bytes\)/);
|
||||
assert.match(
|
||||
body,
|
||||
/\*\*Delta\*\* \| \*\*\+292\.97 KiB \(\+300000 bytes, \+15\.00%\)\*\*/,
|
||||
);
|
||||
assert.match(body, /\[workflow run\]\(https:\/\/example\.test\/run\)/);
|
||||
});
|
||||
|
||||
await it("formats negative deltas with a leading minus and omits the run URL when missing", () => {
|
||||
const body = buildCommentBody({
|
||||
baseRef: "main",
|
||||
baseSize: 2_000_000,
|
||||
prSize: 1_800_000,
|
||||
});
|
||||
assert.match(
|
||||
body,
|
||||
/\*\*Delta\*\* \| \*\*-195\.31 KiB \(-200000 bytes, -10\.00%\)\*\*/,
|
||||
);
|
||||
assert.doesNotMatch(body, /workflow run/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("readArgs", async () => {
|
||||
await it("defaults the base ref and head commit for local runs", () => {
|
||||
const originalEnv = process.env;
|
||||
const originalArgv = process.argv;
|
||||
|
||||
try {
|
||||
process.env = {};
|
||||
process.argv = ["node", "check-repo-size.ts", "--output-dir", "/tmp/out"];
|
||||
|
||||
const args = readArgs();
|
||||
|
||||
assert.equal(args.baseRef, DEFAULT_BASE_REF);
|
||||
assert.equal(args.baseCommitish, `origin/${DEFAULT_BASE_REF}`);
|
||||
assert.equal(args.headCommitish, "HEAD");
|
||||
assert.equal(args.outputDir, "/tmp/out");
|
||||
assert.equal(args.runUrl, undefined);
|
||||
} finally {
|
||||
process.env = originalEnv;
|
||||
process.argv = originalArgv;
|
||||
}
|
||||
});
|
||||
|
||||
await it("uses the base and head SHAs when provided by the workflow", () => {
|
||||
const originalEnv = process.env;
|
||||
const originalArgv = process.argv;
|
||||
|
||||
try {
|
||||
process.env = {
|
||||
BASE_REF: "main",
|
||||
BASE_SHA: "abc123",
|
||||
HEAD_SHA: "def456",
|
||||
RUN_URL: "https://example.test/run",
|
||||
};
|
||||
process.argv = ["node", "check-repo-size.ts", "--output-dir", "/tmp/out"];
|
||||
|
||||
const args = readArgs();
|
||||
|
||||
assert.equal(args.baseRef, "main");
|
||||
assert.equal(args.baseCommitish, "abc123");
|
||||
assert.equal(args.headCommitish, "def456");
|
||||
assert.equal(args.outputDir, "/tmp/out");
|
||||
assert.equal(args.runUrl, "https://example.test/run");
|
||||
} finally {
|
||||
process.env = originalEnv;
|
||||
process.argv = originalArgv;
|
||||
}
|
||||
});
|
||||
|
||||
await it("throws when --output-dir is missing", () => {
|
||||
const originalEnv = process.env;
|
||||
const originalArgv = process.argv;
|
||||
|
||||
try {
|
||||
process.env = {};
|
||||
process.argv = ["node", "check-repo-size.ts"];
|
||||
assert.throws(() => readArgs(), /--output-dir is required/);
|
||||
} finally {
|
||||
process.env = originalEnv;
|
||||
process.argv = originalArgv;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
let repoDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
repoDir = fs.mkdtempSync(path.join(os.tmpdir(), "check-repo-size-test-"));
|
||||
execFileSync("git", ["init", "--initial-branch=main", "-q"], {
|
||||
cwd: repoDir,
|
||||
});
|
||||
execFileSync("git", ["config", "user.email", "test@example.test"], {
|
||||
cwd: repoDir,
|
||||
});
|
||||
execFileSync("git", ["config", "user.name", "Test"], { cwd: repoDir });
|
||||
execFileSync("git", ["config", "commit.gpgsign", "false"], { cwd: repoDir });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fs.rmSync(repoDir, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
function commit(name: string, content: string, message: string) {
|
||||
fs.writeFileSync(path.join(repoDir, name), content);
|
||||
execFileSync("git", ["add", name], { cwd: repoDir });
|
||||
execFileSync("git", ["commit", "-q", "-m", message], { cwd: repoDir });
|
||||
}
|
||||
|
||||
describe("measureArchiveSize", async () => {
|
||||
await it("returns a positive byte count for a non-empty repo", async () => {
|
||||
commit("a.txt", "hello world\n", "first");
|
||||
const size = await measureArchiveSize("HEAD", repoDir);
|
||||
assert.ok(size > 0, `expected size > 0, got ${size}`);
|
||||
});
|
||||
|
||||
await it("returns the same size on repeated runs (deterministic)", async () => {
|
||||
commit("a.txt", "hello world\n", "first");
|
||||
const a = await measureArchiveSize("HEAD", repoDir);
|
||||
const b = await measureArchiveSize("HEAD", repoDir);
|
||||
assert.equal(a, b);
|
||||
});
|
||||
|
||||
await it("returns a larger size when more content is added", async () => {
|
||||
commit("a.txt", "hello world\n", "first");
|
||||
const small = await measureArchiveSize("HEAD", repoDir);
|
||||
|
||||
// Use random bytes so the new content is incompressible and the archive
|
||||
// is guaranteed to grow even after gzip.
|
||||
commit("b.bin", randomBytes(8192).toString("base64"), "second");
|
||||
const big = await measureArchiveSize("HEAD", repoDir);
|
||||
assert.ok(
|
||||
big > small,
|
||||
`expected ${big} > ${small} after adding more content`,
|
||||
);
|
||||
});
|
||||
|
||||
await it("ignores untracked files (e.g. node_modules)", async () => {
|
||||
commit("a.txt", "hello\n", "first");
|
||||
commit(".gitignore", "node_modules/\n", "ignore node_modules");
|
||||
const sizeBefore = await measureArchiveSize("HEAD", repoDir);
|
||||
|
||||
fs.mkdirSync(path.join(repoDir, "node_modules"));
|
||||
fs.writeFileSync(
|
||||
path.join(repoDir, "node_modules", "huge.bin"),
|
||||
"x".repeat(1_000_000),
|
||||
);
|
||||
|
||||
const sizeAfter = await measureArchiveSize("HEAD", repoDir);
|
||||
assert.equal(
|
||||
sizeAfter,
|
||||
sizeBefore,
|
||||
"untracked node_modules should not affect the archive size",
|
||||
);
|
||||
});
|
||||
|
||||
await it("rejects when the ref does not exist", async () => {
|
||||
commit("a.txt", "hello\n", "first");
|
||||
await assert.rejects(
|
||||
() => measureArchiveSize("does-not-exist", repoDir),
|
||||
/git archive does-not-exist exited with code/,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
function escapeRegExp(s: string): string {
|
||||
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
#!/usr/bin/env npx tsx
|
||||
|
||||
/*
|
||||
Measures the difference in the `.tar.gz`'d checkout size of the repo between the PR head and the PR
|
||||
base. This size is relevant because it corresponds to the duration of the "Download action
|
||||
repository" step that happens at the start of every job that uses this Action.
|
||||
|
||||
Writes the candidate sticky-comment body and a small metadata file to `--output-dir`. A separate
|
||||
workflow job consumes those artifacts and decides whether to create or update a PR comment.
|
||||
*/
|
||||
|
||||
import { spawn } from "node:child_process";
|
||||
import * as fs from "node:fs";
|
||||
import * as path from "node:path";
|
||||
import { parseArgs } from "node:util";
|
||||
|
||||
import { REPO_ROOT } from "./config";
|
||||
|
||||
/** Hidden marker used to find the existing sticky comment on a PR. */
|
||||
export const COMMENT_MARKER = "<!-- repo-size-diff-bot -->";
|
||||
|
||||
export const DEFAULT_BASE_REF = "main";
|
||||
|
||||
/**
|
||||
* Fraction of the base archive size at which a delta is considered significant enough to warrant
|
||||
* a new sticky comment. We always update an existing comment regardless, so the comment stays in
|
||||
* sync as the diff evolves.
|
||||
*/
|
||||
export const SIGNIFICANT_DELTA_FRACTION = 0.1;
|
||||
|
||||
/**
|
||||
* Stream `git archive --format=tar.gz <ref>` and count the compressed bytes.
|
||||
*
|
||||
* `git archive` only includes tracked files, so untracked directories like `node_modules` and
|
||||
* `build` aren't counted in the size downloaded when starting up a CodeQL job.
|
||||
*/
|
||||
export async function measureArchiveSize(
|
||||
ref: string,
|
||||
cwd: string,
|
||||
): Promise<number> {
|
||||
const git = spawn("git", ["archive", "--format=tar.gz", ref], { cwd });
|
||||
|
||||
let stderr = "";
|
||||
git.stderr.on("data", (chunk: Buffer) => {
|
||||
stderr += chunk.toString();
|
||||
});
|
||||
|
||||
let size = 0;
|
||||
git.stdout.on("data", (chunk: Buffer) => {
|
||||
size += chunk.length;
|
||||
});
|
||||
|
||||
const exitCode = await new Promise<number>((resolve, reject) => {
|
||||
git.on("error", reject);
|
||||
git.on("close", resolve);
|
||||
});
|
||||
|
||||
if (exitCode !== 0) {
|
||||
throw new Error(
|
||||
`git archive ${ref} exited with code ${exitCode}: ${stderr.trim()}`,
|
||||
);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a byte count as KiB. If `signed` is true, a leading `+` is prepended for non-negative
|
||||
* values so gains and losses are visually distinct.
|
||||
*/
|
||||
export function formatBytes(bytes: number, signed = false): string {
|
||||
const sign = bytes < 0 ? "-" : signed ? "+" : "";
|
||||
const kib = Math.abs(bytes) / 1024;
|
||||
return `${sign}${kib.toFixed(2)} KiB`;
|
||||
}
|
||||
|
||||
/** Format a fraction as a signed percentage with 2 decimal places. */
|
||||
export function formatPercent(fraction: number): string {
|
||||
const pct = fraction * 100;
|
||||
const sign = pct > 0 ? "+" : "";
|
||||
return `${sign}${pct.toFixed(2)}%`;
|
||||
}
|
||||
|
||||
export interface CommentBodyOptions {
|
||||
baseRef: string;
|
||||
baseSize: number;
|
||||
prSize: number;
|
||||
/** Optional URL of the workflow run, included in the comment footer. */
|
||||
runUrl?: string;
|
||||
}
|
||||
|
||||
export function buildCommentBody(opts: CommentBodyOptions): string {
|
||||
const { baseRef, baseSize, prSize, runUrl } = opts;
|
||||
const delta = prSize - baseSize;
|
||||
const signedDelta = delta >= 0 ? `+${delta}` : `${delta}`;
|
||||
const runUrlLine = runUrl
|
||||
? ` See the [workflow run](${runUrl}) for details.`
|
||||
: "";
|
||||
|
||||
return [
|
||||
COMMENT_MARKER,
|
||||
"### Repository checkout size",
|
||||
"",
|
||||
"| | Compressed archive size |",
|
||||
"|---|---|",
|
||||
`| Base (\`${baseRef}\`) | ${formatBytes(baseSize)} (${baseSize} bytes) |`,
|
||||
`| This PR | ${formatBytes(prSize)} (${prSize} bytes) |`,
|
||||
`| **Delta** | **${formatBytes(delta, true)} (${signedDelta} bytes, ${formatPercent(delta / baseSize)})** |`,
|
||||
"",
|
||||
"Sizes are measured by streaming `git archive --format=tar.gz <ref>`, " +
|
||||
"which includes tracked files and excludes untracked files such as " +
|
||||
"`node_modules`. The compressed checkout is " +
|
||||
"downloaded by every consumer of this Action, so changes here directly " +
|
||||
`affect Action download time.${runUrlLine}`,
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true when the absolute delta is at least `fraction` of the base size. Both increases and
|
||||
* decreases are considered significant, so we report wins as well as losses.
|
||||
*/
|
||||
export function isDeltaSignificant(
|
||||
delta: number,
|
||||
baseSize: number,
|
||||
fraction: number,
|
||||
): boolean {
|
||||
return Math.abs(delta) >= baseSize * fraction;
|
||||
}
|
||||
|
||||
interface MainArgs {
|
||||
/** Base ref of the PR. Defaults to `main`. Used as the label in the PR comment. */
|
||||
baseRef: string;
|
||||
/** Base commit-ish to archive. Defaults to `origin/<baseRef>` for local runs. */
|
||||
baseCommitish: string;
|
||||
/** Head commit-ish to archive. Defaults to `HEAD` for local runs. */
|
||||
headCommitish: string;
|
||||
/** Optional URL of the workflow run, surfaced in the comment footer. */
|
||||
runUrl?: string;
|
||||
/** Directory where `body.md` and `metadata.json` are written. */
|
||||
outputDir: string;
|
||||
}
|
||||
|
||||
export function readArgs(): MainArgs {
|
||||
const { values } = parseArgs({
|
||||
options: {
|
||||
"output-dir": { type: "string" },
|
||||
},
|
||||
strict: true,
|
||||
});
|
||||
|
||||
const outputDir = values["output-dir"];
|
||||
if (!outputDir) {
|
||||
throw new Error("--output-dir is required");
|
||||
}
|
||||
|
||||
const baseRef = process.env.BASE_REF ?? DEFAULT_BASE_REF;
|
||||
const baseCommitish = process.env.BASE_SHA ?? `origin/${baseRef}`;
|
||||
const headCommitish = process.env.HEAD_SHA ?? "HEAD";
|
||||
|
||||
return {
|
||||
baseRef,
|
||||
baseCommitish,
|
||||
headCommitish,
|
||||
runUrl: process.env.RUN_URL,
|
||||
outputDir,
|
||||
};
|
||||
}
|
||||
|
||||
async function main(): Promise<number> {
|
||||
const args = readArgs();
|
||||
|
||||
console.log(`Measuring base archive size for ${args.baseCommitish}...`);
|
||||
const baseSize = await measureArchiveSize(args.baseCommitish, REPO_ROOT);
|
||||
console.log(` ${baseSize} bytes`);
|
||||
|
||||
console.log(`Measuring PR archive size for ${args.headCommitish}...`);
|
||||
const prSize = await measureArchiveSize(args.headCommitish, REPO_ROOT);
|
||||
console.log(` ${prSize} bytes`);
|
||||
|
||||
const delta = prSize - baseSize;
|
||||
const significant = isDeltaSignificant(
|
||||
delta,
|
||||
baseSize,
|
||||
SIGNIFICANT_DELTA_FRACTION,
|
||||
);
|
||||
console.log(
|
||||
`Delta: ${delta} bytes (significant=${significant}, threshold=${(
|
||||
SIGNIFICANT_DELTA_FRACTION * 100
|
||||
).toFixed(2)}%)`,
|
||||
);
|
||||
|
||||
const body = buildCommentBody({
|
||||
baseRef: args.baseRef,
|
||||
baseSize,
|
||||
prSize,
|
||||
runUrl: args.runUrl,
|
||||
});
|
||||
|
||||
fs.mkdirSync(args.outputDir, { recursive: true });
|
||||
fs.writeFileSync(path.join(args.outputDir, "body.md"), body);
|
||||
fs.writeFileSync(
|
||||
path.join(args.outputDir, "metadata.json"),
|
||||
`${JSON.stringify(
|
||||
{ significant, baseRef: args.baseRef, baseSize, prSize, delta },
|
||||
null,
|
||||
2,
|
||||
)}\n`,
|
||||
);
|
||||
console.log(`Wrote body.md and metadata.json to ${args.outputDir}.`);
|
||||
return 0;
|
||||
}
|
||||
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
process.exit(await main());
|
||||
} catch (err) {
|
||||
console.error(err instanceof Error ? err.message : String(err));
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
void run();
|
||||
}
|
||||
@@ -2,7 +2,8 @@ name: "Multi-language repository"
|
||||
description: "An end-to-end integration test of a multi-language repository using automatic language detection"
|
||||
operatingSystems:
|
||||
- ubuntu
|
||||
- macos
|
||||
- os: macos
|
||||
runner-image: macos-latest-xlarge
|
||||
env:
|
||||
CODEQL_ACTION_RESOLVE_SUPPORTED_LANGUAGES_USING_CLI: true
|
||||
installGo: true
|
||||
|
||||
@@ -2,7 +2,7 @@ name: "Rust analysis"
|
||||
description: "Tests creation of a Rust database"
|
||||
versions:
|
||||
# experimental rust support introduced, requires action to set `CODEQL_ENABLE_EXPERIMENTAL_FEATURES`
|
||||
- stable-v2.19.3
|
||||
- stable-v2.19.4
|
||||
# first public preview version
|
||||
- stable-v2.22.1
|
||||
- linked
|
||||
|
||||
@@ -3,7 +3,8 @@ description: "Tests creation of a Swift database using autobuild"
|
||||
versions:
|
||||
- nightly-latest
|
||||
operatingSystems:
|
||||
- macos
|
||||
- os: macos
|
||||
runner-image: macos-latest-xlarge
|
||||
steps:
|
||||
- uses: ./../action/init
|
||||
id: init
|
||||
|
||||
+5
-2
@@ -6,14 +6,17 @@ export const OLDEST_SUPPORTED_MAJOR_VERSION = 3;
|
||||
/** The `pr-checks` directory. */
|
||||
export const PR_CHECKS_DIR = __dirname;
|
||||
|
||||
/** The repository root. */
|
||||
export const REPO_ROOT = path.join(PR_CHECKS_DIR, "..");
|
||||
|
||||
/** The path of the file configuring which checks shouldn't be required. */
|
||||
export const PR_CHECK_EXCLUDED_FILE = path.join(PR_CHECKS_DIR, "excluded.yml");
|
||||
|
||||
/** The path to the esbuild metadata file. */
|
||||
export const BUNDLE_METADATA_FILE = path.join(PR_CHECKS_DIR, "..", "meta.json");
|
||||
export const BUNDLE_METADATA_FILE = path.join(REPO_ROOT, "meta.json");
|
||||
|
||||
/** The `src` directory. */
|
||||
const SOURCE_ROOT = path.join(PR_CHECKS_DIR, "..", "src");
|
||||
const SOURCE_ROOT = path.join(REPO_ROOT, "src");
|
||||
|
||||
/** The path to the built-in languages file. */
|
||||
export const BUILTIN_LANGUAGES_FILE = path.join(
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
# PR checks to exclude from required checks
|
||||
contains:
|
||||
- "https://"
|
||||
- "Update"
|
||||
- "ESLint"
|
||||
- "update"
|
||||
- "https://"
|
||||
- "test-setup-python-scripts"
|
||||
- "update"
|
||||
- "Update"
|
||||
is:
|
||||
- "Agent"
|
||||
- "check-expected-release-files"
|
||||
- "Cleanup artifacts"
|
||||
- "CodeQL"
|
||||
- "Dependabot"
|
||||
- "check-expected-release-files"
|
||||
- "Agent"
|
||||
- "Cleanup artifacts"
|
||||
- "Label PR with size"
|
||||
- "Post repo size comment"
|
||||
- "Prepare"
|
||||
- "Upload results"
|
||||
- "Label PR with size"
|
||||
|
||||
@@ -7,7 +7,13 @@ Tests for the sync-checks.ts script
|
||||
import * as assert from "node:assert/strict";
|
||||
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 = {
|
||||
apply: false,
|
||||
@@ -58,3 +64,46 @@ describe("removeExcluded", async () => {
|
||||
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. */
|
||||
export interface Options {
|
||||
/** The token to use to authenticate to the GitHub API. */
|
||||
token?: string;
|
||||
/** Whether to read the GitHub API token from standard input. */
|
||||
tokenStdin?: boolean;
|
||||
/** The git ref to use the checks for. */
|
||||
ref?: string;
|
||||
/** Whether to actually apply the changes or not. */
|
||||
@@ -31,6 +31,65 @@ const codeqlActionRepo = {
|
||||
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. */
|
||||
export interface Exclusions {
|
||||
/** 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> {
|
||||
const { values: options } = parseArgs({
|
||||
options: {
|
||||
// The token to use to authenticate to the API.
|
||||
token: {
|
||||
type: "string",
|
||||
// Read the token to use to authenticate to the API from standard input.
|
||||
"token-stdin": {
|
||||
type: "boolean",
|
||||
default: false,
|
||||
},
|
||||
// The git ref for which to retrieve the check runs.
|
||||
ref: {
|
||||
@@ -228,16 +288,16 @@ async function main(): Promise<void> {
|
||||
strict: true,
|
||||
});
|
||||
|
||||
if (options.token === undefined) {
|
||||
throw new Error("Missing --token");
|
||||
}
|
||||
const token = await resolveToken({
|
||||
tokenStdin: options["token-stdin"],
|
||||
});
|
||||
|
||||
console.info(
|
||||
`Oldest supported major version is: ${OLDEST_SUPPORTED_MAJOR_VERSION}`,
|
||||
);
|
||||
|
||||
// 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
|
||||
// for the main and release branches.
|
||||
|
||||
+42
-11
@@ -28,6 +28,24 @@ interface WorkflowInput {
|
||||
/** A partial mapping from known input names to input definitions. */
|
||||
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.
|
||||
*/
|
||||
@@ -36,8 +54,8 @@ interface Specification extends JobSpecification {
|
||||
inputs?: Record<string, WorkflowInput>;
|
||||
/** CodeQL bundle versions to test against. Defaults to `DEFAULT_TEST_VERSIONS`. */
|
||||
versions?: string[];
|
||||
/** Operating system prefixes used to select runner images (e.g. `["ubuntu", "macos"]`). */
|
||||
operatingSystems?: string[];
|
||||
/** Operating system prefixes, either as strings or with explicit runner image labels. */
|
||||
operatingSystems?: OperatingSystem[];
|
||||
/** Per-OS version overrides. If specified for an OS, only those versions are tested on that OS. */
|
||||
osCodeQlVersions?: Record<string, string[]>;
|
||||
/** 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.
|
||||
const defaultTestVersions = [
|
||||
// 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",
|
||||
// The last CodeQL release in the 2.20 series.
|
||||
"stable-v2.20.7",
|
||||
@@ -108,6 +122,10 @@ const defaultTestVersions = [
|
||||
"stable-v2.21.4",
|
||||
// The last CodeQL release in the 2.22 series.
|
||||
"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.
|
||||
"default",
|
||||
// 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"];
|
||||
|
||||
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.
|
||||
const allowedVersions =
|
||||
checkSpecification.osCodeQlVersions?.[operatingSystem];
|
||||
@@ -322,9 +349,13 @@ function generateJobMatrix(
|
||||
continue;
|
||||
}
|
||||
|
||||
const runnerImagesForOs = runnerImages.filter((image) =>
|
||||
image.startsWith(operatingSystem),
|
||||
);
|
||||
const runnerImagesForOs =
|
||||
typeof operatingSystemConfig === "string" ||
|
||||
operatingSystemConfig["runner-image"] === undefined
|
||||
? defaultRunnerImages.filter((image) =>
|
||||
image.startsWith(operatingSystem),
|
||||
)
|
||||
: [operatingSystemConfig["runner-image"]];
|
||||
|
||||
for (const runnerImage of runnerImagesForOs) {
|
||||
matrix.push({
|
||||
|
||||
@@ -43,6 +43,7 @@ predicate envVarRead(DataFlow::Node node, string envVar) {
|
||||
from DataFlow::Node read, string envVar
|
||||
where
|
||||
envVarRead(read, envVar) and
|
||||
read.getFile().getRelativePath().matches("src/%") and
|
||||
not read.getFile().getBaseName().matches("%.test.ts") and
|
||||
not isSafeForDefaultSetup(envVar)
|
||||
select read,
|
||||
|
||||
+43
-1
@@ -16,7 +16,12 @@ import {
|
||||
} from "./analyses";
|
||||
import { EnvVar } from "./environment";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import { createFeatures, RecordingLogger, setupTests } from "./testing-utils";
|
||||
import {
|
||||
createFeatures,
|
||||
RecordingLogger,
|
||||
setupBaseActionsVars,
|
||||
setupTests,
|
||||
} from "./testing-utils";
|
||||
import { AssessmentPayload } from "./upload-lib/types";
|
||||
import { ConfigurationError } from "./util";
|
||||
|
||||
@@ -72,6 +77,7 @@ test.serial(
|
||||
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();
|
||||
@@ -89,6 +95,40 @@ test.serial(
|
||||
},
|
||||
);
|
||||
|
||||
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(
|
||||
"getAnalysisKinds - includes `code-quality` when deprecated `quality-queries` input is used",
|
||||
async (t) => {
|
||||
@@ -133,6 +173,7 @@ for (let i = 0; i < analysisKinds.length; i++) {
|
||||
test.serial(
|
||||
`getAnalysisKinds - allows ${analysisKind} with ${otherAnalysis}`,
|
||||
async (t) => {
|
||||
setupBaseActionsVars();
|
||||
process.env[EnvVar.TEST_MODE] = "true";
|
||||
const features = createFeatures([]);
|
||||
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
||||
@@ -151,6 +192,7 @@ for (let i = 0; i < analysisKinds.length; i++) {
|
||||
test.serial(
|
||||
`getAnalysisKinds - throws if ${analysisKind} is enabled with ${otherAnalysis}`,
|
||||
async (t) => {
|
||||
setupBaseActionsVars();
|
||||
const features = createFeatures([]);
|
||||
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
||||
requiredInputStub
|
||||
|
||||
+39
-3
@@ -2,6 +2,7 @@ import {
|
||||
fixCodeQualityCategory,
|
||||
getOptionalInput,
|
||||
getRequiredInput,
|
||||
isDynamicWorkflow,
|
||||
} from "./actions-util";
|
||||
import { EnvVar } from "./environment";
|
||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||
@@ -65,6 +66,21 @@ export async function parseAnalysisKinds(
|
||||
// Used to avoid re-parsing the input after we have done it once.
|
||||
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.
|
||||
* This function will also use the deprecated `quality-queries` input as an indicator to enable `code-quality`.
|
||||
@@ -89,6 +105,26 @@ export async function getAnalysisKinds(
|
||||
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.
|
||||
const qualityQueriesInput = getOptionalInput("quality-queries");
|
||||
|
||||
@@ -130,10 +166,10 @@ export async function getAnalysisKinds(
|
||||
!(await features.getValue(Feature.AllowMultipleAnalysisKinds))
|
||||
) {
|
||||
logger.error(
|
||||
"The `analysis-kinds` input is experimental and for GitHub-internal use only. " +
|
||||
"Its behaviour may change at any time or be removed entirely. " +
|
||||
makeAnalysisKindUsageError(
|
||||
"Specifying multiple values as input is no longer supported. " +
|
||||
"Continuing with only `analysis-kinds: code-scanning`.",
|
||||
"Continuing with only `analysis-kinds: code-scanning`.",
|
||||
),
|
||||
);
|
||||
|
||||
// Only enable Code Scanning.
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
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);
|
||||
|
||||
// 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");
|
||||
|
||||
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",
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,83 +0,0 @@
|
||||
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);
|
||||
|
||||
// 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");
|
||||
|
||||
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",
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -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",
|
||||
),
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
+4
-4
@@ -1072,7 +1072,7 @@ 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) => {
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await stubCodeql();
|
||||
@@ -1080,7 +1080,7 @@ test.serial(
|
||||
sinon.stub(io, "which").resolves("");
|
||||
|
||||
process.env["CODEQL_ACTION_EXTRA_OPTIONS"] =
|
||||
'{ "database": { "init": ["--overwrite"] } }';
|
||||
'{ "database": { "init": ["--force-overwrite"] } }';
|
||||
|
||||
await codeqlObject.databaseInitCluster(
|
||||
stubConfig,
|
||||
@@ -1093,9 +1093,9 @@ test.serial(
|
||||
t.true(runnerConstructorStub.calledOnce);
|
||||
const args = runnerConstructorStub.firstCall.args[1] as string[];
|
||||
t.is(
|
||||
args.filter((option: string) => option === "--overwrite").length,
|
||||
args.filter((option: string) => option === "--force-overwrite").length,
|
||||
1,
|
||||
"--overwrite should only be passed once",
|
||||
"--force-overwrite should only be passed once",
|
||||
);
|
||||
|
||||
// Clean up
|
||||
|
||||
+13
-18
@@ -277,7 +277,7 @@ let cachedCodeQL: CodeQL | undefined = undefined;
|
||||
* The version flags below can be used to conditionally enable certain features
|
||||
* 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.
|
||||
@@ -592,13 +592,6 @@ async function getCodeQLForCmd(
|
||||
extraArgs.push(`--qlconfig-file=${qlconfigFile}`);
|
||||
}
|
||||
|
||||
const overwriteFlag = isSupportedToolsFeature(
|
||||
await this.getVersion(),
|
||||
ToolsFeature.ForceOverwrite,
|
||||
)
|
||||
? "--force-overwrite"
|
||||
: "--overwrite";
|
||||
|
||||
const overlayDatabaseMode = config.overlayDatabaseMode;
|
||||
if (overlayDatabaseMode === OverlayDatabaseMode.Overlay) {
|
||||
const overlayChangesFile = await writeOverlayChangesFile(
|
||||
@@ -625,7 +618,7 @@ async function getCodeQLForCmd(
|
||||
"init",
|
||||
...(overlayDatabaseMode === OverlayDatabaseMode.Overlay
|
||||
? []
|
||||
: [overwriteFlag]),
|
||||
: ["--force-overwrite"]),
|
||||
"--db-cluster",
|
||||
config.dbLocation,
|
||||
`--source-root=${sourceRoot}`,
|
||||
@@ -636,7 +629,14 @@ async function getCodeQLForCmd(
|
||||
// Some user configs specify `--no-calculate-baseline` as an additional
|
||||
// argument to `codeql database init`. Therefore ignore the baseline file
|
||||
// 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 },
|
||||
@@ -853,7 +853,7 @@ async function getCodeQLForCmd(
|
||||
"--sarif-group-rules-by-pack",
|
||||
"--sarif-include-query-help=always",
|
||||
"--sublanguage-file-coverage",
|
||||
...(await getJobRunUuidSarifOptions(this)),
|
||||
...(await getJobRunUuidSarifOptions()),
|
||||
...getExtraOptionsFromEnv(["database", "interpret-results"]),
|
||||
];
|
||||
if (sarifRunPropertyFlag !== undefined) {
|
||||
@@ -1283,13 +1283,8 @@ function applyAutobuildAzurePipelinesTimeoutFix() {
|
||||
].join(" ");
|
||||
}
|
||||
|
||||
async function getJobRunUuidSarifOptions(codeql: CodeQL) {
|
||||
async function getJobRunUuidSarifOptions() {
|
||||
const jobRunUuid = process.env[EnvVar.JOB_RUN_UUID];
|
||||
|
||||
return jobRunUuid &&
|
||||
(await codeql.supportsFeature(
|
||||
ToolsFeature.DatabaseInterpretResultsSupportsSarifRunProperty,
|
||||
))
|
||||
? [`--sarif-run-property=jobRunUuid=${jobRunUuid}`]
|
||||
: [];
|
||||
return jobRunUuid ? [`--sarif-run-property=jobRunUuid=${jobRunUuid}`] : [];
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"bundleVersion": "codeql-bundle-v2.25.4",
|
||||
"cliVersion": "2.25.4",
|
||||
"priorBundleVersion": "codeql-bundle-v2.25.3",
|
||||
"priorCliVersion": "2.25.3"
|
||||
"bundleVersion": "codeql-bundle-v2.25.5",
|
||||
"cliVersion": "2.25.5",
|
||||
"priorBundleVersion": "codeql-bundle-v2.25.4",
|
||||
"priorCliVersion": "2.25.4"
|
||||
}
|
||||
|
||||
@@ -75,10 +75,10 @@ const testShouldPerformDiffInformedAnalysis = makeMacro({
|
||||
[Feature.DiffInformedQueries]: testCase.featureEnabled,
|
||||
});
|
||||
|
||||
const getGitHubVersionStub = sinon
|
||||
sinon
|
||||
.stub(apiClient, "getGitHubVersion")
|
||||
.resolves(testCase.gitHubVersion);
|
||||
const getPullRequestBranchesStub = sinon
|
||||
sinon
|
||||
.stub(actionsUtil, "getPullRequestBranches")
|
||||
.returns(testCase.pullRequestBranches);
|
||||
|
||||
@@ -91,9 +91,6 @@ const testShouldPerformDiffInformedAnalysis = makeMacro({
|
||||
t.is(branches !== undefined, expectedResult);
|
||||
|
||||
delete process.env.CODEQL_ACTION_DIFF_INFORMED_QUERIES;
|
||||
|
||||
getGitHubVersionStub.restore();
|
||||
getPullRequestBranchesStub.restore();
|
||||
});
|
||||
},
|
||||
title: (title) => `getDiffInformedAnalysisBranches: ${title}`,
|
||||
|
||||
@@ -26,6 +26,9 @@ const DEFAULT_VERSION_FEATURE_FLAG_SUFFIX = "_enabled";
|
||||
|
||||
/**
|
||||
* 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";
|
||||
|
||||
|
||||
+77
-14
@@ -33,7 +33,6 @@ test.serial(
|
||||
|
||||
const actualRef = await gitUtils.getRef();
|
||||
t.deepEqual(actualRef, expectedRef);
|
||||
callback.restore();
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -54,7 +53,6 @@ test.serial(
|
||||
|
||||
const actualRef = await gitUtils.getRef();
|
||||
t.deepEqual(actualRef, expectedRef);
|
||||
callback.restore();
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -73,7 +71,6 @@ test.serial(
|
||||
|
||||
const actualRef = await gitUtils.getRef();
|
||||
t.deepEqual(actualRef, "refs/pull/1/head");
|
||||
callback.restore();
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -100,8 +97,6 @@ test.serial(
|
||||
|
||||
const actualRef = await gitUtils.getRef();
|
||||
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.",
|
||||
},
|
||||
);
|
||||
getAdditionalInputStub.restore();
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -188,7 +182,6 @@ test.serial(
|
||||
"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_REF"] = "refs/heads/main";
|
||||
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);
|
||||
t.deepEqual(result, undefined);
|
||||
t.deepEqual(0, infoStub.callCount);
|
||||
|
||||
infoStub.restore();
|
||||
});
|
||||
|
||||
test.serial(
|
||||
@@ -276,8 +266,6 @@ test.serial(
|
||||
"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.",
|
||||
);
|
||||
|
||||
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.",
|
||||
),
|
||||
);
|
||||
|
||||
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) => {
|
||||
t.deepEqual(gitUtils.decodeGitFilePath("foo"), "foo");
|
||||
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) => {
|
||||
await withTmpDir(async (tmpDir) => {
|
||||
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 (
|
||||
commitOid === mergeSha &&
|
||||
headOid.length === 40 &&
|
||||
baseOid.length === 40
|
||||
(headOid.length === 40 || headOid.length === 64) &&
|
||||
(baseOid.length === 40 || baseOid.length === 64)
|
||||
) {
|
||||
return baseOid;
|
||||
}
|
||||
@@ -296,7 +297,8 @@ export const getFileOidsUnderPath = async function (
|
||||
// 100644 4c51bc1d9e86cd86e01b0f340cb8ce095c33b283 0\tsrc/git-utils.test.ts
|
||||
// 100644 6b792ea543ce75d7a8a03df591e3c85311ecb64f 0\tsrc/git-utils.ts
|
||||
// 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")) {
|
||||
if (line) {
|
||||
const match = line.match(regex);
|
||||
|
||||
+16
-35
@@ -80,65 +80,46 @@ const testDownloadOverlayBaseDatabaseFromCache = makeMacro({
|
||||
await fs.promises.writeFile(baseDatabaseOidsFile, JSON.stringify({}));
|
||||
}
|
||||
|
||||
const stubs: sinon.SinonStub[] = [];
|
||||
sinon.stub(apiClient, "getAutomationID").resolves("test-automation-id/");
|
||||
|
||||
const getAutomationIDStub = sinon
|
||||
.stub(apiClient, "getAutomationID")
|
||||
.resolves("test-automation-id/");
|
||||
stubs.push(getAutomationIDStub);
|
||||
|
||||
const isInTestModeStub = sinon
|
||||
.stub(utils, "isInTestMode")
|
||||
.returns(testCase.isInTestMode);
|
||||
stubs.push(isInTestModeStub);
|
||||
sinon.stub(utils, "isInTestMode").returns(testCase.isInTestMode);
|
||||
|
||||
if (testCase.restoreCacheResult instanceof Error) {
|
||||
const restoreCacheStub = sinon
|
||||
sinon
|
||||
.stub(actionsCache, "restoreCache")
|
||||
.rejects(testCase.restoreCacheResult);
|
||||
stubs.push(restoreCacheStub);
|
||||
} else {
|
||||
const restoreCacheStub = sinon
|
||||
sinon
|
||||
.stub(actionsCache, "restoreCache")
|
||||
.resolves(testCase.restoreCacheResult);
|
||||
stubs.push(restoreCacheStub);
|
||||
}
|
||||
|
||||
const tryGetFolderBytesStub = sinon
|
||||
sinon
|
||||
.stub(utils, "tryGetFolderBytes")
|
||||
.resolves(testCase.tryGetFolderBytesSucceeds ? 1024 * 1024 : undefined);
|
||||
stubs.push(tryGetFolderBytesStub);
|
||||
|
||||
const codeql = mockCodeQLVersion(testCase.codeQLVersion);
|
||||
|
||||
if (testCase.resolveDatabaseOutput instanceof Error) {
|
||||
const resolveDatabaseStub = sinon
|
||||
sinon
|
||||
.stub(codeql, "resolveDatabase")
|
||||
.rejects(testCase.resolveDatabaseOutput);
|
||||
stubs.push(resolveDatabaseStub);
|
||||
} else {
|
||||
const resolveDatabaseStub = sinon
|
||||
sinon
|
||||
.stub(codeql, "resolveDatabase")
|
||||
.resolves(testCase.resolveDatabaseOutput);
|
||||
stubs.push(resolveDatabaseStub);
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await downloadOverlayBaseDatabaseFromCache(
|
||||
codeql,
|
||||
config,
|
||||
logger,
|
||||
);
|
||||
const result = await downloadOverlayBaseDatabaseFromCache(
|
||||
codeql,
|
||||
config,
|
||||
logger,
|
||||
);
|
||||
|
||||
if (expectDownloadSuccess) {
|
||||
t.truthy(result);
|
||||
} else {
|
||||
t.is(result, undefined);
|
||||
}
|
||||
} finally {
|
||||
for (const stub of stubs) {
|
||||
stub.restore();
|
||||
}
|
||||
if (expectDownloadSuccess) {
|
||||
t.truthy(result);
|
||||
} else {
|
||||
t.is(result, undefined);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
+16
-56
@@ -50,31 +50,21 @@ test.serial(
|
||||
"modified.js": "ddd444", // Changed OID
|
||||
"added.js": "eee555", // New file
|
||||
};
|
||||
const getFileOidsStubForOverlay = sinon
|
||||
.stub(gitUtils, "getFileOidsUnderPath")
|
||||
.resolves(currentOids);
|
||||
sinon.stub(gitUtils, "getFileOidsUnderPath").resolves(currentOids);
|
||||
|
||||
// Write the overlay changes file, which uses the mocked overlay OIDs
|
||||
// and the base database OIDs file
|
||||
const diffRangeFilePath = path.join(tempDir, "pr-diff-range.json");
|
||||
const getTempDirStub = sinon
|
||||
.stub(actionsUtil, "getTemporaryDirectory")
|
||||
.returns(tempDir);
|
||||
const getDiffRangesStub = sinon
|
||||
sinon.stub(actionsUtil, "getTemporaryDirectory").returns(tempDir);
|
||||
sinon
|
||||
.stub(actionsUtil, "getDiffRangesJsonFilePath")
|
||||
.returns(diffRangeFilePath);
|
||||
const getGitRootStub = sinon
|
||||
.stub(gitUtils, "getGitRoot")
|
||||
.resolves(sourceRoot);
|
||||
sinon.stub(gitUtils, "getGitRoot").resolves(sourceRoot);
|
||||
const changesFilePath = await writeOverlayChangesFile(
|
||||
config,
|
||||
sourceRoot,
|
||||
logger,
|
||||
);
|
||||
getFileOidsStubForOverlay.restore();
|
||||
getTempDirStub.restore();
|
||||
getDiffRangesStub.restore();
|
||||
getGitRootStub.restore();
|
||||
|
||||
const fileContent = await fs.promises.readFile(changesFilePath, "utf-8");
|
||||
const parsedContent = JSON.parse(fileContent) as { changes: string[] };
|
||||
@@ -128,20 +118,14 @@ test.serial(
|
||||
"modified.js": "ddd444", // Changed OID
|
||||
"reverted.js": "eee555", // Same OID as base -- not detected by OID comparison
|
||||
};
|
||||
const getFileOidsStubForOverlay = sinon
|
||||
.stub(gitUtils, "getFileOidsUnderPath")
|
||||
.resolves(currentOids);
|
||||
sinon.stub(gitUtils, "getFileOidsUnderPath").resolves(currentOids);
|
||||
|
||||
const diffRangeFilePath = path.join(tempDir, "pr-diff-range.json");
|
||||
const getTempDirStub = sinon
|
||||
.stub(actionsUtil, "getTemporaryDirectory")
|
||||
.returns(tempDir);
|
||||
const getDiffRangesStub = sinon
|
||||
sinon.stub(actionsUtil, "getTemporaryDirectory").returns(tempDir);
|
||||
sinon
|
||||
.stub(actionsUtil, "getDiffRangesJsonFilePath")
|
||||
.returns(diffRangeFilePath);
|
||||
const getGitRootStub = sinon
|
||||
.stub(gitUtils, "getGitRoot")
|
||||
.resolves(sourceRoot);
|
||||
sinon.stub(gitUtils, "getGitRoot").resolves(sourceRoot);
|
||||
|
||||
// Write a pr-diff-range.json file with diff ranges including
|
||||
// "reverted.js" (unchanged OIDs) and "modified.js" (already in OID changes)
|
||||
@@ -159,10 +143,6 @@ test.serial(
|
||||
sourceRoot,
|
||||
logger,
|
||||
);
|
||||
getFileOidsStubForOverlay.restore();
|
||||
getTempDirStub.restore();
|
||||
getDiffRangesStub.restore();
|
||||
getGitRootStub.restore();
|
||||
|
||||
const fileContent = await fs.promises.readFile(changesFilePath, "utf-8");
|
||||
const parsedContent = JSON.parse(fileContent) as { changes: string[] };
|
||||
@@ -208,20 +188,14 @@ test.serial(
|
||||
"unchanged.js": "aaa111",
|
||||
"modified.js": "ddd444",
|
||||
};
|
||||
const getFileOidsStubForOverlay = sinon
|
||||
.stub(gitUtils, "getFileOidsUnderPath")
|
||||
.resolves(currentOids);
|
||||
sinon.stub(gitUtils, "getFileOidsUnderPath").resolves(currentOids);
|
||||
|
||||
const diffRangeFilePath = path.join(tempDir, "pr-diff-range.json");
|
||||
const getTempDirStub = sinon
|
||||
.stub(actionsUtil, "getTemporaryDirectory")
|
||||
.returns(tempDir);
|
||||
const getDiffRangesStub = sinon
|
||||
sinon.stub(actionsUtil, "getTemporaryDirectory").returns(tempDir);
|
||||
sinon
|
||||
.stub(actionsUtil, "getDiffRangesJsonFilePath")
|
||||
.returns(diffRangeFilePath);
|
||||
const getGitRootStub = sinon
|
||||
.stub(gitUtils, "getGitRoot")
|
||||
.resolves(sourceRoot);
|
||||
sinon.stub(gitUtils, "getGitRoot").resolves(sourceRoot);
|
||||
|
||||
// No pr-diff-range.json file exists - should work the same as before
|
||||
const changesFilePath = await writeOverlayChangesFile(
|
||||
@@ -229,10 +203,6 @@ test.serial(
|
||||
sourceRoot,
|
||||
logger,
|
||||
);
|
||||
getFileOidsStubForOverlay.restore();
|
||||
getTempDirStub.restore();
|
||||
getDiffRangesStub.restore();
|
||||
getGitRootStub.restore();
|
||||
|
||||
const fileContent = await fs.promises.readFile(changesFilePath, "utf-8");
|
||||
const parsedContent = JSON.parse(fileContent) as { changes: string[] };
|
||||
@@ -281,21 +251,15 @@ test.serial(
|
||||
"app.js": "aaa111",
|
||||
"lib/util.js": "bbb222",
|
||||
};
|
||||
const getFileOidsStubForOverlay = sinon
|
||||
.stub(gitUtils, "getFileOidsUnderPath")
|
||||
.resolves(currentOids);
|
||||
sinon.stub(gitUtils, "getFileOidsUnderPath").resolves(currentOids);
|
||||
|
||||
const diffRangeFilePath = path.join(tempDir, "pr-diff-range.json");
|
||||
const getTempDirStub = sinon
|
||||
.stub(actionsUtil, "getTemporaryDirectory")
|
||||
.returns(tempDir);
|
||||
const getDiffRangesStub = sinon
|
||||
sinon.stub(actionsUtil, "getTemporaryDirectory").returns(tempDir);
|
||||
sinon
|
||||
.stub(actionsUtil, "getDiffRangesJsonFilePath")
|
||||
.returns(diffRangeFilePath);
|
||||
// getGitRoot returns the repo root (parent of sourceRoot)
|
||||
const getGitRootStub = sinon
|
||||
.stub(gitUtils, "getGitRoot")
|
||||
.resolves(repoRoot);
|
||||
sinon.stub(gitUtils, "getGitRoot").resolves(repoRoot);
|
||||
|
||||
// Diff ranges use repo-root-relative paths (as returned by the GitHub compare API)
|
||||
await fs.promises.writeFile(
|
||||
@@ -312,10 +276,6 @@ test.serial(
|
||||
sourceRoot,
|
||||
logger,
|
||||
);
|
||||
getFileOidsStubForOverlay.restore();
|
||||
getTempDirStub.restore();
|
||||
getDiffRangesStub.restore();
|
||||
getGitRootStub.restore();
|
||||
|
||||
const fileContent = await fs.promises.readFile(changesFilePath, "utf-8");
|
||||
const parsedContent = JSON.parse(fileContent) as { changes: string[] };
|
||||
|
||||
+27
-7
@@ -188,17 +188,37 @@ export const DEFAULT_ACTIONS_VARS = {
|
||||
RUNNER_OS: "Linux",
|
||||
} as const satisfies Record<string, string>;
|
||||
|
||||
// Sets environment variables that make using some libraries designed for
|
||||
// use only on actions safe to use outside of actions.
|
||||
export function setupActionsVars(
|
||||
tempDir: string,
|
||||
toolsDir: string,
|
||||
overrides?: Partial<Record<keyof typeof DEFAULT_ACTIONS_VARS, string>>,
|
||||
) {
|
||||
/** Partial mappings from GitHub Actions environment variables to values. */
|
||||
export type ActionVarOverrides = Partial<
|
||||
Record<keyof typeof DEFAULT_ACTIONS_VARS, string>
|
||||
>;
|
||||
|
||||
/**
|
||||
* Sets environment variables that are always available on GitHub Actions,
|
||||
* excluding some that are expected to be set to paths. See `setupActionsVars`.
|
||||
*
|
||||
* @param overrides Overrides for the defaults.
|
||||
*/
|
||||
export function setupBaseActionsVars(overrides?: ActionVarOverrides) {
|
||||
const vars = { ...DEFAULT_ACTIONS_VARS, ...overrides };
|
||||
for (const [key, value] of Object.entries(vars)) {
|
||||
process.env[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets environment variables that are always available on GitHub Actions.
|
||||
*
|
||||
* @param tempDir A value for `RUNNER_TEMP` and `GITHUB_WORKSPACE`.
|
||||
* @param toolsDir A value for `RUNNER_TOOL_CACHE`.
|
||||
* @param overrides Overrides for the defaults.
|
||||
*/
|
||||
export function setupActionsVars(
|
||||
tempDir: string,
|
||||
toolsDir: string,
|
||||
overrides?: ActionVarOverrides,
|
||||
) {
|
||||
setupBaseActionsVars(overrides);
|
||||
process.env["RUNNER_TEMP"] = tempDir;
|
||||
process.env["RUNNER_TOOL_CACHE"] = toolsDir;
|
||||
process.env["GITHUB_WORKSPACE"] = tempDir;
|
||||
|
||||
@@ -6,9 +6,13 @@ import { ToolsFeature, isSupportedToolsFeature } from "./tools-features";
|
||||
test("isSupportedToolsFeature", async (t) => {
|
||||
const versionInfo = makeVersionInfo("1.0.0");
|
||||
|
||||
t.false(isSupportedToolsFeature(versionInfo, ToolsFeature.ForceOverwrite));
|
||||
t.false(
|
||||
isSupportedToolsFeature(versionInfo, ToolsFeature.BundleSupportsOverlay),
|
||||
);
|
||||
|
||||
versionInfo.features = { forceOverwrite: true };
|
||||
versionInfo.features = { bundleSupportsOverlay: true };
|
||||
|
||||
t.true(isSupportedToolsFeature(versionInfo, ToolsFeature.ForceOverwrite));
|
||||
t.true(
|
||||
isSupportedToolsFeature(versionInfo, ToolsFeature.BundleSupportsOverlay),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -6,8 +6,6 @@ export enum ToolsFeature {
|
||||
BuiltinExtractorsSpecifyDefaultQueries = "builtinExtractorsSpecifyDefaultQueries",
|
||||
BundleSupportsIncludeOption = "bundleSupportsIncludeOption",
|
||||
BundleSupportsOverlay = "bundleSupportsOverlay",
|
||||
DatabaseInterpretResultsSupportsSarifRunProperty = "databaseInterpretResultsSupportsSarifRunProperty",
|
||||
ForceOverwrite = "forceOverwrite",
|
||||
IndirectTracingSupportsStaticBinaries = "indirectTracingSupportsStaticBinaries",
|
||||
SuppressesMissingFileBaselineWarning = "suppressesMissingFileBaselineWarning",
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = require("./entry-points").__UPLOAD_LIB_EXPORT__;
|
||||
+1
-4
@@ -418,9 +418,7 @@ for (const [
|
||||
`checkActionVersion ${reportErrorDescription} for ${versionsDescription}`,
|
||||
async (t) => {
|
||||
const warningSpy = sinon.spy(core, "warning");
|
||||
const versionStub = sinon
|
||||
.stub(api, "getGitHubVersion")
|
||||
.resolves(githubVersion);
|
||||
sinon.stub(api, "getGitHubVersion").resolves(githubVersion);
|
||||
|
||||
// call checkActionVersion twice and assert below that warning is reported only once
|
||||
util.checkActionVersion(version, await api.getGitHubVersion());
|
||||
@@ -437,7 +435,6 @@ for (const [
|
||||
} else {
|
||||
t.false(warningSpy.called);
|
||||
}
|
||||
versionStub.restore();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user