Skip to content
Merged

V2 #18

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0bdd789
add dgate cli to the readme
bubbajoe Jul 10, 2025
21dfce0
fix deadlock and fix reverse proxy scheme issue
bubbajoe Jul 12, 2025
625ff27
v2: initial commit
bubbajoe Jan 17, 2026
9325409
add docker and github action
bubbajoe Jan 17, 2026
93fbda4
update cargo toml and rm old dgate-v2 dir
bubbajoe Jan 18, 2026
38a823e
update github actions
bubbajoe Jan 18, 2026
c7bd170
cargo format and change keyworks for publishing crate
bubbajoe Jan 18, 2026
0d570e9
Add pre-commit hooks and fix clippy warnings
bubbajoe Jan 18, 2026
8cf3073
clean up code
bubbajoe Jan 18, 2026
8917f52
Merge branch 'main' into v2
bubbajoe Jan 18, 2026
85bd1a7
update dockerfile
bubbajoe Jan 18, 2026
d601490
add raft for clustering support to propagate resources
bubbajoe Jan 18, 2026
3004ec2
fixed replication issues
bubbajoe Jan 18, 2026
285200a
fix formatting issues and node_id issues
bubbajoe Jan 18, 2026
2374230
replication raft and simple; add functional tests
bubbajoe Jan 18, 2026
5472d7b
modify docs to refelct current implementation
bubbajoe Jan 18, 2026
c90c7b8
fix storage bug that caused deadlock for http2
bubbajoe Jan 18, 2026
2371408
add js and ts functional tests and update readme
bubbajoe Jan 18, 2026
6f33f7c
fix the raft consensus implementation
bubbajoe Jan 18, 2026
9e32889
clippy fix
bubbajoe Jan 18, 2026
c646362
updates docs
bubbajoe Jan 18, 2026
7d6aed7
update readme and use the modules example dir
bubbajoe Jan 18, 2026
5be3042
fix broken cluster, update hooks and remove functional tests
bubbajoe Jan 19, 2026
3491956
update workflow to make clippy optional and make lint changes
bubbajoe Jan 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
38 changes: 34 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
.*/
dashboard/
dist/
# Build artifacts
target/
*.rs.bk

# IDE
.idea/
.vscode/
*.swp
*.swo

# Git
.git/
.gitignore

# Test files
functional-tests/
go.work*
perf-tests/
**/node_modules/

# Documentation
*.md
!README.md

# Misc
.DS_Store
Thumbs.db
*.log
proxy-results.json

# Config files (will be mounted at runtime)
config*.yaml
*.dgate.yaml

# Development modules
modules/
33 changes: 33 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh
# Pre-commit hook for dgate
# Runs rustfmt and clippy before allowing commits

set -e

echo "🔍 Running pre-commit checks..."

# Check if cargo is available
if ! command -v cargo &> /dev/null; then
echo "❌ cargo not found. Please install Rust."
exit 1
fi

# Get list of staged Rust files
STAGED_RS_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep '\.rs$' || true)

if [ -z "$STAGED_RS_FILES" ]; then
echo "✅ No Rust files staged, skipping checks."
exit 0
fi

echo "📝 Checking formatting with rustfmt..."
if ! cargo fmt -- --check; then
echo ""
echo "❌ Formatting issues found!"
echo " Run 'cargo fmt' to fix them, then stage the changes."
exit 1
fi
echo "✅ Formatting OK"

echo ""
echo "🎉 All pre-commit checks passed!"
125 changes: 95 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,102 @@ name: DGate CI

on:
push:
branches: [ "**" ]
branches: ["**"]
pull_request:
branches: [main]

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
build_test:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Check formatting
run: cargo fmt --all -- --check

- name: Clippy lints
if: always()always()
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Build
run: cargo build --release --all-targets

- name: Run tests
run: cargo test --verbose

- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: dgate-binaries
path: |
target/release/dgate-server
target/release/dgate-cli
retention-days: 7

coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum

- name: Build & Install
run: |
go mod download
go build -v ./...

- name: Test
run: |
go test -coverprofile=coverage.txt -v ./...
go tool cover -func=coverage.txt

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: dgate-io/dgate-api

- name: Benchmark
run: |
go test -bench=. -run=^# ./...
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Generate coverage report
run: cargo llvm-cov --all-features --lcov --output-path lcov.info

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
fail_ci_if_error: false

# Cross-platform build check
build-matrix:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Build
run: cargo build --release
52 changes: 0 additions & 52 deletions .github/workflows/e2e.yml

This file was deleted.

122 changes: 122 additions & 0 deletions .github/workflows/functional.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: DGate Functional Tests

on:
push:
branches: [main]
pull_request:
branches: [main]

env:
CARGO_TERM_COLOR: always
DGATE_PORT: 8080
DGATE_ADMIN_PORT: 9080
TEST_SERVER_PORT: 19999

jobs:
functional-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Build DGate
run: cargo build --release --bin dgate-server --bin dgate-cli

- name: Setup Node.js (for test servers)
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install test dependencies
run: |
cd tests/functional-tests/websocket && npm ci
cd ../grpc && npm ci

- name: Install netcat
run: sudo apt-get update && sudo apt-get install -y netcat-openbsd

- name: Run HTTP/2 Tests
run: ./tests/functional-tests/http2/run-test.sh
continue-on-error: true

- name: Run WebSocket Tests
run: ./tests/functional-tests/websocket/run-test.sh
continue-on-error: true

- name: Run gRPC Tests
run: ./tests/functional-tests/grpc/run-test.sh
continue-on-error: true

- name: Run QUIC Tests
run: ./tests/functional-tests/quic/run-test.sh
continue-on-error: true

- name: Run Simple Replication Cluster Tests
run: ./tests/functional-tests/simple-replication/run-test.sh
continue-on-error: true

- name: Run Raft Consensus Cluster Tests
run: ./tests/functional-tests/raft-consensus/run-test.sh
continue-on-error: true

- name: Upload test logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-logs
path: |
/tmp/dgate*.log
/tmp/*-server.log
retention-days: 7

# Docker-based functional tests
docker-tests:
runs-on: ubuntu-latest
needs: [functional-tests]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
push: false
load: true
tags: dgate:test
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Test Docker image
run: |
# Start container
docker run -d --name dgate-test \
-p 8080:80 -p 9080:9080 \
-e LOG_LEVEL=debug \
dgate:test \
-c /dev/null

# Wait for startup
sleep 5

# Check health
curl -f http://localhost:9080/health || exit 1

# Cleanup
docker stop dgate-test
docker rm dgate-test
Loading
Loading