Skip to content

Commit 5c195d3

Browse files
authored
Merge pull request #92 from pulseengine/resource-implementation
Resource implementation
2 parents b381e7a + c49e277 commit 5c195d3

File tree

1,260 files changed

+249974
-94622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,260 files changed

+249974
-94622
lines changed

.cargo/config.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[alias]
2-
xtask = "run --package xtask --quiet --"
3-
41
[build]
52
# Configure rustflags for different build operations
63

@@ -10,4 +7,7 @@ rustflags = ["--cfg=coverage"]
107

118
# For llvm-cov, define a "coverage" flag to disable problematic modules
129
[target.'cfg(llvm_coverage)']
13-
rustflags = ["--cfg=coverage"]
10+
rustflags = ["--cfg=coverage"]
11+
12+
[env]
13+
RUSTFMT = { value = "/Users/r/git/wrt2/rustfmt-local", force = true }

.clippy.toml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
# Fixed clippy config
2-
warn-on-all-wildcard-imports = true
3-
doc-valid-idents = ["WebAssembly", "WASI"]
1+
# Clippy configuration for PulseEngine code quality
42

5-
# Lint configurations
6-
msrv = "1.86.0" # Minimum supported Rust version
3+
# Enforce documentation
4+
missing-docs-in-crate-items = true
75

8-
# Clippy is strict about the following lints
6+
# MSRV (Minimum Supported Rust Version)
7+
msrv = "1.75.0"
8+
9+
# Cognitive complexity threshold
910
cognitive-complexity-threshold = 30
10-
type-complexity-threshold = 500
11-
too-many-arguments-threshold = 10
12-
too-many-lines-threshold = 500
1311

14-
# Explicitly disallow some patterns
15-
disallowed-names = []
16-
disallowed-methods = []
17-
disallowed-types = []
12+
# Function size limits
13+
too-many-lines-threshold = 100
14+
15+
# Type complexity
16+
type-complexity-threshold = 250
17+
18+
# Disallowed names
19+
disallowed-names = ["foo", "bar", "baz", "quux"]
20+
21+
# Allow some common patterns in no_std
22+
allow-expect-in-tests = true
23+
allow-unwrap-in-tests = true
1824

19-
# Documentation checks
20-
missing-docs-in-crate-items = true # Instead of missing-docs-in-private-items
25+
# Note: undocumented-unsafe-blocks lint not available in current Rust version

.cursorignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.githooks/pre-commit

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
# Pre-commit hook to prevent test files in src/ directories
3+
4+
# Colors for output
5+
RED='\033[0;31m'
6+
GREEN='\033[0;32m'
7+
YELLOW='\033[1;33m'
8+
NC='\033[0m' # No Color
9+
10+
echo "🔍 Checking for test files in src/ directories..."
11+
12+
# Find all test files in src/ directories
13+
test_files=$(find . -path "./target" -prune -o -path "./.git" -prune -o -path "./src/*" -name "*_test.rs" -print -o -path "./src/*" -name "*_tests.rs" -print -o -path "./src/*" -name "test.rs" -print -o -path "./src/*" -name "tests.rs" -print | grep -v target | grep -v .git)
14+
15+
if [ -n "$test_files" ]; then
16+
echo -e "${RED}❌ Error: Test files found in src/ directories!${NC}"
17+
echo -e "${YELLOW}Test files should be placed in the tests/ directory, not in src/${NC}"
18+
echo ""
19+
echo "Found test files:"
20+
echo "$test_files" | while read -r file; do
21+
echo -e " ${RED}$file${NC}"
22+
done
23+
echo ""
24+
echo "Please move these files to the appropriate tests/ directory before committing."
25+
exit 1
26+
fi
27+
28+
# Check if cargo-wrt is available
29+
if command -v cargo-wrt &> /dev/null; then
30+
# Run validation check using cargo-wrt
31+
echo "🔍 Running cargo-wrt validation checks..."
32+
if ! cargo-wrt validate --check-test-files; then
33+
echo -e "${RED}❌ Validation failed!${NC}"
34+
exit 1
35+
fi
36+
else
37+
echo -e "${YELLOW}⚠️ Warning: cargo-wrt not found. Install it for better validation:${NC}"
38+
echo " cargo install --path cargo-wrt"
39+
fi
40+
41+
echo -e "${GREEN}✅ No test files found in src/ directories${NC}"
42+
43+
# Run cargo fmt check
44+
echo ""
45+
echo "🔍 Checking code formatting with cargo fmt..."
46+
47+
# Use the project's unified build tool for formatting check
48+
if ! cargo-wrt check --strict; then
49+
echo -e "${RED}❌ Error: Code formatting issues detected!${NC}"
50+
echo ""
51+
echo "Please run 'cargo-wrt check' or 'cargo fmt' to format your code before committing."
52+
echo ""
53+
echo "To bypass this check (not recommended), use:"
54+
echo " git commit --no-verify"
55+
exit 1
56+
fi
57+
58+
echo -e "${GREEN}✅ Code formatting check passed${NC}"
59+
exit 0

