opencode-skills-antigravity 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundled-skills/aegisops-ai/SKILL.md +127 -0
- package/bundled-skills/cpp-pro/references/build-tooling.md +440 -0
- package/bundled-skills/cpp-pro/references/concurrency.md +437 -0
- package/bundled-skills/cpp-pro/references/memory-performance.md +397 -0
- package/bundled-skills/cpp-pro/references/modern-cpp.md +304 -0
- package/bundled-skills/cpp-pro/references/templates.md +357 -0
- package/bundled-skills/cpp-pro/resources/implementation-playbook.md +43 -0
- package/bundled-skills/docs/integrations/jetski-cortex.md +3 -3
- package/bundled-skills/docs/integrations/jetski-gemini-loader/README.md +4 -4
- package/bundled-skills/docs/integrations/jetski-gemini-loader/{loader.ts → loader.mjs} +38 -50
- package/bundled-skills/docs/maintainers/repo-growth-seo.md +3 -3
- package/bundled-skills/docs/maintainers/security-findings-triage-2026-03-15.csv +1 -1
- package/bundled-skills/docs/maintainers/security-findings-triage-2026-03-15.md +1 -1
- package/bundled-skills/docs/maintainers/security-findings-triage-2026-03-18-addendum.md +1 -1
- package/bundled-skills/docs/maintainers/skills-update-guide.md +1 -1
- package/bundled-skills/docs/users/bundles.md +1 -1
- package/bundled-skills/docs/users/claude-code-skills.md +1 -1
- package/bundled-skills/docs/users/gemini-cli-skills.md +1 -1
- package/bundled-skills/docs/users/getting-started.md +1 -1
- package/bundled-skills/docs/users/kiro-integration.md +1 -1
- package/bundled-skills/docs/users/usage.md +4 -4
- package/bundled-skills/docs/users/visual-guide.md +4 -4
- package/bundled-skills/jobgpt/SKILL.md +100 -0
- package/bundled-skills/moyu/SKILL.md +267 -0
- package/bundled-skills/windows-shell-reliability/SKILL.md +107 -0
- package/bundled-skills/xvary-stock-research/LICENSE +21 -0
- package/bundled-skills/xvary-stock-research/SKILL.md +103 -0
- package/bundled-skills/xvary-stock-research/assets/nvda-deep-dive-hero.png +0 -0
- package/bundled-skills/xvary-stock-research/assets/nvda-deep-dive-scenarios.png +0 -0
- package/bundled-skills/xvary-stock-research/assets/nvda-deep-dive-thesis.png +0 -0
- package/bundled-skills/xvary-stock-research/assets/social-preview.png +0 -0
- package/bundled-skills/xvary-stock-research/examples/nvda-analysis.md +60 -0
- package/bundled-skills/xvary-stock-research/references/edgar-guide.md +53 -0
- package/bundled-skills/xvary-stock-research/references/methodology.md +153 -0
- package/bundled-skills/xvary-stock-research/references/scoring.md +111 -0
- package/bundled-skills/xvary-stock-research/tests/test_edgar.py +90 -0
- package/bundled-skills/xvary-stock-research/tests/test_market.py +113 -0
- package/bundled-skills/xvary-stock-research/tools/edgar.py +495 -0
- package/bundled-skills/xvary-stock-research/tools/market.py +302 -0
- package/package.json +1 -1
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: aegisops-ai
|
|
3
|
+
description: "Autonomous DevSecOps & FinOps Guardrails.
|
|
4
|
+
Orchestrates Gemini 3 Flash to audit Linux Kernel patches,
|
|
5
|
+
Terraform cost drifts, and K8s compliance."
|
|
6
|
+
risk: safe
|
|
7
|
+
source: community
|
|
8
|
+
author: Champbreed
|
|
9
|
+
date_added: "2026-03-24"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# /aegisops-ai — Autonomous Governance Orchestrator
|
|
13
|
+
|
|
14
|
+
AegisOps-AI is a professional-grade "Living Pipeline"
|
|
15
|
+
that integrates advanced AI reasoning directly into
|
|
16
|
+
the SDLC. It acts as an intelligent gatekeeper for
|
|
17
|
+
systems-level security, cloud infrastructure costs,
|
|
18
|
+
and Kubernetes compliance.
|
|
19
|
+
|
|
20
|
+
## Goal
|
|
21
|
+
|
|
22
|
+
To automate high-stakes security and financial audits by:
|
|
23
|
+
1. Identifying logic-based vulnerabilities (UAF, Stale
|
|
24
|
+
State) in Linux Kernel patches.
|
|
25
|
+
2. Detecting massive "Silent Disaster" cost drifts in
|
|
26
|
+
Terraform plans.
|
|
27
|
+
3. Translating natural language security intent into
|
|
28
|
+
hardened K8s manifests.
|
|
29
|
+
|
|
30
|
+
## When to Use
|
|
31
|
+
|
|
32
|
+
- **Kernel Patch Review:** Auditing raw C-based Git diffs for memory safety.
|
|
33
|
+
- **Pre-Apply IaC Audit:** Analyzing `terraform plan` outputs to prevent bill spikes.
|
|
34
|
+
- **Cluster Hardening:** Generating "Least Privilege" securityContexts for deployments.
|
|
35
|
+
- **CI/CD Quality Gating:** Blocking non-compliant merges via GitHub Actions.
|
|
36
|
+
|
|
37
|
+
## When Not to Use
|
|
38
|
+
|
|
39
|
+
- **Web App Logic:** Do not use for standard web vulnerabilities (XSS, SQLi); use dedicated SAST scanners.
|
|
40
|
+
- **Non-C Memory Analysis:** The patch analyzer is optimized for C-logic; avoid using it for high-level languages like Python or JS.
|
|
41
|
+
- **Direct Resource Mutation:** This is an *auditor*, not a deployment tool. It does not execute `terraform apply` or `kubectl apply`.
|
|
42
|
+
- **Post-Mortem Analysis:** For analyzing *why* a previous AI session failed, use `/analyze-project` instead.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
## 🤖 Generative AI Integration
|
|
46
|
+
|
|
47
|
+
AegisOps-AI leverages the **Google GenAI SDK** to implement a "Reasoning Path" for autonomous security and financial audits:
|
|
48
|
+
|
|
49
|
+
* **Neural Patch Analysis:** Performs semantic code reviews of Linux Kernel patches, moving beyond simple pattern matching to understand complex memory state logic.
|
|
50
|
+
* **Intelligent Cost Synthesis:** Processes raw Terraform plan diffs through a financial reasoning model to detect high-risk resource escalations and "silent" fiscal drifts.
|
|
51
|
+
* **Natural Language Policy Mapping:** Translates human security intent into syntactically correct, hardened Kubernetes `securityContext` configurations.
|
|
52
|
+
|
|
53
|
+
## 🧭 Core Modules
|
|
54
|
+
|
|
55
|
+
### 1. 🐧 Kernel Patch Reviewer (`patch_analyzer.py`)
|
|
56
|
+
|
|
57
|
+
* **Problem:** Manual review of Linux Kernel memory safety is time-consuming and prone to human error.
|
|
58
|
+
* **Solution:** Gemini 3 performs a "Deep Reasoning" audit on raw Git diffs to detect critical memory corruption vulnerabilities (UAF, Stale State) in seconds.
|
|
59
|
+
* **Key Output:** `analysis_results.json`
|
|
60
|
+
|
|
61
|
+
### 2. 💰 FinOps & Cloud Auditor (`cost_auditor.py`)
|
|
62
|
+
|
|
63
|
+
* **Problem:** Infrastructure-as-Code (IaC) changes can lead to accidental "Silent Disasters" and massive cloud bill spikes.
|
|
64
|
+
* **Solution:** Analyzes `terraform plan` output to identify cost anomalies—such as accidental upgrades from `t3.micro` to high-performance GPU instances.
|
|
65
|
+
* **Key Output:** `infrastructure_audit_report.json`
|
|
66
|
+
|
|
67
|
+
### 3. ☸️ K8s Policy Hardener (`k8s_policy_generator.py`)
|
|
68
|
+
|
|
69
|
+
* **Problem:** Implementing "Least Privilege" security contexts in Kubernetes is complex and often neglected.
|
|
70
|
+
* **Solution:** Translates natural language security requirements into production-ready, hardened YAML manifests (Read-only root FS, Non-root enforcement, etc.).
|
|
71
|
+
* **Key Output:** `hardened_deployment.yaml`
|
|
72
|
+
|
|
73
|
+
## 🛠️ Setup & Environment
|
|
74
|
+
|
|
75
|
+
### 1. Clone the Repository
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
git clone https://github.com/Champbreed/AegisOps-AI.git
|
|
79
|
+
cd AegisOps-AI
|
|
80
|
+
```
|
|
81
|
+
## 2. Setup
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
python3 -m venv venv
|
|
85
|
+
source venv/bin/activate
|
|
86
|
+
pip install google-genai python-dotenv
|
|
87
|
+
```
|
|
88
|
+
### 3. API Configuration
|
|
89
|
+
|
|
90
|
+
Create a `.env` file in the root directory to securely
|
|
91
|
+
store your credentials:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
echo "GEMINI_API_KEY='your_api_key_here'" > .env
|
|
95
|
+
```
|
|
96
|
+
## 🏁 Operational Dashboard
|
|
97
|
+
|
|
98
|
+
To execute the full suite of agents in sequence and generate all security reports:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
python3 main.py
|
|
102
|
+
```
|
|
103
|
+
### Pattern: Over-Privileged Container
|
|
104
|
+
|
|
105
|
+
* **Indicators:** `allowPrivilegeEscalation: true` or root user execution.
|
|
106
|
+
* **Investigation:** Pass security intent (e.g., "non-root only") to the K8s Hardener module.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## 💡 Best Practices
|
|
111
|
+
|
|
112
|
+
* **Context is King:** Provide at least 5 lines of context around Git diffs for more accurate neural reasoning.
|
|
113
|
+
* **Continuous Gating:** Run the FinOps auditor before every infrastructure change, not after.
|
|
114
|
+
* **Manual Sign-off:** Use AI findings as a high-fidelity signal, but maintain human-in-the-loop for kernel-level merges.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 🔒 Security & Safety Notes
|
|
119
|
+
|
|
120
|
+
* **Key Management:** Use CI/CD secrets for `GEMINI_API_KEY` in production.
|
|
121
|
+
* **Least Privilege:** Test "Hardened" manifests in staging first to ensure no functional regressions.
|
|
122
|
+
|
|
123
|
+
## Links
|
|
124
|
+
|
|
125
|
+
+ - **Repository**: https://github.com/Champbreed/AegisOps-AI
|
|
126
|
+
+ - **Documentation**: https://github.com/Champbreed/AegisOps-AI#readme
|
|
127
|
+
|
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
# Build Systems and Tooling
|
|
2
|
+
|
|
3
|
+
## Modern CMake
|
|
4
|
+
|
|
5
|
+
```cmake
|
|
6
|
+
cmake_minimum_required(VERSION 3.20)
|
|
7
|
+
project(MyProject VERSION 1.0.0 LANGUAGES CXX)
|
|
8
|
+
|
|
9
|
+
# Set C++ standard
|
|
10
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
11
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
12
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
13
|
+
|
|
14
|
+
# Export compile commands for tools
|
|
15
|
+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
16
|
+
|
|
17
|
+
# Compiler warnings
|
|
18
|
+
if(MSVC)
|
|
19
|
+
add_compile_options(/W4 /WX)
|
|
20
|
+
else()
|
|
21
|
+
add_compile_options(-Wall -Wextra -Wpedantic -Werror)
|
|
22
|
+
endif()
|
|
23
|
+
|
|
24
|
+
# Create library target
|
|
25
|
+
add_library(mylib
|
|
26
|
+
src/mylib.cpp
|
|
27
|
+
include/mylib.h
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
target_include_directories(mylib
|
|
31
|
+
PUBLIC
|
|
32
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
33
|
+
$<INSTALL_INTERFACE:include>
|
|
34
|
+
PRIVATE
|
|
35
|
+
${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
target_compile_features(mylib PUBLIC cxx_std_20)
|
|
39
|
+
|
|
40
|
+
# Create executable
|
|
41
|
+
add_executable(myapp src/main.cpp)
|
|
42
|
+
target_link_libraries(myapp PRIVATE mylib)
|
|
43
|
+
|
|
44
|
+
# Dependencies with FetchContent
|
|
45
|
+
include(FetchContent)
|
|
46
|
+
|
|
47
|
+
FetchContent_Declare(
|
|
48
|
+
fmt
|
|
49
|
+
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
|
|
50
|
+
GIT_TAG 10.1.1
|
|
51
|
+
)
|
|
52
|
+
FetchContent_MakeAvailable(fmt)
|
|
53
|
+
|
|
54
|
+
target_link_libraries(mylib PUBLIC fmt::fmt)
|
|
55
|
+
|
|
56
|
+
# Testing
|
|
57
|
+
enable_testing()
|
|
58
|
+
add_subdirectory(tests)
|
|
59
|
+
|
|
60
|
+
# Install rules
|
|
61
|
+
include(GNUInstallDirs)
|
|
62
|
+
install(TARGETS mylib myapp
|
|
63
|
+
EXPORT MyProjectTargets
|
|
64
|
+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
65
|
+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
66
|
+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
install(DIRECTORY include/
|
|
70
|
+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
71
|
+
)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Sanitizers
|
|
75
|
+
|
|
76
|
+
```cmake
|
|
77
|
+
# AddressSanitizer (ASan) - memory errors
|
|
78
|
+
set(CMAKE_CXX_FLAGS_ASAN
|
|
79
|
+
"-g -O1 -fsanitize=address -fno-omit-frame-pointer"
|
|
80
|
+
CACHE STRING "Flags for ASan build"
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
# UndefinedBehaviorSanitizer (UBSan)
|
|
84
|
+
set(CMAKE_CXX_FLAGS_UBSAN
|
|
85
|
+
"-g -O1 -fsanitize=undefined -fno-omit-frame-pointer"
|
|
86
|
+
CACHE STRING "Flags for UBSan build"
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
# ThreadSanitizer (TSan) - data races
|
|
90
|
+
set(CMAKE_CXX_FLAGS_TSAN
|
|
91
|
+
"-g -O1 -fsanitize=thread -fno-omit-frame-pointer"
|
|
92
|
+
CACHE STRING "Flags for TSan build"
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
# MemorySanitizer (MSan) - uninitialized reads
|
|
96
|
+
set(CMAKE_CXX_FLAGS_MSAN
|
|
97
|
+
"-g -O1 -fsanitize=memory -fno-omit-frame-pointer"
|
|
98
|
+
CACHE STRING "Flags for MSan build"
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
# Usage: cmake -DCMAKE_BUILD_TYPE=ASAN ..
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Static Analysis
|
|
105
|
+
|
|
106
|
+
```yaml
|
|
107
|
+
# .clang-tidy configuration
|
|
108
|
+
---
|
|
109
|
+
Checks: >
|
|
110
|
+
*,
|
|
111
|
+
-fuchsia-*,
|
|
112
|
+
-google-*,
|
|
113
|
+
-llvm-*,
|
|
114
|
+
-modernize-use-trailing-return-type,
|
|
115
|
+
-readability-identifier-length
|
|
116
|
+
|
|
117
|
+
WarningsAsErrors: '*'
|
|
118
|
+
|
|
119
|
+
CheckOptions:
|
|
120
|
+
- key: readability-identifier-naming.ClassCase
|
|
121
|
+
value: CamelCase
|
|
122
|
+
- key: readability-identifier-naming.FunctionCase
|
|
123
|
+
value: lower_case
|
|
124
|
+
- key: readability-identifier-naming.VariableCase
|
|
125
|
+
value: lower_case
|
|
126
|
+
- key: readability-identifier-naming.ConstantCase
|
|
127
|
+
value: UPPER_CASE
|
|
128
|
+
- key: readability-identifier-naming.MemberCase
|
|
129
|
+
value: lower_case
|
|
130
|
+
- key: readability-identifier-naming.MemberSuffix
|
|
131
|
+
value: '_'
|
|
132
|
+
- key: modernize-use-nullptr.NullMacros
|
|
133
|
+
value: 'NULL'
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Run clang-tidy
|
|
138
|
+
clang-tidy src/*.cpp -p build/
|
|
139
|
+
|
|
140
|
+
# Run cppcheck
|
|
141
|
+
cppcheck --enable=all --std=c++20 --suppress=missingInclude src/
|
|
142
|
+
|
|
143
|
+
# Run include-what-you-use
|
|
144
|
+
include-what-you-use -std=c++20 src/main.cpp
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Testing with Catch2
|
|
148
|
+
|
|
149
|
+
```cpp
|
|
150
|
+
#include <catch2/catch_test_macros.hpp>
|
|
151
|
+
#include <catch2/benchmark/catch_benchmark.hpp>
|
|
152
|
+
#include "mylib.h"
|
|
153
|
+
|
|
154
|
+
TEST_CASE("Vector operations", "[vector]") {
|
|
155
|
+
std::vector<int> vec{1, 2, 3};
|
|
156
|
+
|
|
157
|
+
SECTION("push_back") {
|
|
158
|
+
vec.push_back(4);
|
|
159
|
+
REQUIRE(vec.size() == 4);
|
|
160
|
+
REQUIRE(vec.back() == 4);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
SECTION("pop_back") {
|
|
164
|
+
vec.pop_back();
|
|
165
|
+
REQUIRE(vec.size() == 2);
|
|
166
|
+
REQUIRE(vec.back() == 2);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
TEST_CASE("Exception handling", "[exceptions]") {
|
|
171
|
+
REQUIRE_THROWS_AS(risky_function(), std::runtime_error);
|
|
172
|
+
REQUIRE_THROWS_WITH(risky_function(), "error message");
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
TEST_CASE("Floating point", "[math]") {
|
|
176
|
+
REQUIRE_THAT(compute_value(),
|
|
177
|
+
Catch::Matchers::WithinAbs(3.14, 0.01));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
BENCHMARK("Vector creation") {
|
|
181
|
+
return std::vector<int>(1000);
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
BENCHMARK("Vector fill") {
|
|
185
|
+
std::vector<int> vec(1000);
|
|
186
|
+
for (int i = 0; i < 1000; ++i) {
|
|
187
|
+
vec[i] = i;
|
|
188
|
+
}
|
|
189
|
+
return vec;
|
|
190
|
+
};
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Testing with GoogleTest
|
|
194
|
+
|
|
195
|
+
```cpp
|
|
196
|
+
#include <gtest/gtest.h>
|
|
197
|
+
#include <gmock/gmock.h>
|
|
198
|
+
#include "calculator.h"
|
|
199
|
+
|
|
200
|
+
class CalculatorTest : public ::testing::Test {
|
|
201
|
+
protected:
|
|
202
|
+
void SetUp() override {
|
|
203
|
+
calc = std::make_unique<Calculator>();
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
void TearDown() override {
|
|
207
|
+
calc.reset();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
std::unique_ptr<Calculator> calc;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
TEST_F(CalculatorTest, Addition) {
|
|
214
|
+
EXPECT_EQ(calc->add(2, 3), 5);
|
|
215
|
+
EXPECT_EQ(calc->add(-1, 1), 0);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
TEST_F(CalculatorTest, Division) {
|
|
219
|
+
EXPECT_DOUBLE_EQ(calc->divide(10, 2), 5.0);
|
|
220
|
+
EXPECT_THROW(calc->divide(10, 0), std::invalid_argument);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Parameterized tests
|
|
224
|
+
class AdditionTest : public ::testing::TestWithParam<std::tuple<int, int, int>> {};
|
|
225
|
+
|
|
226
|
+
TEST_P(AdditionTest, ValidAddition) {
|
|
227
|
+
auto [a, b, expected] = GetParam();
|
|
228
|
+
Calculator calc;
|
|
229
|
+
EXPECT_EQ(calc.add(a, b), expected);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
INSTANTIATE_TEST_SUITE_P(
|
|
233
|
+
AdditionSuite,
|
|
234
|
+
AdditionTest,
|
|
235
|
+
::testing::Values(
|
|
236
|
+
std::make_tuple(1, 2, 3),
|
|
237
|
+
std::make_tuple(-1, -2, -3),
|
|
238
|
+
std::make_tuple(0, 0, 0)
|
|
239
|
+
)
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
// Mock objects
|
|
243
|
+
class MockDatabase : public Database {
|
|
244
|
+
public:
|
|
245
|
+
MOCK_METHOD(void, connect, (const std::string&), (override));
|
|
246
|
+
MOCK_METHOD(std::string, query, (const std::string&), (override));
|
|
247
|
+
MOCK_METHOD(void, disconnect, (), (override));
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
TEST(ServiceTest, UsesDatabase) {
|
|
251
|
+
MockDatabase mock_db;
|
|
252
|
+
EXPECT_CALL(mock_db, connect("localhost"))
|
|
253
|
+
.Times(1);
|
|
254
|
+
EXPECT_CALL(mock_db, query("SELECT *"))
|
|
255
|
+
.WillOnce(::testing::Return("result"));
|
|
256
|
+
|
|
257
|
+
Service service(mock_db);
|
|
258
|
+
service.process();
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Performance Profiling
|
|
263
|
+
|
|
264
|
+
```cpp
|
|
265
|
+
// Benchmark with Google Benchmark
|
|
266
|
+
#include <benchmark/benchmark.h>
|
|
267
|
+
|
|
268
|
+
static void BM_VectorPush(benchmark::State& state) {
|
|
269
|
+
for (auto _ : state) {
|
|
270
|
+
std::vector<int> vec;
|
|
271
|
+
for (int i = 0; i < state.range(0); ++i) {
|
|
272
|
+
vec.push_back(i);
|
|
273
|
+
}
|
|
274
|
+
benchmark::DoNotOptimize(vec);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
BENCHMARK(BM_VectorPush)->Range(8, 8<<10);
|
|
278
|
+
|
|
279
|
+
static void BM_VectorReserve(benchmark::State& state) {
|
|
280
|
+
for (auto _ : state) {
|
|
281
|
+
std::vector<int> vec;
|
|
282
|
+
vec.reserve(state.range(0));
|
|
283
|
+
for (int i = 0; i < state.range(0); ++i) {
|
|
284
|
+
vec.push_back(i);
|
|
285
|
+
}
|
|
286
|
+
benchmark::DoNotOptimize(vec);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
BENCHMARK(BM_VectorReserve)->Range(8, 8<<10);
|
|
290
|
+
|
|
291
|
+
BENCHMARK_MAIN();
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
# Profiling with perf (Linux)
|
|
296
|
+
perf record -g ./myapp
|
|
297
|
+
perf report
|
|
298
|
+
|
|
299
|
+
# Profiling with Instruments (macOS)
|
|
300
|
+
instruments -t "Time Profiler" ./myapp
|
|
301
|
+
|
|
302
|
+
# Valgrind callgrind
|
|
303
|
+
valgrind --tool=callgrind ./myapp
|
|
304
|
+
kcachegrind callgrind.out.*
|
|
305
|
+
|
|
306
|
+
# Memory profiling
|
|
307
|
+
valgrind --tool=massif ./myapp
|
|
308
|
+
ms_print massif.out.*
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## Conan Package Manager
|
|
312
|
+
|
|
313
|
+
```python
|
|
314
|
+
# conanfile.txt
|
|
315
|
+
[requires]
|
|
316
|
+
fmt/10.1.1
|
|
317
|
+
spdlog/1.12.0
|
|
318
|
+
catch2/3.4.0
|
|
319
|
+
|
|
320
|
+
[generators]
|
|
321
|
+
CMakeDeps
|
|
322
|
+
CMakeToolchain
|
|
323
|
+
|
|
324
|
+
[options]
|
|
325
|
+
fmt:header_only=True
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
```cmake
|
|
329
|
+
# CMakeLists.txt with Conan
|
|
330
|
+
cmake_minimum_required(VERSION 3.20)
|
|
331
|
+
project(MyProject)
|
|
332
|
+
|
|
333
|
+
find_package(fmt REQUIRED)
|
|
334
|
+
find_package(spdlog REQUIRED)
|
|
335
|
+
find_package(Catch2 REQUIRED)
|
|
336
|
+
|
|
337
|
+
add_executable(myapp src/main.cpp)
|
|
338
|
+
target_link_libraries(myapp
|
|
339
|
+
PRIVATE
|
|
340
|
+
fmt::fmt
|
|
341
|
+
spdlog::spdlog
|
|
342
|
+
)
|
|
343
|
+
|
|
344
|
+
add_executable(tests test/main.cpp)
|
|
345
|
+
target_link_libraries(tests
|
|
346
|
+
PRIVATE
|
|
347
|
+
Catch2::Catch2WithMain
|
|
348
|
+
)
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
# Install dependencies
|
|
353
|
+
conan install . --output-folder=build --build=missing
|
|
354
|
+
cd build
|
|
355
|
+
cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake
|
|
356
|
+
cmake --build .
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
## CI/CD with GitHub Actions
|
|
360
|
+
|
|
361
|
+
```yaml
|
|
362
|
+
# .github/workflows/ci.yml
|
|
363
|
+
name: CI
|
|
364
|
+
|
|
365
|
+
on: [push, pull_request]
|
|
366
|
+
|
|
367
|
+
jobs:
|
|
368
|
+
build:
|
|
369
|
+
runs-on: ${{ matrix.os }}
|
|
370
|
+
strategy:
|
|
371
|
+
matrix:
|
|
372
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
373
|
+
compiler: [gcc, clang, msvc]
|
|
374
|
+
build_type: [Debug, Release]
|
|
375
|
+
|
|
376
|
+
steps:
|
|
377
|
+
- uses: actions/checkout@v3
|
|
378
|
+
|
|
379
|
+
- name: Install dependencies
|
|
380
|
+
run: |
|
|
381
|
+
pip install conan
|
|
382
|
+
conan install . --output-folder=build --build=missing
|
|
383
|
+
|
|
384
|
+
- name: Configure
|
|
385
|
+
run: |
|
|
386
|
+
cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
|
|
387
|
+
|
|
388
|
+
- name: Build
|
|
389
|
+
run: cmake --build build --config ${{ matrix.build_type }}
|
|
390
|
+
|
|
391
|
+
- name: Test
|
|
392
|
+
run: ctest --test-dir build -C ${{ matrix.build_type }}
|
|
393
|
+
|
|
394
|
+
sanitizers:
|
|
395
|
+
runs-on: ubuntu-latest
|
|
396
|
+
strategy:
|
|
397
|
+
matrix:
|
|
398
|
+
sanitizer: [asan, ubsan, tsan]
|
|
399
|
+
|
|
400
|
+
steps:
|
|
401
|
+
- uses: actions/checkout@v3
|
|
402
|
+
|
|
403
|
+
- name: Build with sanitizer
|
|
404
|
+
run: |
|
|
405
|
+
cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.sanitizer }}
|
|
406
|
+
cmake --build build
|
|
407
|
+
|
|
408
|
+
- name: Run tests
|
|
409
|
+
run: ctest --test-dir build
|
|
410
|
+
|
|
411
|
+
static-analysis:
|
|
412
|
+
runs-on: ubuntu-latest
|
|
413
|
+
|
|
414
|
+
steps:
|
|
415
|
+
- uses: actions/checkout@v3
|
|
416
|
+
|
|
417
|
+
- name: Run clang-tidy
|
|
418
|
+
run: |
|
|
419
|
+
cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
|
420
|
+
clang-tidy src/*.cpp -p build/
|
|
421
|
+
|
|
422
|
+
- name: Run cppcheck
|
|
423
|
+
run: cppcheck --enable=all --error-exitcode=1 src/
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
## Quick Reference
|
|
427
|
+
|
|
428
|
+
| Tool | Purpose | Command |
|
|
429
|
+
|------|---------|---------|
|
|
430
|
+
| CMake | Build system | `cmake -B build && cmake --build build` |
|
|
431
|
+
| Conan | Package manager | `conan install . --build=missing` |
|
|
432
|
+
| ASan | Memory errors | `-fsanitize=address` |
|
|
433
|
+
| UBSan | Undefined behavior | `-fsanitize=undefined` |
|
|
434
|
+
| TSan | Data races | `-fsanitize=thread` |
|
|
435
|
+
| clang-tidy | Static analysis | `clang-tidy src/*.cpp` |
|
|
436
|
+
| cppcheck | Static analysis | `cppcheck --enable=all src/` |
|
|
437
|
+
| Catch2 | Unit testing | `TEST_CASE("name") { REQUIRE(...); }` |
|
|
438
|
+
| GoogleTest | Unit testing | `TEST(Suite, Name) { EXPECT_EQ(...); }` |
|
|
439
|
+
| Google Benchmark | Performance | `BENCHMARK(func)->Range(...)` |
|
|
440
|
+
| Valgrind | Memory profiler | `valgrind --tool=memcheck ./app` |
|