Skip to content
Open
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
11 changes: 11 additions & 0 deletions .github/workflows/script/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"lib": ["esnext"],
"rootDir": "../../..",
"sourceMap": false,
"noEmit": true,
},
"include": ["./*.ts"],
"exclude": ["node_modules"]
}
88 changes: 88 additions & 0 deletions .github/workflows/script/update-builtin-languages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/usr/bin/env npx tsx
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shebang #!/usr/bin/env npx tsx is not portable: most env implementations can’t take multiple arguments from a shebang line (without -S), so running this script directly would fail. Either remove the shebang (since the workflow already runs it via npx tsx ...) or switch to an env -S style shebang.

Suggested change
#!/usr/bin/env npx tsx

Copilot uses AI. Check for mistakes.

/**
* Updates src/languages/builtin.json by querying the CodeQL CLI for:
* - Languages that have default queries (via codeql-extractor.yml)
* - Language aliases (via `codeql resolve languages --format=betterjson --extractor-include-aliases`)
*
* Usage:
* npx tsx .github/workflows/script/update-builtin-languages.ts [path-to-codeql]
*
* If no path is given, falls back to "codeql".
*/

import { execFileSync } from "node:child_process";
import * as fs from "node:fs";
import * as path from "node:path";

import * as yaml from "yaml";

const codeqlPath = process.argv[2] || "codeql";

// Step 1: Resolve all language extractor directories.
const resolveJson: Record<string, string[]> = JSON.parse(
execFileSync(
codeqlPath,
["resolve", "languages", "--format=json"],
{ encoding: "utf8" },
),
);

// Step 2: For each language, read codeql-extractor.yml and check default_queries.
const languages: string[] = [];

for (const [language, dirs] of Object.entries(resolveJson)) {
const extractorDir = dirs[0];
const extractorYmlPath = path.join(extractorDir, "codeql-extractor.yml");

if (!fs.existsSync(extractorYmlPath)) {
throw new Error(`Extractor YAML not found for language '${language}' at expected path: ${extractorYmlPath}`);
}

const extractorYml = yaml.parse(fs.readFileSync(extractorYmlPath, "utf8"));
const defaultQueries: unknown[] | undefined = extractorYml.default_queries;

if (Array.isArray(defaultQueries) && defaultQueries.length > 0) {
console.log(` ✅ ${language}: included (default_queries: ${JSON.stringify(defaultQueries)})`);
languages.push(language);
} else {
console.log(` ❌ ${language}: excluded (no default queries)`);
}
}

languages.sort();

// Step 3: Resolve aliases, filtered to only those targeting included languages.
const betterjsonOutput = JSON.parse(
execFileSync(
codeqlPath,
["resolve", "languages", "--format=betterjson", "--extractor-include-aliases"],
{ encoding: "utf8" },
),
);

const languageSet = new Set(languages);
const aliases: Record<string, string> = Object.fromEntries(
Object.entries((betterjsonOutput.aliases ?? {}) as Record<string, string>)
.filter(([, target]) => languageSet.has(target))
.sort(([a], [b]) => a.localeCompare(b)),
);

// Step 4: Write builtin.json.
const outputPath = path.join(
__dirname,
"..",
"..",
"..",
"src",
"languages",
"builtin.json",
);

const content = JSON.stringify({ languages, aliases }, null, 2) + "\n";
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
fs.writeFileSync(outputPath, content);

console.log(`\nWrote ${outputPath}`);
console.log(` Languages: ${languages.join(", ")}`);
console.log(` Aliases: ${Object.keys(aliases).join(", ")}`);
7 changes: 2 additions & 5 deletions .github/workflows/update-bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,10 @@ jobs:
with:
tools: https://github.com/github/codeql-action/releases/download/${{ github.event.release.tag_name }}/codeql-bundle-linux64.tar.gz

- name: Update language aliases
- name: Update built-in languages
run: npx tsx .github/workflows/script/update-builtin-languages.ts "$CODEQL_PATH"
env:
CODEQL_PATH: ${{ steps.setup-codeql.outputs.codeql-path }}
run: |
"$CODEQL_PATH" resolve languages --format=betterjson --extractor-include-aliases \
| jq -S '.aliases // {}' \
> src/known-language-aliases.json

- name: Bump Action minor version if new CodeQL minor version series
id: bump-action-version
Expand Down
30 changes: 30 additions & 0 deletions lib/analyze-action-post.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 35 additions & 1 deletion lib/analyze-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions lib/autobuild-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions lib/init-action-post.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 43 additions & 15 deletions lib/init-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions lib/resolve-environment-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading