Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# pre-commit hook: runs fmt check, build, and clippy before every commit.
set -e

echo "==> [pre-commit] Checking formatting..."
cargo fmt --all -- --check

echo "==> [pre-commit] Building..."
cargo build --all --quiet

echo "==> [pre-commit] Running clippy..."
cargo clippy --all-targets --all-features -- -D warnings

echo "==> [pre-commit] All checks passed!"
76 changes: 76 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: CI

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

jobs:
check:
name: Format / Clippy / Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install stable Rust
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') }}

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

- name: Clippy (no warnings)
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Run unit & integration tests
run: cargo test --all

e2e:
name: End-to-End smoke test
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v4

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

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

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

- name: Start server in background
run: |
./target/release/server &
echo "SERVER_PID=$!" >> "$GITHUB_ENV"
# Wait for server to be ready
sleep 1

- name: Send a message via client (non-interactive)
run: |
# Use a here-doc to pipe commands into the client's stdin
# The client reads stdin line by line; we send a message then leave.
printf 'send Hello from CI!\nleave\n' | \
HOST=127.0.0.1 PORT=8080 USERNAME=ci_bot ./target/release/client
EXIT=$?
kill "$SERVER_PID" || true
exit $EXIT
15 changes: 1 addition & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
target/
290 changes: 290 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading