Skip to content

Commit cf90bf5

Browse files
fix(ci): improve CodeQL analysis quality with Unity build
Use game-ci/unity-builder to compile Unity scripts before CodeQL analysis. This provides proper type information and resolves the "Low C# analysis quality" warning. Signed-off-by: JasonXuDeveloper - 傑 <jason@xgamedev.net> Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 55e565d commit cf90bf5

1 file changed

Lines changed: 32 additions & 3 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,45 @@ jobs:
3535
steps:
3636
- name: Checkout repository
3737
uses: actions/checkout@v4
38+
with:
39+
lfs: true
40+
41+
- name: Cache Unity Library
42+
uses: actions/cache@v4
43+
with:
44+
path: UnityProject/Library
45+
key: Library-CodeQL-2022.3.55f1-${{ hashFiles('UnityProject/Packages/packages-lock.json') }}
46+
restore-keys: |
47+
Library-CodeQL-2022.3.55f1-
48+
Library-CodeQL-
3849
3950
- name: Initialize CodeQL
4051
uses: github/codeql-action/init@v4
4152
with:
4253
languages: csharp
4354
config-file: ./.github/codeql/codeql-config.yml
44-
# Use security-and-quality queries for comprehensive analysis
4555
queries: security-and-quality
46-
# Use buildless mode for Unity projects (no standard .NET build)
47-
build-mode: none
56+
build-mode: manual
57+
58+
# Compile Unity scripts to generate assemblies for CodeQL analysis
59+
# Using unity-builder with a no-op build method just compiles scripts
60+
- name: Compile Unity Scripts
61+
uses: game-ci/unity-builder@v4
62+
env:
63+
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
64+
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
65+
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
66+
with:
67+
projectPath: UnityProject
68+
unityVersion: 2022.3.55f1
69+
targetPlatform: StandaloneLinux64
70+
buildName: CodeQL
71+
# Skip actual build, we just need script compilation
72+
customParameters: -nographics -quit
73+
74+
- name: Return Unity license
75+
uses: game-ci/unity-return-license@v2
76+
if: always()
4877

4978
- name: Perform CodeQL Analysis
5079
uses: github/codeql-action/analyze@v4

0 commit comments

Comments
 (0)