Skip to content

Commit 82d699c

Browse files
committed
Add GitHub Actions CI and Makefile
- Add .github/workflows/ci.yml with jobs for: - check: cargo check - fmt: formatting verification - clippy: linting with warnings as errors - test: run all tests - doc: documentation generation - ci-success: summary job - Add Makefile with common development commands: - make ci: full CI pipeline - make test: run tests - make fmt/fmt-fix: format checking and fixing - make clippy/clippy-fix: linting - make doc/doc-open: documentation - make quick: fast development checks - Fix all clippy warnings: - Replace manual range contains with (0.0..=1.0).contains() - Replace map_or(false, ..) with is_some_and() - Add #[allow] for intentional patterns (module_inception, type_complexity) - Rename from_iter to collect_from to avoid trait confusion - Apply rustfmt formatting to all files
1 parent 9fa3996 commit 82d699c

18 files changed

Lines changed: 383 additions & 111 deletions

File tree

.github/workflows/ci.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
workflow_dispatch:
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
RUSTFLAGS: -Dwarnings
13+
14+
jobs:
15+
check:
16+
name: Check
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Install Rust toolchain
22+
uses: dtolnay/rust-action@stable
23+
24+
- name: Cache cargo registry
25+
uses: actions/cache@v4
26+
with:
27+
path: |
28+
~/.cargo/registry
29+
~/.cargo/git
30+
target
31+
key: ${{ runner.os }}-cargo-check-${{ hashFiles('**/Cargo.lock') }}
32+
restore-keys: |
33+
${{ runner.os }}-cargo-check-
34+
35+
- name: Run cargo check
36+
run: cargo check --all-targets --all-features
37+
38+
fmt:
39+
name: Format
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
44+
- name: Install Rust toolchain
45+
uses: dtolnay/rust-action@stable
46+
with:
47+
components: rustfmt
48+
49+
- name: Check formatting
50+
run: cargo fmt --all -- --check
51+
52+
clippy:
53+
name: Clippy
54+
runs-on: ubuntu-latest
55+
steps:
56+
- uses: actions/checkout@v4
57+
58+
- name: Install Rust toolchain
59+
uses: dtolnay/rust-action@stable
60+
with:
61+
components: clippy
62+
63+
- name: Cache cargo registry
64+
uses: actions/cache@v4
65+
with:
66+
path: |
67+
~/.cargo/registry
68+
~/.cargo/git
69+
target
70+
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
71+
restore-keys: |
72+
${{ runner.os }}-cargo-clippy-
73+
74+
- name: Run clippy
75+
run: cargo clippy --all-targets --all-features -- -D warnings
76+
77+
test:
78+
name: Test
79+
runs-on: ubuntu-latest
80+
steps:
81+
- uses: actions/checkout@v4
82+
83+
- name: Install Rust toolchain
84+
uses: dtolnay/rust-action@stable
85+
86+
- name: Cache cargo registry
87+
uses: actions/cache@v4
88+
with:
89+
path: |
90+
~/.cargo/registry
91+
~/.cargo/git
92+
target
93+
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
94+
restore-keys: |
95+
${{ runner.os }}-cargo-test-
96+
97+
- name: Run tests
98+
run: cargo test --all-features
99+
100+
doc:
101+
name: Documentation
102+
runs-on: ubuntu-latest
103+
steps:
104+
- uses: actions/checkout@v4
105+
106+
- name: Install Rust toolchain
107+
uses: dtolnay/rust-action@stable
108+
109+
- name: Cache cargo registry
110+
uses: actions/cache@v4
111+
with:
112+
path: |
113+
~/.cargo/registry
114+
~/.cargo/git
115+
target
116+
key: ${{ runner.os }}-cargo-doc-${{ hashFiles('**/Cargo.lock') }}
117+
restore-keys: |
118+
${{ runner.os }}-cargo-doc-
119+
120+
- name: Check documentation
121+
run: cargo doc --no-deps --all-features
122+
env:
123+
RUSTDOCFLAGS: -Dwarnings
124+
125+
# Summary job that depends on all other jobs
126+
ci-success:
127+
name: CI Success
128+
needs: [check, fmt, clippy, test, doc]
129+
runs-on: ubuntu-latest
130+
if: always()
131+
steps:
132+
- name: Check all jobs passed
133+
run: |
134+
if [[ "${{ needs.check.result }}" != "success" ]] || \
135+
[[ "${{ needs.fmt.result }}" != "success" ]] || \
136+
[[ "${{ needs.clippy.result }}" != "success" ]] || \
137+
[[ "${{ needs.test.result }}" != "success" ]] || \
138+
[[ "${{ needs.doc.result }}" != "success" ]]; then
139+
echo "One or more jobs failed"
140+
exit 1
141+
fi
142+
echo "All jobs passed!"

