Skip to content

Commit 754eeb2

Browse files
authoredOct 27, 2022
Update CodeQL workflow and configuration, fix found bugs (#51263)
1 parent d8aad26 commit 754eeb2

5 files changed

+64
-50
lines changed
 
+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
name : CodeQL Configuration
22

33
paths:
4-
- './src'
4+
- src
5+
- scripts
6+
- Gulpfile.mjs
7+
paths-ignore:
8+
- src/lib

‎.github/workflows/codeql.yml

+52-38
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,64 @@
1-
name: "Code scanning - action"
1+
name: "Code Scanning - Action"
22

33
on:
44
push:
5+
branches:
6+
- main
7+
- release-*
58
pull_request:
9+
branches:
10+
- main
11+
- release-*
612
schedule:
7-
- cron: '0 19 * * 0'
13+
# ┌───────────── minute (0 - 59)
14+
# │ ┌───────────── hour (0 - 23)
15+
# │ │ ┌───────────── day of the month (1 - 31)
16+
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
17+
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
18+
# │ │ │ │ │
19+
# │ │ │ │ │
20+
# │ │ │ │ │
21+
# * * * * *
22+
- cron: '30 1 * * 0'
823

924
jobs:
1025
CodeQL-Build:
11-
12-
# CodeQL runs on ubuntu-latest and windows-latest
26+
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
1327
runs-on: ubuntu-latest
1428
if: github.repository == 'microsoft/TypeScript'
1529

30+
permissions:
31+
# required for all workflows
32+
security-events: write
33+
1634
steps:
17-
- name: Checkout repository
18-
uses: actions/checkout@v3
19-
with:
20-
# We must fetch at least the immediate parents so that if this is
21-
# a pull request then we can checkout the head.
22-
fetch-depth: 2
23-
24-
# Initializes the CodeQL tools for scanning.
25-
- name: Initialize CodeQL
26-
uses: github/codeql-action/init@v2
27-
with:
28-
config-file: ./.github/codeql/codeql-configuration.yml
29-
# Override language selection by uncommenting this and choosing your languages
30-
# with:
31-
# languages: go, javascript, csharp, python, cpp, java
32-
33-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
34-
# If this step fails, then you should remove it and run the build manually (see below)
35-
- name: Autobuild
36-
uses: github/codeql-action/autobuild@v2
37-
38-
# ℹ️ Command-line programs to run using the OS shell.
39-
# 📚 https://git.io/JvXDl
40-
41-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
42-
# and modify them (or add more) to build your code if your project
43-
# uses a compiled language
44-
45-
#- run: |
46-
# make bootstrap
47-
# make release
48-
49-
- name: Perform CodeQL Analysis
50-
uses: github/codeql-action/analyze@v2
35+
- name: Checkout repository
36+
uses: actions/checkout@v3
37+
38+
# Initializes the CodeQL tools for scanning.
39+
- name: Initialize CodeQL
40+
uses: github/codeql-action/init@v2
41+
with:
42+
config-file: ./.github/codeql/codeql-configuration.yml
43+
# Override language selection by uncommenting this and choosing your languages
44+
# with:
45+
# languages: go, javascript, csharp, python, cpp, java
46+
47+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
48+
# If this step fails, then you should remove it and run the build manually (see below).
49+
- name: Autobuild
50+
uses: github/codeql-action/autobuild@v2
51+
52+
# ℹ️ Command-line programs to run using the OS shell.
53+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
54+
55+
# ✏️ If the Autobuild fails above, remove it and uncomment the following
56+
# three lines and modify them (or add more) to build your code if your
57+
# project uses a compiled language
58+
59+
#- run: |
60+
# make bootstrap
61+
# make release
62+
63+
- name: Perform CodeQL Analysis
64+
uses: github/codeql-action/analyze@v2

‎scripts/generateLocalizedDiagnosticMessages.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ function main() {
171171
*/
172172
function getItemXML(key, value) {
173173
// escape entrt value
174-
value = value.replace(/]/, "]5D;");
174+
value = value.replace(/]/g, "]5D;");
175175

176176
return `
177177
<Item ItemId=";${key}" ItemType="0" PsrId="306" Leaf="true">

‎scripts/importDefinitelyTypedTests.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ function importDefinitelyTypedTests(tscPath, rwcTestPath, definitelyTypedRoot) {
157157

158158
if (testFiles.length === 0) {
159159
// no test files but multiple d.ts's, e.g. winjs
160-
const regexp = new RegExp(d + "(([-][0-9])|([\.]d[\.]ts))");
160+
const regexp = new RegExp(d + "(([-][0-9])|(\\.d\\.ts))");
161161
if (tsFiles.length > 1 && tsFiles.every(t => filePathEndsWith(t, ".d.ts") && regexp.test(t))) {
162162
for (const fileName of tsFiles) {
163163
importDefinitelyTypedTest(tscPath, rwcTestPath, path.basename(fileName, ".d.ts"), [fileName], paramFile);

‎scripts/processDiagnosticMessages.mjs

+5-9
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,15 @@ function buildInfoFileOutput(messageTable, inputFilePathRel, thisFilePathRel) {
104104
* @returns {string}
105105
*/
106106
function buildDiagnosticMessageOutput(messageTable) {
107-
let result = "{";
107+
/** @type {Record<string, string>} */
108+
const result = {};
109+
108110
messageTable.forEach(({ code }, name) => {
109111
const propName = convertPropertyName(name);
110-
result += `\r\n "${createKey(propName, code)}" : "${name.replace(/[\"]/g, '\\"')}",`;
112+
result[createKey(propName, code)] = name;
111113
});
112114

113-
// Shave trailing comma, then add newline and ending brace
114-
result = result.slice(0, result.length - 1) + "\r\n}";
115-
116-
// Assert that we generated valid JSON
117-
JSON.parse(result);
118-
119-
return result;
115+
return JSON.stringify(result, undefined, 2).replace(/\r?\n/g, "\r\n");
120116
}
121117

122118
/**

0 commit comments

Comments
 (0)
Please sign in to comment.