Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/bug-debugger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Actions
run: cd ./.github/actions && npm install --production && cd ../..
run: cd ./.github/actions && npm ci --omit=dev && cd ../..
- name: Add Comment
uses: ./.github/actions/AddComment
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/by-design-closer-debugger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Actions
run: cd ./.github/actions && npm install --production && cd ../..
run: cd ./.github/actions && npm ci --omit=dev && cd ../..
- name: Stale Closer
uses: ./.github/actions/StaleCloser
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/by-design-closer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Actions
run: cd ./.github/actions && npm install --production && cd ../..
run: cd ./.github/actions && npm ci --omit=dev && cd ../..
- name: Stale Closer
uses: ./.github/actions/StaleCloser
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/duplicate-closer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Actions
run: cd ./.github/actions && npm install --production && cd ../..
run: cd ./.github/actions && npm ci --omit=dev && cd ../..
- name: Stale Closer
uses: ./.github/actions/StaleCloser
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/enhancement-closer-no-milestone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Actions
run: cd ./.github/actions && npm install --production && cd ../..
run: cd ./.github/actions && npm ci --omit=dev && cd ../..
- name: Stale Closer
uses: ./.github/actions/StaleCloser
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/enhancement-closer-triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Actions
run: cd ./.github/actions && npm install --production && cd ../..
run: cd ./.github/actions && npm ci --omit=dev && cd ../..
- name: Stale Closer
uses: ./.github/actions/StaleCloser
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/enhancement-reopener.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Actions
run: cd ./.github/actions && npm install --production && cd ../..
run: cd ./.github/actions && npm ci --omit=dev && cd ../..
- name: Run Reopener
uses: ./.github/actions/Reopener
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/external-closer-debugger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Actions
run: cd ./.github/actions && npm install --production && cd ../..
run: cd ./.github/actions && npm ci --omit=dev && cd ../..
- name: Stale Closer
uses: ./.github/actions/StaleCloser
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Actions
run: cd ./.github/actions && npm install --production && cd ../..
run: cd ./.github/actions && npm ci --omit=dev && cd ../..
- name: Stale Closer
uses: ./.github/actions/StaleCloser
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/feature-request-closer-triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Actions
run: cd ./.github/actions && npm install --production && cd ../..
run: cd ./.github/actions && npm ci --omit=dev && cd ../..
- name: Stale Closer
uses: ./.github/actions/StaleCloser
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/feature-request-debugger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Actions
run: cd ./.github/actions && npm install --production && cd ../..
run: cd ./.github/actions && npm ci --omit=dev && cd ../..
- name: Add Comment
uses: ./.github/actions/AddComment
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/feature-request-reopener.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Actions
run: cd ./.github/actions && npm install --production && cd ../..
run: cd ./.github/actions && npm ci --omit=dev && cd ../..
- name: Run Reopener
uses: ./.github/actions/Reopener
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/investigate-closer-debugger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Actions
run: cd ./.github/actions && npm install --production && cd ../..
run: cd ./.github/actions && npm ci --omit=dev && cd ../..
- name: Stale Closer
uses: ./.github/actions/StaleCloser
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Actions
run: cd ./.github/actions && npm install --production && cd ../..
run: cd ./.github/actions && npm ci --omit=dev && cd ../..
- name: Stale Closer
uses: ./.github/actions/StaleCloser
with:
Expand Down
21 changes: 20 additions & 1 deletion .github/workflows/job-compile-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,27 @@ jobs:
run: yarn test-yarn-lock && yarn verify-yarn-lock
working-directory: Extension

- name: Validate LLDB-MI component manifest
run: yarn test-lldb-mi-component-manifest && yarn verify-lldb-mi-component-manifest
working-directory: Extension

- name: Install Dependencies
run: yarn install ${{ inputs.yarn-args }}
shell: bash
env:
YARN_ARGS: ${{ inputs.yarn-args }}
run: |
read -r -a yarn_args <<< "$YARN_ARGS"
for attempt in 1 2 3; do
if yarn install "${yarn_args[@]}"; then
exit 0
fi
if (( attempt == 3 )); then
exit 1
fi
delay=$((attempt * 15))
printf 'yarn install failed; retrying in %d seconds.\n' "$delay" >&2
sleep "$delay"
done
working-directory: Extension

