Repository navigation
160 lines (143 loc) · 7.14 KB
/
Copy pathcodeql.yml
File metadata and controls
160 lines (143 loc) · 7.14 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL Advanced"
on:
workflow_dispatch:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '40 3 * * 4'
# A cold-cache run rebuilds PostgreSQL, SVS, and pgvector from source (up to
# the 180-minute timeout below), so a superseded run on the same ref is
# cancelled rather than left to run to completion alongside its replacement.
concurrency:
group: codeql-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
analyze:
name: Analyze (${{ matrix.language }})
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners (GitHub.com only)
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
runs-on: ubuntu-latest
# Cold-cache runs build PostgreSQL and the SVS library from source; the
# timeout keeps a hung dependency build from consuming the 6 hour default.
timeout-minutes: 180
env:
# config's own SVS_URL/SVS_COMMIT defaults are blank (defer to
# upstream, see docs/build_guide/config); pin both here, side by side,
# so CI's build is reproducible. SVS_COMMIT must be the exact SVS_REPO
# commit SVS_URL's tarball was built from: SVS_BRANCH is a moving
# branch, and without SVS_COMMIT pinning bindings/c to match, it drifts
# ahead of the tarball's API and fails to compile. Update both together
# whenever SVS_URL is bumped to a newer nightly.
SVS_URL: "https://github.com/intel/ScalableVectorSearch/releases/download/nightly/svs-shared-library-nightly-2026-09-15-1529.tar.gz"
SVS_COMMIT: "1cd0df27c4bf54c4b963ad02112c873fba21a6ef"
permissions:
# required for all workflows
security-events: write
# required to fetch internal or private CodeQL packs
packages: read
# only required for workflows in private repositories
actions: read
contents: read
strategy:
fail-fast: false
matrix:
include:
- language: c-cpp
# 'manual' rather than 'none': this extension only compiles against
# PostgreSQL, SVS and pgvector headers, so buildless extraction cannot
# resolve its macros and types.
build-mode: manual
# 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
# The dependency builds below deliberately run *before* `init` so that the
# CodeQL tracer only wraps this repository's `make`. Building PostgreSQL and
# the SVS C++ library after `init` would extract them into the database too.
# See docs/build_guide/README.md for the equivalent local build.
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential cmake git bison flex pkg-config \
libreadline-dev zlib1g-dev libicu-dev
# pgvector installs into the PostgreSQL prefix, so caching pgsql_install
# also caches the vector/halfvec headers the Makefile compiles against.
- name: Restore PostgreSQL and SVS builds
id: deps-cache
uses: actions/cache@v4
with:
path: |
docs/build_guide/pgsql_install
docs/build_guide/svs_install
key: svs-deps-${{ runner.os }}-${{ env.SVS_URL }}-${{ env.SVS_COMMIT }}-${{ hashFiles('docs/build_guide/config', 'docs/build_guide/install_postgres.sh', 'docs/build_guide/build_svs.sh', 'docs/build_guide/build_pgvector_vanilla.sh') }}
- name: Build PostgreSQL
if: steps.deps-cache.outputs.cache-hit != 'true'
run: bash docs/build_guide/install_postgres.sh
- name: Build SVS library
if: steps.deps-cache.outputs.cache-hit != 'true'
run: bash docs/build_guide/build_svs.sh
- name: Build and install vanilla pgvector
if: steps.deps-cache.outputs.cache-hit != 'true'
run: bash docs/build_guide/build_pgvector_vanilla.sh
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
queries: security-and-quality
# Build only the extension, so this is the compilation CodeQL traces.
# docs/build_guide/config is the single source of truth for PG_CONFIG and
# SVS_INSTALL_DIR. PG_CONFIG is exported rather than passed on the command
# line, matching build_svs_extension.sh's own convention, so the two don't
# drift into different patterns for the same variable.
- name: Run manual build steps
if: matrix.build-mode == 'manual'
shell: bash
run: |
source docs/build_guide/config
export PG_CONFIG
make -j"$(nproc)" SVS_INSTALL="$SVS_INSTALL_DIR"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{matrix.language}}"
# Report only on a manual run, never on push/PR/schedule.
- name: Generate Security Report
if: github.event_name == 'workflow_dispatch'
uses: rsdmike/github-security-report-action@v3.0.4
with:
template: report
token: ${{ secrets.GITHUB_TOKEN }}
- name: GitHub Upload Release Artifacts
if: github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v4
with:
name: report
path: |
./report.pdf