Skip to content

Commit 5fa2989

Browse files
committed
Initial check in
0 parents  commit 5fa2989

37 files changed

+2319
-0
lines changed

.dockerignore

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Rust
2+
target/
3+
**/*.rs.bk
4+
Cargo.lock
5+
6+
# Git
7+
.git/
8+
.gitignore
9+
10+
# IDE
11+
.vscode/
12+
.idea/
13+
*.swp
14+
*.swo
15+
16+
# OS
17+
.DS_Store
18+
Thumbs.db
19+
20+
# Logs
21+
*.log
22+
logs/
23+
24+
# Environment
25+
.env
26+
.env.local
27+
28+
# Documentation
29+
docs/
30+
*.md
31+
!README.md
32+
33+
# CI/CD
34+
.github/
35+
36+
# Docker
37+
Dockerfile*
38+
docker-compose*
39+
.dockerignore
40+
41+
# Node.js
42+
node_modules/
43+
npm-debug.log*
44+
45+
# Temporary files
46+
*.tmp
47+
*.temp
48+
/tmp/

.github/workflows/ci.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
test:
14+
name: Test Suite
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest, windows-latest, macos-latest]
19+
rust: [stable, beta]
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Install Rust
26+
uses: dtolnay/rust-toolchain@master
27+
with:
28+
toolchain: ${{ matrix.rust }}
29+
components: rustfmt, clippy
30+
31+
- name: Cache dependencies
32+
uses: actions/cache@v3
33+
with:
34+
path: |
35+
~/.cargo/registry
36+
~/.cargo/git
37+
target
38+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
39+
40+
- name: Check formatting
41+
run: cargo fmt --all -- --check
42+
43+
- name: Run clippy
44+
run: cargo clippy --all-targets --all-features -- -D warnings
45+
46+
- name: Run tests
47+
run: cargo test --all --verbose
48+
49+
- name: Run benchmarks (dry run)
50+
run: cargo bench --all --no-run
51+
52+
build:
53+
name: Build Release
54+
runs-on: ubuntu-latest
55+
needs: test
56+
57+
steps:
58+
- name: Checkout code
59+
uses: actions/checkout@v4
60+
61+
- name: Install Rust
62+
uses: dtolnay/rust-toolchain@stable
63+
64+
- name: Cache dependencies
65+
uses: actions/cache@v3
66+
with:
67+
path: |
68+
~/.cargo/registry
69+
~/.cargo/git
70+
target
71+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
72+
73+
- name: Build release
74+
run: cargo build --release --all
75+
76+
- name: Upload CLI binary
77+
uses: actions/upload-artifact@v3
78+
with:
79+
name: smart-diff-cli-linux
80+
path: target/release/smart-diff
81+
82+
- name: Upload server binary
83+
uses: actions/upload-artifact@v3
84+
with:
85+
name: smart-diff-server-linux
86+
path: target/release/smart-diff-server
87+
88+
security:
89+
name: Security Audit
90+
runs-on: ubuntu-latest
91+
92+
steps:
93+
- name: Checkout code
94+
uses: actions/checkout@v4
95+
96+
- name: Install Rust
97+
uses: dtolnay/rust-toolchain@stable
98+
99+
- name: Install cargo-audit
100+
run: cargo install cargo-audit
101+
102+
- name: Run security audit
103+
run: cargo audit

.github/workflows/release.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
create-release:
13+
name: Create Release
14+
runs-on: ubuntu-latest
15+
outputs:
16+
upload_url: ${{ steps.create_release.outputs.upload_url }}
17+
18+
steps:
19+
- name: Create Release
20+
id: create_release
21+
uses: actions/create-release@v1
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
with:
25+
tag_name: ${{ github.ref }}
26+
release_name: Release ${{ github.ref }}
27+
draft: false
28+
prerelease: false
29+
30+
build-release:
31+
name: Build Release
32+
needs: create-release
33+
runs-on: ${{ matrix.os }}
34+
strategy:
35+
matrix:
36+
include:
37+
- os: ubuntu-latest
38+
target: x86_64-unknown-linux-gnu
39+
suffix: ""
40+
- os: windows-latest
41+
target: x86_64-pc-windows-msvc
42+
suffix: ".exe"
43+
- os: macos-latest
44+
target: x86_64-apple-darwin
45+
suffix: ""
46+
47+
steps:
48+
- name: Checkout code
49+
uses: actions/checkout@v4
50+
51+
- name: Install Rust
52+
uses: dtolnay/rust-toolchain@stable
53+
with:
54+
targets: ${{ matrix.target }}
55+
56+
- name: Cache dependencies
57+
uses: actions/cache@v3
58+
with:
59+
path: |
60+
~/.cargo/registry
61+
~/.cargo/git
62+
target
63+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
64+
65+
- name: Build release
66+
run: cargo build --release --target ${{ matrix.target }}
67+
68+
- name: Package binaries
69+
shell: bash
70+
run: |
71+
mkdir -p release
72+
cp target/${{ matrix.target }}/release/smart-diff${{ matrix.suffix }} release/
73+
cp target/${{ matrix.target }}/release/smart-diff-server${{ matrix.suffix }} release/
74+
cp README.md LICENSE release/
75+
tar -czf smart-diff-${{ matrix.target }}.tar.gz -C release .
76+
77+
- name: Upload Release Asset
78+
uses: actions/upload-release-asset@v1
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
with:
82+
upload_url: ${{ needs.create-release.outputs.upload_url }}
83+
asset_path: ./smart-diff-${{ matrix.target }}.tar.gz
84+
asset_name: smart-diff-${{ matrix.target }}.tar.gz
85+
asset_content_type: application/gzip

.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Rust
2+
/target/
3+
**/*.rs.bk
4+
Cargo.lock
5+
6+
# IDE
7+
.vscode/
8+
.idea/
9+
*.swp
10+
*.swo
11+
*~
12+
13+
# OS
14+
.DS_Store
15+
Thumbs.db
16+
17+
# Logs
18+
*.log
19+
logs/
20+
21+
# Environment
22+
.env
23+
.env.local
24+
25+
# Build artifacts
26+
/dist/
27+
/build/
28+
29+
# Node.js (for web UI)
30+
node_modules/
31+
npm-debug.log*
32+
yarn-debug.log*
33+
yarn-error.log*
34+
35+
# Test artifacts
36+
/coverage/
37+
*.profraw
38+
39+
# Temporary files
40+
*.tmp
41+
*.temp
42+
/tmp/

