Repository navigation
89 lines (82 loc) · 3.79 KB
/
Copy pathcodeql.yml
File metadata and controls
89 lines (82 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: "CodeQL Advanced"
on:
push:
branches: [ "main" ]
# Markdown can't change the analysis.
paths-ignore: [ "**.md" ]
pull_request:
branches: [ "main" ]
paths-ignore: [ "**.md" ]
schedule:
- cron: '35 2 * * 0'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
analyze:
name: Analyze (${{ matrix.language }})
# Swift analysis requires macOS; the Actions-workflow and Ruby
# analyses don't, and they'd otherwise queue behind CI's macOS jobs.
runs-on: ${{ matrix.runs-on }}
permissions:
security-events: write
packages: read
actions: read
contents: read
strategy:
fail-fast: false
matrix:
include:
- language: actions
build-mode: none
runs-on: ubuntu-latest
- language: swift
build-mode: manual
runs-on: xcode-27
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
# Use `c-cpp` to analyze code written in C, C++ or both
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:
- name: Checkout repository
uses: actions/checkout@v7
- if: matrix.language == 'swift'
name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_27.2.app/Contents/Developer
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# CodeQL analyzes whatever the compiler is invoked on during the
# traced build. Autobuild found CLI/Package.swift (the SwiftFormat
# wrapper) and built only that, so AsyncQueue was never compiled
# under the tracer. Build the library target explicitly instead.
#
# CodeQL's Swift extractor ships x86_64 only, so on Apple Silicon the
# tracer falls back to the x86_64 slices of the system binaries it
# injects into (/bin/bash, /usr/bin/xcrun), and everything they
# spawn runs under Rosetta. Launching the toolchain's own swift with
# `arch -arm64`, with Xcode's toolchain first on PATH so swiftc
# resolves to Xcode's arm64 binary, keeps SwiftPM and the compiler
# native; only the extractor runs under Rosetta.
- if: matrix.language == 'swift'
name: Build
run: |
DEVELOPER_DIR=$(xcode-select -p)
TOOLCHAIN="$DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin"
export PATH="$TOOLCHAIN:$DEVELOPER_DIR/usr/bin:$PATH"
SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
export SDKROOT
# Under the CodeQL tracer, SwiftPM's sandbox-exec cannot launch the compiled manifest
# ("Bad CPU type in executable"), so build without SwiftPM's sandbox.
arch -arm64 "$TOOLCHAIN/swift" build --target AsyncQueue --disable-sandbox
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{matrix.language}}"