Makefile

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
.PHONY: all build check test lint fmt clippy doc clean ci help
2+
3+
# Default target
4+
all: check
5+
6+
# Build the project
7+
build:
8+
cargo build
9+
10+
# Build in release mode
11+
release:
12+
cargo build --release
13+
14+
# Run cargo check (type checking)
15+
check:
16+
cargo check --all-targets --all-features
17+
18+
# Run all tests
19+
test:
20+
cargo test --all-features
21+
22+
# Run tests with output
23+
test-verbose:
24+
cargo test --all-features -- --nocapture
25+
26+
# Run formatting check
27+
fmt:
28+
cargo fmt --all -- --check
29+
30+
# Run formatting and apply fixes
31+
fmt-fix:
32+
cargo fmt --all
33+
34+
# Run clippy linter
35+
clippy:
36+
cargo clippy --all-targets --all-features -- -D warnings
37+
38+
# Run clippy and apply suggestions
39+
clippy-fix:
40+
cargo clippy --all-targets --all-features --fix --allow-dirty
41+
42+
# Generate documentation
43+
doc:
44+
cargo doc --no-deps --all-features
45+
46+
# Open documentation in browser
47+
doc-open:
48+
cargo doc --no-deps --all-features --open
49+
50+
# Clean build artifacts
51+
clean:
52+
cargo clean
53+
54+
# Run the full CI pipeline (same as GitHub Actions)
55+
ci: fmt clippy check test doc
56+
@echo "CI pipeline completed successfully!"
57+
58+
# Run quick checks (for development)
59+
quick: fmt-fix clippy check test
60+
@echo "Quick checks completed!"
61+
62+
# Watch for changes and run tests
63+
watch:
64+
cargo watch -x test
65+
66+
# Run benchmarks (if any)
67+
bench:
68+
cargo bench
69+
70+
# Check for security vulnerabilities
71+
audit:
72+
cargo audit
73+
74+
# Update dependencies
75+
update:
76+
cargo update
77+
78+
# Show outdated dependencies
79+
outdated:
80+
cargo outdated
81+
82+
# Help
83+
help:
84+
@echo "Available targets:"
85+
@echo " all - Default target (runs check)"
86+
@echo " build - Build the project"
87+
@echo " release - Build in release mode"
88+
@echo " check - Run cargo check (type checking)"
89+
@echo " test - Run all tests"
90+
@echo " test-verbose - Run tests with output"
91+
@echo " fmt - Check code formatting"
92+
@echo " fmt-fix - Fix code formatting"
93+
@echo " clippy - Run clippy linter"
94+
@echo " clippy-fix - Run clippy and apply fixes"
95+
@echo " doc - Generate documentation"
96+
@echo " doc-open - Generate and open documentation"
97+
@echo " clean - Clean build artifacts"
98+
@echo " ci - Run full CI pipeline"
99+
@echo " quick - Run quick development checks"
100+
@echo " watch - Watch for changes and run tests"
101+
@echo " bench - Run benchmarks"
102+
@echo " audit - Check for security vulnerabilities"
103+
@echo " update - Update dependencies"
104+
@echo " outdated - Show outdated dependencies"
105+
@echo " help - Show this help message"

0 commit comments

Comments
 (0)