Skip to content

Commit 255229a

Browse files
committed
dev: added CI/CD pipeline
1 parent 7630a11 commit 255229a

9 files changed

Lines changed: 169 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: DevSecOps CLI CI/CD
2+
3+
on: [ push, pull_request ]
4+
5+
env:
6+
DOCKERHUB_REPO: monokkay/devsecops-cli
7+
CARGO_TERM_COLOR: always
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Setup Rust
16+
uses: actions-rs/toolchain@v1
17+
with:
18+
profile: minimal
19+
toolchain: stable
20+
components: rustfmt, clippy
21+
override: true
22+
23+
- name: Cache dependencies
24+
uses: actions/cache@v3
25+
with:
26+
path: |
27+
~/.cargo/registry
28+
~/.cargo/git
29+
target
30+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
31+
32+
- name: Run tests
33+
run: cargo test --all-features --workspace -- --nocapture
34+
35+
- name: Security audit
36+
run: cargo audit --deny warnings
37+
38+
- name: Format check
39+
run: cargo fmt --all -- --check
40+
41+
- name: Clippy check
42+
run: cargo clippy --all-targets --all-features -- -D warnings
43+
44+
release:
45+
needs: test
46+
runs-on: ubuntu-latest
47+
if: startsWith(github.ref, 'refs/tags/v')
48+
49+
steps:
50+
- uses: actions/checkout@v4
51+
52+
- name: Login to DockerHub
53+
uses: docker/login-action@v2
54+
with:
55+
username: ${{ secrets.DOCKERHUB_USERNAME }}
56+
password: ${{ secrets.DOCKERHUB_TOKEN }}
57+
58+
- name: Setup Docker Buildx
59+
uses: docker/setup-buildx-action@v2
60+
61+
- name: Build and push Docker image
62+
uses: docker/build-push-action@v4
63+
with:
64+
context: .
65+
platforms: linux/amd64,linux/arm64
66+
push: true
67+
tags: |
68+
${{ env.DOCKERHUB_REPO }}:latest
69+
${{ env.DOCKERHUB_REPO }}:${{ github.ref_name }}
70+
build-args: |
71+
RUST_VERSION=1.70.0
72+
73+
- name: Create GitHub release
74+
uses: softprops/action-gh-release@v1
75+
with:
76+
name: ${{ github.ref_name }}
77+
body: ${{ github.event.release.body }}
78+
draft: false
79+
prerelease: false
80+
files: |
81+
target/release/monokkai
82+
target/release/monokkai-http

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ reqwest = { version = "0.11", features = ["blocking", "json"] }
1515
serde = { version = "1.0", features = ["derive"] }
1616
serde_json = "1.0"
1717
jsonwebtoken = "8.0"
18-
dotenv = "0.15" # For .env config
19-
shellexpand = "3.0" # For path expansion
18+
dotenv = "0.15"
19+
shellexpand = "3.0"
2020
colored = { version = "2.0", features = ["no-color"] }
21-
terminal_size = "0.2"
21+
terminal_size = "0.2"
22+
libloading = "0.8"

src/.github/workflows/ci.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/core/config.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use serde::{Deserialize, Serialize};
2+
use std::collections::HashMap;
3+
4+
#[derive(Serialize, Deserialize)]
5+
pub struct ModuleConfig {
6+
pub enabled: bool,
7+
pub settings: HashMap<String, String>,
8+
}
9+
10+
#[derive(Serialize, Deserialize)]
11+
pub struct AppConfig {
12+
pub version: String,
13+
pub modules: HashMap<String, ModuleConfig>,
14+
}
15+
16+
impl AppConfig {
17+
pub fn load() -> Self {
18+
// Loading from ... config.toml + env vars
19+
}
20+
}

src/core/plugin.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
use libloading::{Library, Symbol};
2+
use std::path::{Path, PathBuf};
3+
use std::sync::Arc;
4+
use thiserror::Error;
5+
6+
#[derive(Error, Debug)]
7+
pub enum PluginError {
8+
#[error("Failed to load library: {0}")]
9+
LibraryError(#[from] libloading::Error),
10+
#[error("Plugin initialization failed")]
11+
InitError,
12+
}
13+
14+
pub trait Plugin: Send + Sync {
15+
fn name(&self) -> &str;
16+
fn execute(&self, args: Vec<String>) -> Result<(), Box<dyn std::error::Error>>;
17+
}
18+
19+
type PluginInit = unsafe fn() -> *mut dyn Plugin;
20+
21+
pub struct PluginManager {
22+
plugins: Vec<Arc<dyn Plugin>>,
23+
libraries: Vec<Library>,
24+
}
25+
26+
impl PluginManager {
27+
pub fn new() -> Self {
28+
Self {
29+
plugins: Vec::new(),
30+
libraries: Vec::new(),
31+
}
32+
}
33+
34+
pub fn load(&mut self, path: impl AsRef<Path>) -> Result<(), PluginError> {
35+
let path = path.as_ref();
36+
unsafe {
37+
let lib = Library::new(path)?;
38+
let init: Symbol<PluginInit> = lib.get(b"init")?;
39+
let plugin = Box::from_raw(init());
40+
41+
self.plugins.push(Arc::from(plugin));
42+
self.libraries.push(lib);
43+
44+
Ok(())
45+
}
46+
}
47+
48+
pub fn get_plugin(&self, name: &str) -> Option<&Arc<dyn Plugin>> {
49+
self.plugins.iter().find(|p| p.name() == name)
50+
}
51+
}

src/core/utils/config.rs

Whitespace-only changes.

src/modules/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
pub mod git;
2-
pub mod docker;
3-
// pub mod auth;
2+
pub mod docker;

0 commit comments

Comments
 (0)