Skip to content

Commit 259bc81

Browse files
author
Timothy Mothra Lee (from Dev Box)
committed
additional changes. also split languages into two jobs
1 parent 328f2b4 commit 259bc81

File tree

2 files changed

+88
-23
lines changed

2 files changed

+88
-23
lines changed

.github/codeql-config.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
paths:
2+
- etw/native/src
3+
paths-ignore:
4+
- '**/node_modules/**'
5+
- '**/build/**'
6+
- '**/dist/**'
7+
- '**/vendor/**'
8+
- '**/test/**'
9+
- '**/tests/**'

.github/workflows/codeql-daily.yml

Lines changed: 79 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,66 +9,122 @@ on:
99
- '**'
1010

1111
jobs:
12-
analyze:
12+
# ===== Java Analysis Job =====
13+
analyze-java:
14+
name: "Analyze Java Code"
1315
permissions:
14-
actions: read # for github/codeql-action/init to get workflow details
15-
security-events: write # for github/codeql-action/analyze to upload SARIF results
16-
runs-on: windows-latest
17-
16+
actions: read
17+
security-events: write
18+
runs-on: ubuntu-latest
19+
1820
steps:
1921
- uses: actions/checkout@v4
2022

21-
- name: Setup Visual Studio Build Tools
22-
uses: microsoft/setup-msbuild@v1
23-
24-
- name: Set up Windows SDK
25-
uses: ilammy/msvc-dev-cmd@v1
26-
2723
- name: Set up Java 17
2824
uses: actions/setup-java@v4
2925
with:
3026
distribution: temurin
3127
java-version: 17
3228

29+
- name: Setup Gradle
30+
uses: gradle/actions/setup-gradle@v4
31+
3332
- name: Initialize CodeQL
3433
uses: github/codeql-action/init@v3
3534
with:
36-
languages: java, c-cpp
35+
languages: java
3736
debug: true
3837

38+
- name: Build Java code
39+
run: ./gradlew assemble --no-build-cache
40+
# Skip build cache for full code analysis
41+
42+
- name: Perform CodeQL analysis
43+
uses: github/codeql-action/analyze@v3
44+
with:
45+
category: java
46+
47+
# ===== C++ Analysis Job =====
48+
analyze-cpp:
49+
name: "Analyze C++ Code"
50+
permissions:
51+
actions: read
52+
security-events: write
53+
runs-on: windows-latest
54+
55+
steps:
56+
- uses: actions/checkout@v4
57+
58+
- name: Set up Java 17 (required for JNI compilation)
59+
uses: actions/setup-java@v4
60+
with:
61+
distribution: temurin
62+
java-version: 17
63+
64+
- name: Setup Visual Studio Build Tools
65+
uses: microsoft/setup-msbuild@v1
66+
67+
- name: Set up Windows SDK
68+
uses: ilammy/msvc-dev-cmd@v1
69+
3970
- name: Setup Gradle
4071
uses: gradle/actions/setup-gradle@v4
4172

42-
- name: Build native C++ code (Windows-specific)
73+
- name: Initialize CodeQL
74+
uses: github/codeql-action/init@v3
75+
with:
76+
languages: cpp
77+
debug: true
78+
config-file: .github/codeql-config.yml
79+
80+
- name: Build C++ code
4381
shell: powershell
82+
id: build-cpp
4483
run: |
45-
# Find the Windows SDK path and use it
84+
# Configure environment for C++ build
4685
$winSdkPath = (Get-ChildItem "C:\Program Files (x86)\Windows Kits\10\include" | Select-Object -Last 1).FullName
4786
Write-Host "Using Windows SDK from path: $winSdkPath"
4887
49-
# Set environment variables for Windows SDK and Visual Studio
88+
# Set environment variables
5089
$env:APPINSIGHTS_WIN10_SDK_PATH = "C:\Program Files (x86)\Windows Kits\10"
5190
$env:APPINSIGHTS_VS_PATH = $env:VsInstallRoot
91+
$env:JAVA_HOME = $env:JAVA_HOME_17_X64
5292
53-
# Log environment for debugging
5493
Write-Host "APPINSIGHTS_WIN10_SDK_PATH: $env:APPINSIGHTS_WIN10_SDK_PATH"
5594
Write-Host "APPINSIGHTS_VS_PATH: $env:APPINSIGHTS_VS_PATH"
95+
Write-Host "JAVA_HOME: $env:JAVA_HOME"
5696
57-
./gradlew "-Dai.etw.native.build=release" :etw:native:build --info
58-
59-
- name: Assemble
60-
# skipping build cache is needed so that all modules will be analyzed
61-
run: ./gradlew assemble --no-build-cache
97+
# Build the native code
98+
try {
99+
./gradlew "-Dai.etw.native.build=release" :etw:native:build --info
100+
echo "CPP_BUILD_SUCCEEDED=true" | Out-File -FilePath $env:GITHUB_ENV -Append
101+
} catch {
102+
Write-Host "Native C++ build failed with error: $_"
103+
# Ensure CodeQL can still scan the files by touching them
104+
Get-ChildItem -Path "etw/native/src" -Recurse -Filter "*.cpp" | Foreach-Object {
105+
Write-Host "Touching file: $($_.FullName)"
106+
(Get-Item $_.FullName).LastWriteTime = Get-Date
107+
}
108+
echo "CPP_BUILD_SUCCEEDED=false" | Out-File -FilePath $env:GITHUB_ENV -Append
109+
}
62110
63111
- name: Perform CodeQL analysis
64112
uses: github/codeql-action/analyze@v3
113+
with:
114+
category: cpp
115+
116+
- name: Report C++ build status
117+
if: env.CPP_BUILD_SUCCEEDED == 'false'
118+
run: |
119+
echo "::warning::C++ build failed but CodeQL scan was attempted anyway. Some C++ issues may not be detected."
65120
66121
scheduled-job-notification:
67122
permissions:
68123
issues: write
69124
needs:
70-
- analyze
125+
- analyze-java
126+
- analyze-cpp
71127
if: always()
72128
uses: ./.github/workflows/reusable-scheduled-job-notification.yml
73129
with:
74-
success: ${{ needs.analyze.result == 'success' }}
130+
success: ${{ needs.analyze-java.result == 'success' && needs.analyze-cpp.result == 'success' }}

0 commit comments

Comments
 (0)