Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 9db8fd9

Browse files
authored
Merge pull request #291 from janhq/feat/gh_codeql
feat: Add Github CodeQL
2 parents 9737c87 + 5155584 commit 9db8fd9

File tree

6 files changed

+119
-56
lines changed

6 files changed

+119
-56
lines changed

.github/workflows/auto-bump-llamacpp.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches:
17+
- main
18+
tags: ["v[0-9]+.[0-9]+.[0-9]+"]
19+
paths:
20+
[
21+
".github/scripts/**",
22+
".github/workflows/build.yml",
23+
".github/workflows/codeql-analysis.yml",
24+
"**/CMakeLists.txt",
25+
"**/Makefile",
26+
"**/*.h",
27+
"**/*.hpp",
28+
"**/*.c",
29+
"**/*.cpp",
30+
"**/*.cu",
31+
"**/*.cc",
32+
"**/*.cxx",
33+
"llama.cpp",
34+
"!docs/**",
35+
"!.gitignore",
36+
"!README.md",
37+
]
38+
pull_request:
39+
types: [opened, synchronize, reopened]
40+
paths:
41+
[
42+
".github/scripts/**",
43+
".github/workflows/build.yml",
44+
".github/workflows/codeql-analysis.yml",
45+
"**/CMakeLists.txt",
46+
"**/Makefile",
47+
"**/*.h",
48+
"**/*.hpp",
49+
"**/*.c",
50+
"**/*.cpp",
51+
"**/*.cu",
52+
"**/*.cc",
53+
"**/*.cxx",
54+
"llama.cpp",
55+
"!docs/**",
56+
"!.gitignore",
57+
"!README.md",
58+
]
59+
60+
jobs:
61+
analyze:
62+
name: Analyze
63+
# Runner size impacts CodeQL analysis time. To learn more, please see:
64+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
65+
# - https://gh.io/supported-runners-and-hardware-resources
66+
# - https://gh.io/using-larger-runners
67+
# Consider using larger runners for possible analysis time improvements.
68+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
69+
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
70+
permissions:
71+
actions: read
72+
contents: read
73+
security-events: write
74+
75+
strategy:
76+
fail-fast: false
77+
matrix:
78+
language: ["c-cpp"]
79+
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
80+
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
81+
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
82+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
83+
84+
steps:
85+
- name: Checkout repository
86+
uses: actions/checkout@v4
87+
with:
88+
submodules: recursive
89+
90+
- name: Initialize CodeQL
91+
uses: github/codeql-action/init@v3
92+
with:
93+
languages: ${{ matrix.language }}
94+
95+
- name: Autobuild
96+
run: |
97+
./install_deps.sh
98+
mkdir build && cd build
99+
cmake ..
100+
CC=gcc-8 make -j $(sysctl -n hw.ncp)
101+
ls -la
102+
103+
- name: Perform CodeQL Analysis
104+
uses: github/codeql-action/analyze@v3
105+
with:
106+
category: "/language:${{matrix.language}}"

controllers/health.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55

66
using namespace drogon;
77

8-
class health : public drogon::HttpSimpleController<health>
9-
{
10-
public:
11-
void asyncHandleHttpRequest(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback) override;
12-
PATH_LIST_BEGIN
13-
PATH_ADD("/healthz", Get);
14-
PATH_LIST_END
8+
class health : public drogon::HttpSimpleController<health> {
9+
public:
10+
void asyncHandleHttpRequest(
11+
const HttpRequestPtr &req,
12+
std::function<void(const HttpResponsePtr &)> &&callback) override;
13+
PATH_LIST_BEGIN
14+
PATH_ADD("/healthz", Get);
15+
PATH_LIST_END
1516
};

controllers/llamaCPP.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
using namespace inferences;
1414
using json = nlohmann::json;
1515

16-
// To store state of each inference request
1716
struct State {
1817
bool isStopped = false;
1918
int task_id;

controllers/processManager.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
#include <cstdlib>
33
#include <trantor/utils/Logger.h>
44

5-
void processManager::destroy(const HttpRequestPtr &req,
6-
std::function<void(const HttpResponsePtr &)> &&callback) {
5+
void processManager::destroy(
6+
const HttpRequestPtr &req,
7+
std::function<void(const HttpResponsePtr &)> &&callback) {
78
LOG_INFO << "Program is exitting, goodbye!";
89
exit(0);
910
return;
1011
};
11-
// Add definition of your processing function here

controllers/processManager.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,12 @@ using namespace drogon;
88
class processManager : public drogon::HttpController<processManager> {
99
public:
1010
METHOD_LIST_BEGIN
11-
// use METHOD_ADD to add your custom processing function here;
12-
// METHOD_ADD(processManager::get, "/{2}/{1}", Get); // path is
13-
// /processManager/{arg2}/{arg1}
11+
1412
METHOD_ADD(processManager::destroy, "/destroy",
1513
Delete); // path is /processManager/{arg1}/{arg2}/list
1614

1715
METHOD_LIST_END
18-
// your declaration of processing function maybe like this:
16+
1917
void destroy(const HttpRequestPtr &req,
2018
std::function<void(const HttpResponsePtr &)> &&callback);
21-
// void your_method_name(const HttpRequestPtr& req, std::function<void (const
22-
// HttpResponsePtr &)> &&callback, double p1, int p2) const;
2319
};

0 commit comments

Comments
 (0)