.github/kani-badge.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"schemaVersion": 1,
3+
"label": "formal verification",
4+
"message": "KANI",
5+
"color": "brightgreen",
6+
"namedLogo": "rust",
7+
"logoColor": "white",
8+
"style": "for-the-badge",
9+
"cacheSeconds": 86400
10+
}
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
name: Capability Engine Tests
2+
3+
on:
4+
push:
5+
branches: [ main, resource-implementation ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
RUST_BACKTRACE: 1
11+
12+
jobs:
13+
test-matrix:
14+
name: Test ${{ matrix.name }}
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- name: "Default"
21+
features: ""
22+
package: "wrtd"
23+
- name: "QM"
24+
features: "qm"
25+
package: "wrtd"
26+
- name: "ASIL-A"
27+
features: "asil-a"
28+
package: "wrtd"
29+
- name: "ASIL-B"
30+
features: "asil-b"
31+
package: "wrtd"
32+
- name: "Minimal"
33+
features: "--no-default-features"
34+
package: "wrtd"
35+
no_default: true
36+
- name: "Runtime STD"
37+
features: "std"
38+
package: "wrt-runtime"
39+
- name: "Runtime Alloc"
40+
features: "alloc"
41+
package: "wrt-runtime"
42+
- name: "WRT QM"
43+
features: "qm"
44+
package: "wrt"
45+
- name: "WRT ASIL-A"
46+
features: "asil-a"
47+
package: "wrt"
48+
- name: "WRT ASIL-B"
49+
features: "asil-b"
50+
package: "wrt"
51+
52+
steps:
53+
- uses: actions/checkout@v4
54+
55+
- uses: dtolnay/rust-toolchain@stable
56+
with:
57+
components: clippy
58+
59+
- uses: actions/cache@v4
60+
with:
61+
path: |
62+
~/.cargo/registry
63+
~/.cargo/git
64+
target
65+
key: ${{ runner.os }}-cargo-${{ matrix.name }}-${{ hashFiles('**/Cargo.lock') }}
66+
67+
- name: Build ${{ matrix.name }}
68+
run: |
69+
if [ "${{ matrix.no_default }}" = "true" ]; then
70+
cargo build -p ${{ matrix.package }} --no-default-features
71+
elif [ "${{ matrix.features }}" = "" ]; then
72+
cargo build -p ${{ matrix.package }}
73+
else
74+
cargo build -p ${{ matrix.package }} --features ${{ matrix.features }}
75+
fi
76+
77+
- name: Clippy ${{ matrix.name }}
78+
run: |
79+
if [ "${{ matrix.no_default }}" = "true" ]; then
80+
cargo clippy -p ${{ matrix.package }} --no-default-features -- -D warnings
81+
elif [ "${{ matrix.features }}" = "" ]; then
82+
cargo clippy -p ${{ matrix.package }} -- -D warnings
83+
else
84+
cargo clippy -p ${{ matrix.package }} --features ${{ matrix.features }} -- -D warnings
85+
fi
86+
87+
- name: Test ${{ matrix.name }}
88+
if: matrix.package != 'wrtd'
89+
run: |
90+
if [ "${{ matrix.features }}" = "" ]; then
91+
cargo test -p ${{ matrix.package }} capability
92+
else
93+
cargo test -p ${{ matrix.package }} --features ${{ matrix.features }} capability
94+
fi
95+
96+
integration-tests:
97+
name: Integration Tests
98+
runs-on: ubuntu-latest
99+
steps:
100+
- uses: actions/checkout@v4
101+
102+
- uses: dtolnay/rust-toolchain@stable
103+
104+
- uses: actions/cache@v4
105+
with:
106+
path: |
107+
~/.cargo/registry
108+
~/.cargo/git
109+
target
110+
key: ${{ runner.os }}-cargo-integration-${{ hashFiles('**/Cargo.lock') }}
111+
112+
- name: Install wat2wasm
113+
run: |
114+
curl -sSL https://github.com/WebAssembly/wabt/releases/download/1.0.34/wabt-1.0.34-ubuntu.tar.gz | tar xz
115+
echo "$PWD/wabt-1.0.34/bin" >> $GITHUB_PATH
116+
117+
- name: Run capability integration tests
118+
run: cargo test -p wrt capability_integration_tests -- --nocapture
119+
120+
- name: Run build matrix script
121+
run: ./scripts/test_build_matrix.sh
122+
123+
summary:
124+
name: Test Summary
125+
runs-on: ubuntu-latest
126+
needs: [test-matrix, integration-tests]
127+
if: always()
128+
steps:
129+
- name: Summary
130+
run: |
131+
if [ "${{ needs.test-matrix.result }}" = "success" ] && [ "${{ needs.integration-tests.result }}" = "success" ]; then
132+
echo "✅ All capability engine tests passed!"
133+
exit 0
134+
else
135+
echo "❌ Some capability engine tests failed"
136+
exit 1
137+
fi

0 commit comments

Comments
 (0)