- name: Install gdb (linux)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/locker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Actions
run: cd ./.github/actions && npm install --production && cd ../..
run: cd ./.github/actions && npm ci --omit=dev && cd ../..
- name: Run Locker
uses: ./.github/actions/Locker
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/more-info-needed-closer-debugger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Actions
run: cd ./.github/actions && npm install --production && cd ../..
run: cd ./.github/actions && npm ci --omit=dev && cd ../..
- name: Stale Closer
uses: ./.github/actions/StaleCloser
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/more-info-needed-closer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Actions
run: cd ./.github/actions && npm install --production && cd ../..
run: cd ./.github/actions && npm ci --omit=dev && cd ../..
- name: Stale Closer
uses: ./.github/actions/StaleCloser
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/question-closer-debugger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Actions
run: cd ./.github/actions && npm install --production && cd ../..
run: cd ./.github/actions && npm ci --omit=dev && cd ../..
- name: Stale Closer
uses: ./.github/actions/StaleCloser
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/question-closer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Actions
run: cd ./.github/actions && npm install --production && cd ../..
run: cd ./.github/actions && npm ci --omit=dev && cd ../..
- name: Stale Closer
uses: ./.github/actions/StaleCloser
with:
Expand Down
1 change: 1 addition & 0 deletions Extension/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ bin/scout_driver
bin/process_wait_test_helper
bin/unittests
bin/vcpkgsrvtest
bin/xobjgen
bin/*.dll
bin/.vs

Expand Down
113 changes: 113 additions & 0 deletions Extension/.scripts/verifyLldbMiComponentManifest.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import { fileURLToPath, pathToFileURL, URL } from 'node:url';

const componentParameters = [
{ repository: 'llvm_repo', commit: 'llvm_commit' },
{ repository: 'lldb_mi_repo', commit: 'lldb_mi_commit' }
];

function parseScalarParameter(template, parameterName) {
const matches = [...template.matchAll(new RegExp(`^ ${parameterName}:\\s*(.*?)\\s*$`, 'gm'))];
if (matches.length !== 1) {
throw new Error(`Expected ${parameterName} to appear exactly once in the LLDB-MI template.`);
}

const serializedValue = matches[0][1];
if (serializedValue.startsWith('"')) {
const value = JSON.parse(serializedValue);
if (typeof value !== 'string') {
throw new Error(`Expected ${parameterName} to be a string.`);
}
return value;
}
if (serializedValue.startsWith("'")) {
if (!serializedValue.endsWith("'")) {
throw new Error(`Expected ${parameterName} to be a valid scalar value.`);
}
return serializedValue.slice(1, -1).replaceAll("''", "'");
}
if (!serializedValue || /\s/.test(serializedValue)) {
throw new Error(`Expected ${parameterName} to be a non-empty scalar value.`);
}
return serializedValue;
}

function normalizeRepositoryUrl(repositoryUrl) {
const normalizedUrl = new URL(repositoryUrl);
normalizedUrl.hash = '';
normalizedUrl.search = '';
normalizedUrl.pathname = normalizedUrl.pathname.replace(/\/+$/, '').replace(/\.git$/i, '');
return normalizedUrl.href.replace(/\/$/, '');
}

function getGitRegistrations(manifest) {
if (!Array.isArray(manifest.registrations)) {
throw new Error('Component manifest does not contain a registrations array.');
}

const registrations = new Map();
for (const registration of manifest.registrations) {
const component = registration?.component;
if (component?.type !== 'git') {
continue;
}

const repositoryUrl = component.git?.repositoryUrl;
const commitHash = component.git?.commitHash;
if (typeof repositoryUrl !== 'string' || typeof commitHash !== 'string') {
throw new Error('Git component registrations require repositoryUrl and commitHash strings.');
}

const normalizedRepositoryUrl = normalizeRepositoryUrl(repositoryUrl);
if (registrations.has(normalizedRepositoryUrl)) {
throw new Error(`Component manifest contains duplicate registrations for ${repositoryUrl}.`);
}
registrations.set(normalizedRepositoryUrl, { repositoryUrl, commitHash });
}
return registrations;
}

function validateLldbMiComponentManifest(template, manifest) {
const registrations = getGitRegistrations(manifest);
const errors = [];

for (const parameters of componentParameters) {
const repositoryUrl = parseScalarParameter(template, parameters.repository);
const commitHash = parseScalarParameter(template, parameters.commit);
if (!/^[0-9a-f]{40}$/.test(commitHash)) {
errors.push(`${parameters.commit} must be a 40-character lowercase Git commit hash.`);
continue;
}

const registration = registrations.get(normalizeRepositoryUrl(repositoryUrl));
if (!registration) {
errors.push(`${parameters.repository} references ${repositoryUrl}, which is missing from the component manifest.`);
} else if (registration.commitHash !== commitHash) {
errors.push(`${parameters.commit} is ${commitHash}, but the component manifest registers ${registration.commitHash} for ${registration.repositoryUrl}.`);
}
}

if (errors.length > 0) {
throw new Error(`LLDB-MI component manifest validation failed:\n${errors.map(error => ` ${error}`).join('\n')}`);
}
}

const invokedUrl = process.argv[1] ? pathToFileURL(path.resolve(process.argv[1])).href : undefined;
if (invokedUrl === import.meta.url) {
const extensionRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const manifestPath = process.argv[2] ?? path.join(extensionRoot, 'cgmanifest.json');
const templatePath = process.argv[3] ?? path.join(extensionRoot, '..', 'Build', 'lldb-mi', 'lldb-mi.template.yml');

try {
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
const template = fs.readFileSync(templatePath, 'utf8');
validateLldbMiComponentManifest(template, manifest);
} catch (error) {
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
process.exitCode = 1;
}
}

export { normalizeRepositoryUrl, parseScalarParameter, validateLldbMiComponentManifest };
65 changes: 65 additions & 0 deletions Extension/.scripts/verifyLldbMiComponentManifest.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { parseScalarParameter, validateLldbMiComponentManifest } from './verifyLldbMiComponentManifest.mjs';

const template = `parameters:
llvm_repo: https://github.com/llvm/llvm-project.git
llvm_commit: 0d44201451f03ba907cdb268ddddfc3fa38a0ebd
lldb_mi_repo: https://github.com/lldb-tools/lldb-mi.git
lldb_mi_commit: 2388bd74133bc21eac59b2e2bf97f2a30770a315

jobs:
`;

function createManifest(llvmCommit = '0d44201451f03ba907cdb268ddddfc3fa38a0ebd') {
return {
registrations: [
{
component: {
type: 'git',
git: {
repositoryUrl: 'https://github.com/lldb-tools/lldb-mi',
commitHash: '2388bd74133bc21eac59b2e2bf97f2a30770a315'
}
}
},
{
component: {
type: 'git',
git: {
repositoryUrl: 'https://github.com/llvm/llvm-project',
commitHash: llvmCommit
}
}
}
]
};
}

test('accepts matching build and component manifest pins', () => {
assert.doesNotThrow(() => validateLldbMiComponentManifest(template, createManifest()));
});

test('reports a missing repository registration', () => {
const manifest = createManifest();
manifest.registrations.pop();

assert.throws(
() => validateLldbMiComponentManifest(template, manifest),
/llvm_repo references https:\/\/github\.com\/llvm\/llvm-project\.git, which is missing/
);
});

test('reports a stale registered commit', () => {
assert.throws(
() => validateLldbMiComponentManifest(template, createManifest('1111111111111111111111111111111111111111')),
/llvm_commit is 0d44201451f03ba907cdb268ddddfc3fa38a0ebd, but the component manifest registers 1111111111111111111111111111111111111111/
);
});

test('requires each build parameter exactly once', () => {
assert.throws(
() => parseScalarParameter(`${template} llvm_repo: https://example.com/duplicate.git\n`, 'llvm_repo'),
/Expected llvm_repo to appear exactly once/
);
});
Loading
Loading