Cargo.toml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
[workspace]
2+
members = [
3+
"crates/parser",
4+
"crates/semantic-analysis",
5+
"crates/diff-engine",
6+
"crates/cli",
7+
"crates/web-ui"
8+
]
9+
resolver = "2"
10+
11+
[workspace.package]
12+
version = "0.1.0"
13+
edition = "2021"
14+
authors = ["Smart Code Diff Team"]
15+
license = "MIT"
16+
repository = "https://github.com/your-org/smart-code-diff"
17+
description = "A next-generation code diffing tool that performs structural and semantic comparison"
18+
19+
[workspace.dependencies]
20+
# Core dependencies
21+
tokio = { version = "1.0", features = ["full"] }
22+
serde = { version = "1.0", features = ["derive"] }
23+
serde_json = "1.0"
24+
anyhow = "1.0"
25+
thiserror = "1.0"
26+
tracing = "0.1"
27+
tracing-subscriber = "0.3"
28+
29+
# Tree-sitter dependencies
30+
tree-sitter = "0.20"
31+
tree-sitter-java = "0.20"
32+
tree-sitter-python = "0.20"
33+
tree-sitter-javascript = "0.20"
34+
tree-sitter-cpp = "0.20"
35+
tree-sitter-c-sharp = "0.20"
36+
37+
# CLI dependencies
38+
clap = { version = "4.0", features = ["derive"] }
39+
colored = "2.0"
40+
41+
# Web dependencies
42+
axum = "0.7"
43+
tower = "0.4"
44+
tower-http = { version = "0.5", features = ["cors", "fs"] }
45+
46+
# Algorithm dependencies
47+
petgraph = "0.6"
48+
rayon = "1.7"
49+
50+
# Testing dependencies
51+
criterion = "0.5"
52+
proptest = "1.0"

Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Multi-stage Docker build for Smart Code Diff
2+
3+
# Build stage
4+
FROM rust:1.75 as builder
5+
6+
WORKDIR /app
7+
8+
# Copy manifests
9+
COPY Cargo.toml Cargo.lock ./
10+
COPY crates/ ./crates/
11+
12+
# Build dependencies (this is cached if dependencies don't change)
13+
RUN cargo build --release --bin smart-diff-server
14+
15+
# Runtime stage
16+
FROM debian:bookworm-slim
17+
18+
# Install runtime dependencies
19+
RUN apt-get update && apt-get install -y \
20+
ca-certificates \
21+
&& rm -rf /var/lib/apt/lists/*
22+
23+
# Create app user
24+
RUN useradd -r -s /bin/false smartdiff
25+
26+
# Copy binary from builder stage
27+
COPY --from=builder /app/target/release/smart-diff-server /usr/local/bin/smart-diff-server
28+
29+
# Set ownership and permissions
30+
RUN chown smartdiff:smartdiff /usr/local/bin/smart-diff-server
31+
RUN chmod +x /usr/local/bin/smart-diff-server
32+
33+
# Switch to app user
34+
USER smartdiff
35+
36+
# Expose port
37+
EXPOSE 3000
38+
39+
# Health check
40+
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
41+
CMD curl -f http://localhost:3000/api/health || exit 1
42+
43+
# Run the server
44+
CMD ["smart-diff-server"]

0 commit comments

Comments
 (0)