Skip to content

Commit 2843877

Browse files
committed
fix(ci): Fix CodeQL workflow to properly analyze Go code
- Change condition from 'pull_request only' to 'skip merge_group' This enables scans on push/schedule while avoiding duplicate runs - Replace Autobuild with explicit 'go build ./...' for Go language - Add setup-go action to ensure Go is properly configured - Add submodules: true to checkout for complete codebase - Keep Autobuild for Python as it works for interpreted languages Fixes: Go files were found but not processed Fixes: Code Scanning results may be out of date Refs: github/codeql-action#1537 Signed-off-by: Jonah Kowall <[email protected]>
1 parent 5bebf41 commit 2843877

1 file changed

Lines changed: 23 additions & 10 deletions

File tree

‎.github/workflows/codeql.yml‎

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: "CodeQL"
22

33
on:
4+
merge_group:
45
push:
56
branches: [main]
67

@@ -20,8 +21,9 @@ permissions: # added using https://github.com/step-security/secure-workflows
2021

2122
jobs:
2223
codeql-analyze:
23-
# Run only on pull requests, see https://github.com/github/codeql-action/issues/1537
24-
if: ${{ github.event_name == 'pull_request' }}
24+
# Skip merge_group to avoid duplicate runs (code already scanned on pull_request)
25+
# See https://github.com/github/codeql-action/issues/1537
26+
if: ${{ github.event_name != 'merge_group' }}
2527
name: CodeQL Analyze
2628
runs-on: ubuntu-latest
2729

@@ -33,29 +35,40 @@ jobs:
3335
fail-fast: false
3436
matrix:
3537
language: [ 'go', 'python' ]
36-
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
3738

3839
steps:
3940
- name: Harden Runner
4041
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
4142
with:
42-
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
43+
egress-policy: audit
4344

4445
- name: Checkout repository
4546
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
47+
with:
48+
submodules: true # Jaeger uses submodules (jaeger-ui, idl)
49+
50+
- name: Setup Go
51+
if: matrix.language == 'go'
52+
uses: actions/setup-go@v5
53+
with:
54+
go-version: stable
4655

47-
# Initializes the CodeQL tools for scanning.
4856
- name: Initialize CodeQL
4957
uses: github/codeql-action/init@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4
5058
with:
5159
languages: ${{ matrix.language }}
52-
# If you wish to specify custom queries, you can do so here or in a config file.
53-
# By default, queries listed here will override any specified in a config file.
54-
# Prefix the list here with "+" to use these queries and those in the config file.
55-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
5660

57-
- name: Autobuild
61+
# Use Autobuild for Python (it works fine for interpreted languages)
62+
- name: Autobuild (Python)
63+
if: matrix.language == 'python'
5864
uses: github/codeql-action/autobuild@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4
5965

66+
# Explicit build for Go - required for CodeQL to analyze compiled code
67+
- name: Build Go code
68+
if: matrix.language == 'go'
69+
run: |
70+
# Build all Go binaries to ensure CodeQL can analyze them
71+
go build -v ./...
72+
6073
- name: Perform CodeQL Analysis
6174
uses: github/codeql-action/analyze@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4

0 commit comments

Comments
 (0)