Skip to content

Commit 8f1b0c7

Browse files
committed
Store all built-in languages
While we want the CodeQL Action to work with third-party language support, having a list of all built-in languages can help us create better type-level checks to ensure that we don't miss things that we want to customize for each of our built-in languages.
1 parent a26cb68 commit 8f1b0c7

21 files changed

+1443
-1066
lines changed

.github/workflows/update-bundle.yml

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,58 @@ jobs:
6363
with:
6464
tools: https://github.com/github/codeql-action/releases/download/${{ github.event.release.tag_name }}/codeql-bundle-linux64.tar.gz
6565

66-
- name: Update language aliases
66+
- name: Update known languages
67+
uses: actions/github-script@v8
6768
env:
6869
CODEQL_PATH: ${{ steps.setup-codeql.outputs.codeql-path }}
69-
run: |
70-
"$CODEQL_PATH" resolve languages --format=betterjson --extractor-include-aliases \
71-
| jq -S '.aliases // {}' \
72-
> src/known-language-aliases.json
70+
with:
71+
script: |
72+
const { execFileSync } = require("node:child_process");
73+
const fs = require("node:fs");
74+
const path = require("node:path");
75+
76+
const knownLanguages = [
77+
"actions",
78+
"cpp",
79+
"csharp",
80+
"go",
81+
"java",
82+
"javascript",
83+
"python",
84+
"ruby",
85+
"rust",
86+
"swift",
87+
];
88+
89+
const resolveOutput = JSON.parse(
90+
execFileSync(
91+
process.env.CODEQL_PATH,
92+
[
93+
"resolve",
94+
"languages",
95+
"--format=betterjson",
96+
"--extractor-include-aliases",
97+
],
98+
{ encoding: "utf8" },
99+
),
100+
);
101+
102+
const aliases = Object.fromEntries(
103+
Object.entries(resolveOutput.aliases ?? {})
104+
.filter(([, target]) => knownLanguages.includes(target))
105+
.sort(([left], [right]) => left.localeCompare(right)),
106+
);
107+
108+
const outputDir = path.join(
109+
process.env.GITHUB_WORKSPACE,
110+
"src",
111+
"languages",
112+
);
113+
fs.mkdirSync(outputDir, { recursive: true });
114+
fs.writeFileSync(
115+
path.join(outputDir, "builtin.json"),
116+
`${JSON.stringify({ languages: knownLanguages, aliases }, null, 2)}\n`,
117+
);
73118
74119
- name: Bump Action minor version if new CodeQL minor version series
75120
id: bump-action-version

lib/analyze-action-post.js

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/analyze-action.js

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/autobuild-action.js

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action-post.js

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js

Lines changed: 29 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/resolve-environment-action.js

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/setup-codeql-action.js

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/start-proxy-action-post.js

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)