Skip to content

fix(ci): move Swift CodeQL to macos-latest - #12

Merged
TeoSlayer merged 5 commits into
mainfrom
fix/codeql-runs-on-macos
Jun 16, 2026
Merged

TeoSlayer merged 5 commits into
mainfrom
fix/codeql-runs-on-macos

Conversation

@TeoSlayer

Copy link
Copy Markdown
Contributor

Closes #11.

GitHub-hosted ubuntu runners refuse Swift CodeQL extraction:

```
Swift analysis is only supported on macOS runner images.
Please migrate to a macOS runner.
```

Pre-existing config bug from when codeql.yml was first added. The documented fix is to flip the runner to macOS, which I've done.

Stays on the `-latest` tag so the runner image moves forward as GitHub upgrades it.

Test plan

  • CI on this PR should now have a passing `Analyze` job. If it does, this is the last red on main across all our repos.

teovl and others added 5 commits June 9, 2026 10:57
GitHub-hosted ubuntu runners refuse Swift CodeQL extraction:

  Swift analysis is only supported on macOS runner images.
  Please migrate to a macOS runner.

Pre-existing config bug from when codeql.yml was first added — flipping
the runs-on to macos-latest is the documented fix
(https://codeql.github.com/docs/codeql-overview/supported-languages-and-frameworks/).

Closes #11
… binaryTargets

After moving the runner to macos-latest the autobuild step still
failed:

  error: emit-module command failed with exit code 1
  Sources/Pilot/Pilot.swift:25:8: error: no such module 'PilotC'

CodeQL's swift autobuild invokes swiftc directly without running
`swift package resolve` first, so the manifest's .binaryTarget
(PilotC, the XCFramework) is never downloaded. Replace autobuild
with the same `swift build` the ci.yml test job already runs
successfully — that resolves the manifest, fetches the artifact,
and produces an indexable build the extractor can attach to.
With `swift package resolve` running after codeql-action/init,
swift downloaded Pilot.xcframework.zip OK but the compile then
failed with `error: no such module 'PilotC'` — the tracer
interposes between resolve and compile in a way that hides the
freshly-resolved module from the swift search path.

Splitting the resolve out into its own step before the tracer
init puts the XCFramework on disk first, so the observed
`swift build` step is a no-op resolve + clean compile.
Auto-tracing the swift build still couldn't see the resolved
.binaryTarget (PilotC, the XCFramework) even with a pre-tracer
`swift package resolve` — the documented limitation when
`swift build` is auto-instrumented under codeql-action.

`build-mode: manual` disables the auto-trace; the database is
populated from the explicit `swift build` step instead. This is
the official escape hatch for compiled languages whose build
flow autobuild can't follow.
The CodeQL tracer (build-mode: manual) wraps `swift build` and forces a
clean recompile to observe the Swift frontend. SwiftPM's internal build
plan injects the .binaryTarget (PilotC XCFramework) modulemap dir into
the compile's header search path, but that injection does not survive
the tracer's re-invocation of the compiler — producing
`no such module 'PilotC'` (Sources/Pilot/Pilot.swift:25) even though the
pre-resolve and a plain `swift build` both succeed.

Make the traced build self-contained: locate the resolved XCFramework's
macOS-slice Headers dir (carries PilotC's module.modulemap) under
.build/artifacts and pass it explicitly via `-Xswiftc -I`, so PilotC
resolves regardless of how the tracer re-spawns the compiler.

Validated locally on macOS (Apple Swift 6.3.2): full clean
pre-resolve + forced clean recompile with the explicit header path
compiles Pilot + PilotC successfully.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@TeoSlayer
TeoSlayer merged commit 9ced898 into main Jun 16, 2026
3 of 4 checks passed
@TeoSlayer
TeoSlayer deleted the fix/codeql-runs-on-macos branch June 16, 2026 08:05
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.

codeql.yml runs Swift CodeQL on ubuntu-latest — needs macos-latest

3 participants