-
Notifications
You must be signed in to change notification settings - Fork 194
95 lines (85 loc) · 3.4 KB
/
Copy pathcodeql.yml
File metadata and controls
95 lines (85 loc) · 3.4 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
name: CodeQL
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
# Weekly on Monday 03:27 UTC — off-peak and offset from the other
# scheduled jobs (scorecard 06:00 Mon, labels 04:17 Mon, stale 04:37
# daily).
- cron: '27 3 * * 1'
# Default to read-only; the analyze job opts into security-events: write.
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
analyze:
name: Analyze (${{ matrix.language }})
runs-on: ubuntu-latest
timeout-minutes: 120
permissions:
# Upload CodeQL results to the code-scanning dashboard. On pull_request
# this is also what lets CodeQL post new-alert annotations on the diff.
security-events: write
# Check out the repository.
contents: read
# Read workflow run metadata (required by codeql-action on private
# repos; harmless on a public repo).
actions: read
strategy:
fail-fast: false
matrix:
include:
# Go uses build-mode: manual. The alternative, autobuild, runs `make`
# from the repo root, whose included hack/common-envs.mk does a
# `$(shell git fetch upstream --tags)` at parse time — a network call
# to a non-origin remote that has no bearing on the analysis and is a
# flake vector. Instead the "Build Go modules" step below compiles
# each first-party module explicitly. This keeps the same coverage
# autobuild aimed for — the root module, api/apps/v1alpha1, and the
# three nested image modules — while the _repos/* upstream clones are
# gitignored and absent on a clean checkout, so they are excluded for
# free. setup-go pins the toolchain to the root go.mod version.
- language: go
build-mode: manual
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version-file: go.mod
cache: false
- name: Initialize CodeQL
uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# CodeQL traces these compiler invocations to build its database. Each
# first-party module is a separate go.mod, so `go build ./...` from the
# root never reaches the nested ones — build each explicitly. No `make`,
# so no upstream fetch.
- name: Build Go modules
if: matrix.build-mode == 'manual'
shell: bash
run: |
set -euxo pipefail
for mod in \
. \
api/apps/v1alpha1 \
packages/apps/kubernetes/images/kubevirt-csi-driver \
packages/system/dashboard/images/token-proxy \
packages/system/kubeovn-webhook/images/kubeovn-webhook; do
echo "::group::go build ${mod}"
( cd "${mod}" && go build ./... )
echo "::endgroup::"
done
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
with:
category: "/language:${{ matrix.language }}"