Skip to content

Commit 658c134

Browse files
authored
Merge pull request #200 from devscafecommunity/feature/M1.1.5-ci-cd-pipeline
Feature/m1.1.5 ci cd pipeline
2 parents 9134e86 + de8dc2d commit 658c134

4 files changed

Lines changed: 598 additions & 22 deletions

File tree

.github/workflows/ci.yml

Lines changed: 78 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,106 @@
1-
name: CI/CD Pipeline
1+
name: Rust CI/CD
22

33
on:
4+
push:
5+
branches: [main, develop]
6+
paths:
7+
- 'src/**'
8+
- 'crates/**'
9+
- 'Cargo.toml'
10+
- 'Cargo.lock'
11+
- '.github/workflows/ci.yml'
12+
pull_request:
13+
branches: [main, develop]
14+
paths:
15+
- 'src/**'
16+
- 'crates/**'
17+
- 'Cargo.toml'
18+
- 'Cargo.lock'
419
workflow_dispatch:
520

621
jobs:
7-
build:
8-
name: Build & Test
22+
test:
23+
name: Test & Lint
924
runs-on: ${{ matrix.os }}
1025
strategy:
1126
matrix:
1227
os: [ubuntu-latest, windows-latest, macos-latest]
1328

1429
steps:
15-
- uses: actions/checkout@v3
30+
- uses: actions/checkout@v4
1631

1732
- name: Setup Rust
18-
uses: actions-rs/toolchain@v1
33+
uses: dtolnay/rust-toolchain@stable
1934
with:
20-
toolchain: stable
21-
override: true
22-
23-
- name: Setup Python
24-
uses: actions/setup-python@v4
25-
with:
26-
python-version: '3.11'
35+
components: rustfmt, clippy
2736

2837
- name: Cache cargo
29-
uses: actions/cache@v3
38+
uses: Swatinem/rust-cache@v2
3039
with:
31-
path: ~/.cargo
32-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
40+
workspaces: '.'
3341

34-
- name: Build Rust
35-
run: cargo build --verbose --release
42+
- name: Build
43+
run: cargo build --verbose
3644

3745
- name: Run tests
3846
run: cargo test --verbose
3947

