Repository navigation
128 lines (116 loc) · 4.76 KB
/
Copy pathcodeql.yml
File metadata and controls
128 lines (116 loc) · 4.76 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: CodeQL
# Replaces GitHub's default code-scanning setup, which cannot be path-filtered:
# it ran the Swift analysis on a macOS runner (~10x Linux billing, 20-30 min)
# for every PR, including the large majority that never touch apps/ios. Swift
# now runs only when Swift could have changed, plus on the weekly schedule.
#
# The same goes for Rust (~6 min, 22 files in apps/ingest), Go and
# Actions on pull requests: they start alongside CI and took four of the org's
# runner slots on every push for code most PRs never touch. A PR analyzes them
# only when their paths change; main pushes and the schedule analyze them all,
# so the base-branch results PRs compare against stay current. JS/TS runs on
# every event.
#
# Categories match default setup's (`/language:<lang>`), so alert history
# carries over. Default setup must stay disabled (repo Settings → Code security)
# or GitHub rejects this workflow's uploads.
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "17 4 * * 1"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
changes:
name: Detect changes
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
swift: ${{ steps.filter.outputs.swift == 'true' }}
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
id: filter
with:
filters: |
swift:
- 'apps/ios/**'
- '.github/workflows/codeql.yml'
rust:
- '**/*.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
- '.github/workflows/codeql.yml'
go:
- '**/*.go'
- '**/go.mod'
- '**/go.sum'
- '.github/workflows/codeql.yml'
actions:
- '.github/**'
- name: Pick languages to analyze
id: matrix
env:
EVENT: ${{ github.event_name }}
CHANGED: ${{ steps.filter.outputs.changes }}
run: |
if [[ "$EVENT" != pull_request ]]; then
CHANGED='["actions","go","rust"]'
fi
jq -cn --argjson changed "$CHANGED" '{include: (
[{language: "javascript-typescript", "build-mode": "none"}]
+ [
{language: "actions", "build-mode": "none"},
{language: "go", "build-mode": "autobuild"},
{language: "rust", "build-mode": "none"}
| select(.language | IN($changed[]))
]
)}' | sed 's/^/matrix=/' >> "$GITHUB_OUTPUT"
analyze:
name: Analyze (${{ matrix.language }})
needs: changes
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
security-events: write
contents: read
actions: read
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.changes.outputs.matrix) }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- uses: github/codeql-action/init@d8073367669608af8fbcc5f63dd0a0d52bb90cff # v4
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
- uses: github/codeql-action/analyze@d8073367669608af8fbcc5f63dd0a0d52bb90cff # v4
with:
category: /language:${{ matrix.language }}
swift:
name: Analyze (swift)
needs: changes
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || needs.changes.outputs.swift == 'true'
runs-on: macos-latest
timeout-minutes: 60
permissions:
security-events: write
contents: read
actions: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- uses: github/codeql-action/init@d8073367669608af8fbcc5f63dd0a0d52bb90cff # v4
with:
languages: swift
build-mode: autobuild
- uses: github/codeql-action/analyze@d8073367669608af8fbcc5f63dd0a0d52bb90cff # v4
with:
category: /language:swift