Skip to content

Commit 6a565f4

Browse files
chore: update global workflows
1 parent 68a850a commit 6a565f4

File tree

1 file changed

+36
-49
lines changed

1 file changed

+36
-49
lines changed

.github/workflows/codeql.yml

Lines changed: 36 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,23 @@ jobs:
3939
uses: actions/github-script@v7
4040
with:
4141
script: |
42-
// CodeQL supports ['cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift']
43-
// Use only 'java' to analyze code written in Java, Kotlin or both
44-
// Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
42+
// CodeQL supports the following:
43+
// ['actions', 'c', 'cpp', 'csharp', 'go', 'java', 'javascript', 'kotlin', 'python', 'ruby', 'swift']
44+
4545
// Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
46-
const supported_languages = ['cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift']
46+
const supported_languages = [
47+
'cpp',
48+
'csharp',
49+
'go',
50+
'java',
51+
'javascript',
52+
'python',
53+
'ruby',
54+
'swift',
55+
]
4756
4857
const remap_languages = {
58+
'c': 'cpp',
4959
'c++': 'cpp',
5060
'c#': 'csharp',
5161
'kotlin': 'java',
@@ -73,7 +83,8 @@ jobs:
7383
"category": "/language:actions",
7484
"language": "actions",
7585
"name": "actions",
76-
"os": "ubuntu-latest"
86+
"os": "ubuntu-latest",
87+
"build-mode": "none",
7788
});
7889
}
7990
@@ -94,25 +105,37 @@ jobs:
94105
let osList = ['ubuntu-latest'];
95106
if (normalizedKey === 'swift') {
96107
osList = ['macos-latest'];
97-
} else if (normalizedKey === 'cpp') {
98-
osList = ['macos-latest', 'ubuntu-latest', 'windows-latest'];
99108
}
100109
for (let os of osList) {
101110
// set name for matrix
102111
let name = osList.length === 1 ? normalizedKey : `${normalizedKey}, ${os}`
103112
104113
// set category for matrix
105114
let category = `/language:${normalizedKey}`
106-
if (normalizedKey === 'cpp') {
107-
category = `/language:cpp-${os.split('-')[0]}`
115+
let build_mode = 'none';
116+
117+
// Set build mode based on language
118+
switch (normalizedKey) {
119+
case 'csharp':
120+
build_mode = 'autobuild'
121+
break
122+
case 'go':
123+
build_mode = 'autobuild'
124+
break
125+
case 'java':
126+
build_mode = 'autobuild'
127+
break
128+
default:
129+
build_mode = 'none'
108130
}
109131
110132
// add to matrix
111133
matrix['include'].push({
112134
"category": category,
113135
"language": normalizedKey,
114136
"name": name,
115-
"os": os
137+
"os": os,
138+
"build-mode": build_mode,
116139
})
117140
}
118141
}
@@ -140,9 +163,6 @@ jobs:
140163
analyze:
141164
name: Analyze (${{ matrix.name }})
142165
if: needs.languages.outputs.continue == 'true'
143-
defaults:
144-
run:
145-
shell: ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash' }}
146166
env:
147167
GITHUB_CODEQL_BUILD: true
148168
needs: languages
@@ -154,35 +174,13 @@ jobs:
154174
strategy:
155175
fail-fast: false
156176
matrix: ${{ fromJson(needs.languages.outputs.matrix) }}
157-
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
177+
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 60 }}
158178
steps:
159-
- name: Maximize build space
160-
if: >-
161-
runner.os == 'Linux' &&
162-
matrix.language == 'cpp'
163-
uses: easimon/maximize-build-space@v10
164-
with:
165-
root-reserve-mb: 30720
166-
remove-dotnet: ${{ (matrix.language == 'csharp' && 'false') || 'true' }}
167-
remove-android: 'true'
168-
remove-haskell: 'true'
169-
remove-codeql: 'false'
170-
remove-docker-images: 'true'
171-
172179
- name: Checkout repository
173180
uses: actions/checkout@v4
174181
with:
175182
submodules: recursive
176183

177-
- name: Setup msys2
178-
if: >-
179-
runner.os == 'Windows' &&
180-
matrix.language == 'cpp'
181-
uses: msys2/setup-msys2@v2
182-
with:
183-
msystem: ucrt64
184-
update: true
185-
186184
# Initializes the CodeQL tools for scanning.
187185
- name: Initialize CodeQL
188186
uses: github/codeql-action/init@v3
@@ -200,22 +198,11 @@ jobs:
200198
- build
201199
- node_modules
202200
- third-party
203-
204-
# Pre autobuild
205-
# create a file named .codeql-prebuild-${{ matrix.language }}-${{ runner.os }}.sh in the root of your repository
206-
- name: Prebuild
207-
id: prebuild
208-
run: |
209-
# check if prebuild script exists
210-
filename=".codeql-prebuild-${{ matrix.language }}-${{ runner.os }}.sh"
211-
if [ -f "./${filename}" ]; then
212-
echo "Running prebuild script: ${filename}"
213-
./${filename}
214-
fi
201+
build-mode: ${{ matrix.build-mode || 'none' }}
215202

216203
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
217204
- name: Autobuild
218-
if: steps.prebuild.outputs.skip_autobuild != 'true'
205+
if: matrix.build-mode == 'autobuild'
219206
uses: github/codeql-action/autobuild@v3
220207

221208
- name: Perform CodeQL Analysis

0 commit comments

Comments
 (0)