40-
- name: Lint Rust
41-
run: cargo clippy -- -D warnings
48+
- name: Lint (clippy)
49+
run: cargo clippy --all-targets --all-features -- -D warnings
50+
51+
- name: Format check
52+
run: cargo fmt -- --check
53+
54+
coverage:
55+
name: Code Coverage
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Setup Rust
61+
uses: dtolnay/rust-toolchain@stable
62+
63+
- name: Install tarpaulin
64+
run: cargo install cargo-tarpaulin
65+
66+
- name: Generate coverage
67+
run: cargo tarpaulin --workspace --out Xml --exclude-files tests/* --timeout 300
68+
69+
- name: Upload coverage to Codecov
70+
uses: codecov/codecov-action@v3
71+
with:
72+
files: ./cobertura.xml
73+
flags: rust
74+
fail_ci_if_error: false
4275

4376
security:
4477
name: Security Audit
4578
runs-on: ubuntu-latest
4679
steps:
47-
- uses: actions/checkout@v3
48-
- uses: rustsec/audit-check-action@v1
80+
- uses: actions/checkout@v4
81+
82+
- name: Setup Rust
83+
uses: dtolnay/rust-toolchain@stable
84+
85+
- name: Install cargo-audit
86+
run: cargo install cargo-audit
87+
88+
- name: Run security audit
89+
run: cargo audit
90+
91+
release-build:
92+
name: Release Build
93+
runs-on: ubuntu-latest
94+
steps:
95+
- uses: actions/checkout@v4
96+
97+
- name: Setup Rust
98+
uses: dtolnay/rust-toolchain@stable
99+
100+
- name: Cache cargo
101+
uses: Swatinem/rust-cache@v2
49102
with:
50-
token: ${{ secrets.GITHUB_TOKEN }}
103+
workspaces: '.'
104+
105+
- name: Build release
106+
run: cargo build --release --verbose

.github/workflows/cpp-build.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: C++ CI/CD
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
paths:
7+
- 'crates/pandora-memory/**'
8+
- 'crates/odlaguna-watchdog/**'
9+
- 'CMakeLists.txt'
10+
- 'cmake/**'
11+
- '.github/workflows/cpp-build.yml'
12+
pull_request:
13+
branches: [main, develop]
14+
paths:
15+
- 'crates/pandora-memory/**'
16+
- 'crates/odlaguna-watchdog/**'
17+
- 'CMakeLists.txt'
18+
- 'cmake/**'
19+
workflow_dispatch:
20+
21+
jobs:
22+
build:
23+
name: Build & Unit Tests
24+
runs-on: ${{ matrix.os }}
25+
strategy:
26+
matrix:
27+
os: [ubuntu-latest, windows-latest, macos-latest]
28+
include:
29+
- os: ubuntu-latest
30+
compiler: gcc
31+
cxx_compiler: g++
32+
- os: windows-latest
33+
compiler: msvc
34+
cxx_compiler: cl
35+
- os: macos-latest
36+
compiler: clang
37+
cxx_compiler: clang++
38+
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- name: Setup CMake
43+
uses: jwlawson/actions-setup-cmake@v1
44+
with:
45+
cmake-version: 3.25.x
46+
47+
- name: Setup build dependencies (Ubuntu)
48+
if: runner.os == 'Linux'
49+
run: |
50+
sudo apt-get update
51+
sudo apt-get install -y build-essential nlohmann-json3-dev
52+
53+
- name: Setup build dependencies (macOS)
54+
if: runner.os == 'macOS'
55+
run: |
56+
brew install cmake nlohmann-json
57+
58+
- name: Create build directory
59+
run: cmake -E make_directory ${{runner.workspace}}/build
60+
61+
- name: Configure CMake
62+
shell: bash
63+
working-directory: ${{runner.workspace}}/build
64+
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release
65+
66+
- name: Build
67+
working-directory: ${{runner.workspace}}/build
68+
shell: bash
69+
run: cmake --build . --config Release --parallel
70+
71+
- name: Run unit tests
72+
working-directory: ${{runner.workspace}}/build
73+
shell: bash
74+
run: ctest --output-on-failure --verbose
75+
76+
- name: Run clang-tidy (Ubuntu)
77+
if: runner.os == 'Linux'
78+
working-directory: ${{runner.workspace}}/build
79+
continue-on-error: true
80+
run: |
81+
sudo apt-get install -y clang-tidy
82+
cmake --build . --target clang-tidy || true
83+
84+
static-analysis:
85+
name: Static Analysis
86+
runs-on: ubuntu-latest
87+
steps:
88+
- uses: actions/checkout@v4
89+
90+
- name: Setup CMake
91+
uses: jwlawson/actions-setup-cmake@v1
92+
with:
93+
cmake-version: 3.25.x
94+
95+
- name: Install dependencies
96+
run: |
97+
sudo apt-get update
98+
sudo apt-get install -y build-essential cppcheck nlohmann-json3-dev
99+
100+
- name: Run cppcheck
101+
run: |
102+
cppcheck --enable=all --suppress=missingIncludeSystem \
103+
--error-exitcode=1 crates/pandora-memory crates/odlaguna-watchdog || true

.github/workflows/docker-build.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Docker Build & Push
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'Dockerfile'
8+
- 'docker-compose.yml'
9+
- 'docker/**'
10+
- 'src/**'
11+
- 'crates/**'
12+
- 'Cargo.toml'
13+
- 'Cargo.lock'
14+
- 'CMakeLists.txt'
15+
- '.github/workflows/docker-build.yml'
16+
workflow_dispatch:
17+
schedule:
18+
# Build nightly at 2 AM UTC
19+
- cron: '0 2 * * *'
20+
21+
env:
22+
REGISTRY: ghcr.io
23+
IMAGE_NAME: ${{ github.repository }}
24+
25+
jobs:
26+
build:
27+
runs-on: ubuntu-latest
28+
permissions:
29+
contents: read
30+
packages: write
31+
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- name: Set up Docker Buildx
36+
uses: docker/setup-buildx-action@v3
37+
38+
- name: Log in to Container Registry
39+
if: github.event_name != 'pull_request'
40+
uses: docker/login-action@v3
41+
with:
42+
registry: ${{ env.REGISTRY }}
43+
username: ${{ github.actor }}
44+
password: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Extract metadata
47+
id: meta
48+
uses: docker/metadata-action@v5
49+
with:
50+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
51+
tags: |
52+
type=ref,event=branch
53+
type=semver,pattern={{version}}
54+
type=semver,pattern={{major}}.{{minor}}
55+
type=sha
56+
type=raw,value=latest,enable={{is_default_branch}}
57+
58+
- name: Build and push Docker image
59+
uses: docker/build-push-action@v5
60+
with:
61+
context: .
62+
push: ${{ github.event_name != 'pull_request' }}
63+
tags: ${{ steps.meta.outputs.tags }}
64+
labels: ${{ steps.meta.outputs.labels }}
65+
cache-from: type=gha
66+
cache-to: type=gha,mode=max
67+
68+
docker-compose-test:
69+
name: Docker Compose Integration Test
70+
runs-on: ubuntu-latest
71+
steps:
72+
- uses: actions/checkout@v4
73+
74+
- name: Set up Docker Buildx
75+
uses: docker/setup-buildx-action@v3
76+
77+
- name: Build images
78+
run: docker-compose -f docker-compose.yml build
79+
80+
- name: Start services
81+
run: |
82+
docker-compose -f docker-compose.yml up -d
83+
sleep 10
84+
85+
- name: Verify services are running
86+
run: |
87+
docker-compose -f docker-compose.yml ps
88+
docker-compose -f docker-compose.yml exec -T mimi sh -c 'echo "Mimi service running"'
89+
90+
- name: Collect logs
91+
if: always()
92+
run: docker-compose -f docker-compose.yml logs
93+
94+
- name: Stop services
95+
if: always()
96+
run: docker-compose -f docker-compose.yml down -v

0 commit comments

Comments
 (0)