Skip to content

Commit 76bbeb0

Browse files
Fix CodeQL workflow for MAUI build and add code scanning setup instructions
- Replace Autobuild with explicit .NET 9 SDK setup and MAUI workload install - Add manual dotnet build step targeting net9.0-android (Ubuntu-compatible) - Simplify runs-on to ubuntu-latest (only scanning C#) - Add CODE_SCANNING_SETUP.md with maintainer instructions Co-authored-by: jeff-at-trimble <215895768+jeff-at-trimble@users.noreply.github.com>
1 parent 29b46d3 commit 76bbeb0

2 files changed

Lines changed: 89 additions & 3 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
jobs:
1313
analyze:
1414
name: Analyze
15-
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
15+
runs-on: ubuntu-latest
1616
if: ${{ github.actor != 'dependabot[bot]' }}
1717
permissions:
1818
actions: read
@@ -30,14 +30,22 @@ jobs:
3030
with:
3131
persist-credentials: false
3232

33+
- name: Setup .NET 9
34+
uses: actions/setup-dotnet@v4
35+
with:
36+
dotnet-version: 9.0.x
37+
38+
- name: Install MAUI workloads
39+
run: dotnet workload install maui-android --ignore-failed-sources
40+
3341
- name: Initialize CodeQL
3442
uses: github/codeql-action/init@v4
3543
with:
3644
languages: ${{ matrix.language }}
3745
queries: +security-and-quality
3846

39-
- name: Autobuild
40-
uses: github/codeql-action/autobuild@v4
47+
- name: Build
48+
run: dotnet build Trimble.Modus.Components.sln -f net9.0-android -c Release
4149

4250
- name: Perform CodeQL Analysis
4351
uses: github/codeql-action/analyze@v4

CODE_SCANNING_SETUP.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Code Scanning Setup Guide
2+
3+
This document explains how to resolve code scanning configuration issues in this repository and maintain compliance with organizational policies.
4+
5+
## Current Configuration
6+
7+
This repository has two CodeQL code scanning configurations:
8+
9+
1. **Default Setup** (managed by GitHub) — Configured in **Settings > Code security > Code scanning**. This is GitHub's built-in scanning that runs automatically without a workflow file.
10+
11+
2. **Custom Workflow** (`.github/workflows/codeql.yml`) — A workflow file in the repository that provides more control over the scanning process, including the `security-and-quality` query suite.
12+
13+
## Known Issue: Stale Configuration Error
14+
15+
The custom CodeQL workflow (`codeql.yml`) was previously **manually disabled**, which causes the code scanning status page to show an error or stale configuration at:
16+
17+
> **Security** > **Code scanning** > **Tool status** > **CodeQL** > **Configurations**
18+
19+
This happens because GitHub detects the workflow configuration but finds no recent scan results from it.
20+
21+
## How to Resolve
22+
23+
You have two options — choose **one**:
24+
25+
### Option A: Use the Custom Workflow (Recommended)
26+
27+
The custom workflow provides more thorough analysis with the `security-and-quality` query suite.
28+
29+
1. Go to **Actions** > **CodeQL** (the workflow, not the default setup)
30+
2. Click **Enable workflow** to re-enable the disabled `codeql.yml`
31+
3. Optionally, trigger a manual run via **Run workflow** to verify it works
32+
4. Go to **Settings** > **Code security** > **Code scanning** and disable the **Default setup** to avoid duplicate scanning
33+
5. Verify the workflow completes successfully and results appear under **Security** > **Code scanning**
34+
35+
### Option B: Use the Default Setup Only
36+
37+
If you prefer the simpler GitHub-managed scanning:
38+
39+
1. Verify the Default Setup is enabled in **Settings** > **Code security** > **Code scanning**
40+
2. **Delete** the file `.github/workflows/codeql.yml` from the repository to remove the stale configuration
41+
3. Commit and push the deletion
42+
4. The stale configuration error will clear after the next scheduled scan
43+
44+
## Why Was the Workflow Failing?
45+
46+
The original `codeql.yml` used CodeQL's **Autobuild** step, which could not build this .NET MAUI project because:
47+
48+
- The .NET SDK was not set up in the workflow
49+
- MAUI workloads (required for building MAUI projects) were not installed
50+
- Autobuild does not automatically install platform-specific workloads
51+
52+
The updated workflow in this repository fixes these issues by:
53+
54+
- Adding a `setup-dotnet` step for .NET 9
55+
- Installing the `maui-android` workload (compatible with Ubuntu runners)
56+
- Replacing the Autobuild step with an explicit `dotnet build` targeting `net9.0-android`
57+
58+
## Verifying Code Scanning Compliance
59+
60+
To verify your code scanning setup is working correctly:
61+
62+
1. Go to **Security** > **Code scanning** > **Tool status**
63+
2. Confirm CodeQL shows a **green status** with recent scan results
64+
3. Ensure there is only **one active configuration** (either default setup or custom workflow, not both)
65+
4. Check that scheduled scans are running (the custom workflow runs monthly on the 1st)
66+
67+
## Dependencies for the Custom Workflow
68+
69+
The custom CodeQL workflow requires:
70+
71+
| Dependency | Purpose |
72+
|---|---|
73+
| `actions/checkout@v5` | Check out the repository code |
74+
| `actions/setup-dotnet@v4` | Install .NET 9 SDK |
75+
| `github/codeql-action/init@v4` | Initialize CodeQL analysis |
76+
| `github/codeql-action/analyze@v4` | Run CodeQL analysis and upload results |
77+
78+
These are kept up to date by Dependabot (configured in `.github/dependabot.yml`).

0 commit comments

Comments
 (0)