Skip to content

Remove csharp from CodeQL analysis — only scan C/C++#564

Closed
Copilot wants to merge 2 commits intostagingfrom
copilot/update-codeql-workflow-languages
Closed

Remove csharp from CodeQL analysis — only scan C/C++#564
Copilot wants to merge 2 commits intostagingfrom
copilot/update-codeql-workflow-languages

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

The dynamic CodeQL workflow was attempting to analyze C# code that exists solely as test code and cannot be auto-built, causing the CodeQL job to fail.

Changes

  • Added .github/workflows/codeql.yml — custom CodeQL workflow that overrides the dynamic GitHub-managed setup, scoping analysis exclusively to c-cpp and dropping csharp
- name: Initialize CodeQL
  uses: github/codeql-action/init@v3
  with:
    languages: ${{ matrix.language }}  # c-cpp only
    build-mode: ${{ matrix.build-mode }}

Uses codeql-action v3 with matrix strategy, runs on push/PR to staging/main and weekly schedule.

Original prompt

Update the CodeQL workflow at dynamic/github-code-scanning/codeql to remove csharp from the languages list in the CodeQL initialization step. Use:

  • name: Initialize CodeQL
    uses: github/codeql-action/init@v2
    with:
    languages: c, cpp

This change ensures CodeQL will only analyze C and C++ code, skipping C# analysis and avoiding build errors related to C# test code.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.

Assistant: The failing CodeQL job could not auto-detect a suitable build method for C#. The error in the logs is:

"We were unable to automatically build your code. Please replace the call to the autobuild action with your custom build steps."

This means the CodeQL workflow uses the default autobuild step, but your repository's build process is not automatically detected.

Solution

  1. Update the workflow file (dynamic/github-code-scanning/codeql) to use manual build steps.

  2. Replace:

    - name: Autobuild
      uses: github/codeql-action/autobuild@v2

    With explicit build steps for your C# code. For example, if you use dotnet build:

    - name: Build with dotnet
      run: dotnet build path/to/your/project.sln --configuration Release
  3. Make sure the build command matches your project structure and dependencies.

Code Example (workflow snippet)

jobs:
  codeql:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Set up .NET
        uses: actions/setup-dotnet@v3
        with:
          dotnet-version: 'X.Y.Z'

      - name: Build with dotnet
        run: dotnet build path/to/your/project.sln --configuration Release

      # Continue with CodeQL steps...

Summary

Replace the autobuild action with manual build steps that fit your repository. This will resolve the detection error and allow CodeQL to analyze your code correctly.

Let me know your exact build commands if you need further help updating the workflow file.

User: but these code are just for tests not really needed to be build

Assistant: If the C# code is only for tests and not required for builds, you can do one of the following:

1. Skip C# Analysis in CodeQL Job

Update your CodeQL workflow to only analyze the relevant languages (such as C or C++), and remove C# from the languages list.

Example:

- name: Initialize CodeQL
  uses: github/codeql-action/init@v2
  with:
    languages: c, cpp      # Remove 'csharp' if not needed

This will prevent CodeQL from trying to build C# code.


2. Exclude Test Directories from CodeQL

If you still need to analyze C# but want to skip test files, use the paths and paths-ignore options in your workflow.

Example:

- name: Initialize CodeQL
  uses: github/codeql-action/init@v2
  with:
    languages: csharp
    paths-ignore: |
      test/

This skips files and directories matching test/.


3. Remove Unnecessary Build Steps

If there’s no C# code required, ensure you do not run C# autobuild or build steps in the workflow.


Summary

  • Remove C# from CodeQL languages list if not needed.
  • Or, use paths-ignore to skip test code.
  • Remove C# build steps from the workflow.

Let me know which workflow option you'd prefer, or share your workflow file for targeted suggestions!

User: please prepare a PR

Assistant: To prepare a PR that fixes the failing CodeQL job, I need to know which solution you'd like to implement:

  1. Remove C# ("csharp") from CodeQL workflow languages (skip analysis for C# code)
  2. Exclude test directories from CodeQL analysis using paths-ignore
  3. Manually build C# code (adding build steps), even though it's just for tests
  4. Remove unnecessary build steps for C#

Please confirm your preferred solution, or share your workflow requirements. Once you confirm, I’ll prepare the PR in FalkorDB/code-graph for you.

User: can we just do the skip?

  • name: Initialize CodeQL
    uses: github/codeql-action/init@v2
    with:
    languages: csharp
    paths-ignore: |
    test/

Assistant: Yes, you can simply use the skip option by adding paths-ignore: test/ to your CodeQL initialization step. This will instruct CodeQL to ignore the test/ directory, so it won’t attempt to analyze or build code in your test files, resolving the build issue for C# test code.

PR Plan

  • Update the workflow at dynamic/github-code-scanning/codeql in FalkorDB/code-graph.
  • Add paths-ignore: test/ to the Initialize CodeQL step.

Example snippet:

- name: Initialize CodeQL
  uses: github/codeql-action/init@v2
  with:
    languages: csharp
    paths-ignore: |
      test/

If you'd like, I can ...

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link

vercel bot commented Mar 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
code-graph Error Error Mar 10, 2026 8:26am

Request Review

Co-authored-by: gkorland <753206+gkorland@users.noreply.github.com>
Copilot AI changed the title [WIP] Update CodeQL workflow to remove C# from languages Remove csharp from CodeQL analysis — only scan C/C++ Mar 10, 2026
@gkorland gkorland marked this pull request as ready for review March 10, 2026 08:28
@gkorland gkorland requested a review from Copilot March 10, 2026 08:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a repository-owned CodeQL workflow intended to avoid failing C# analysis by scoping CodeQL to a single language matrix entry.

Changes:

  • Add .github/workflows/codeql.yml to run CodeQL on pushes/PRs to staging/main and on a weekly schedule.
  • Configure CodeQL initialization to use a matrix with c-cpp and autobuild mode.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +25 to +26
- language: c-cpp
build-mode: autobuild
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow is configured to analyze only c-cpp, but the repo appears to contain no C/C++ source files (no .c/.cc/.cpp/.h/.hpp found). That means CodeQL will either produce no useful results or the autobuild step may fail due to no detectable build. If the goal is to avoid failing on C# fixtures while still scanning this repo’s code, consider switching matrix.language to the actual implementation languages here (e.g., python and javascript-typescript) rather than c-cpp.

Suggested change
- language: c-cpp
build-mode: autobuild
- language: python
build-mode: autobuild
- language: javascript-typescript
build-mode: autobuild

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +45
- name: Checkout repository
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}

- if: matrix.build-mode == 'autobuild'
name: Autobuild
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

steps: list items are not indented under the steps: key (e.g., - name: Checkout repository is aligned with steps:). This is invalid YAML and will cause the workflow to fail to load. Indent all step entries (and their nested keys) so the - name lines are children of steps:.

Suggested change
- name: Checkout repository
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
- if: matrix.build-mode == 'autobuild'
name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
- name: Checkout repository
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
- if: matrix.build-mode == 'autobuild'
name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"

Copilot uses AI. Check for mistakes.
@gkorland gkorland closed this Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants