Skip to content

Commit 98efa2e

Browse files
committed
Fix GitHub Actions workflow failures
- Reorganize examples into subdirectories (basic/, adaptive/) - Each example now has its own directory with main.go - Prevents 'multiple main() declarations' build errors - Remove examples/indexed_engine.go (library code, not a runnable example) - Update CI workflow: - Remove go.sum verification (project has no external dependencies) - Fix build step to handle new examples structure - Build each example in its own directory - Add examples/README.md documenting the new structure This fixes all build, lint, and format check failures in GitHub Actions.
1 parent bfb8c15 commit 98efa2e

File tree

7 files changed

+65
-236
lines changed

7 files changed

+65
-236
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ jobs:
9696
exit 1
9797
fi
9898
99-
- name: Verify go.mod and go.sum
99+
- name: Verify go.mod
100100
run: |
101101
go mod tidy
102-
git diff --exit-code go.mod go.sum
102+
git diff --exit-code go.mod
103103
104104
build:
105105
name: Build
@@ -114,21 +114,26 @@ jobs:
114114
with:
115115
go-version: '1.25.x'
116116

117-
- name: Build
118-
run: go build -v ./...
117+
- name: Build main package
118+
run: go build -v .
119+
120+
- name: Build sub-packages
121+
run: go build -v ./pkg/...
119122

120123
- name: Build examples
121124
run: |
122-
for example in examples/*.go; do
123-
if [ -f "$example" ]; then
124-
go build -v "$example"
125+
for example_dir in examples/*/; do
126+
if [ -d "$example_dir" ]; then
127+
echo "Building $example_dir"
128+
(cd "$example_dir" && go build -v .)
125129
fi
126130
done
127131
128132
- name: Build commands
129133
run: |
130134
for cmd in cmd/*; do
131135
if [ -d "$cmd" ]; then
136+
echo "Building $cmd"
132137
go build -v "./$cmd"
133138
fi
134139
done

examples/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# SPOCP Examples
2+
3+
This directory contains runnable examples demonstrating various features of the SPOCP library.
4+
5+
## Available Examples
6+
7+
### basic
8+
Basic usage example showing:
9+
- Creating an engine with `spocp.New()`
10+
- Adding rules
11+
- Querying policies
12+
- Using wildcards and sets
13+
14+
Run with:
15+
```bash
16+
cd examples/basic
17+
go run main.go
18+
```
19+
20+
### adaptive
21+
Demonstrates the AdaptiveEngine with automatic indexing:
22+
- Creating rules with diverse tags
23+
- Automatic indexing optimization
24+
- Performance statistics
25+
- Index transition monitoring
26+
27+
Run with:
28+
```bash
29+
cd examples/adaptive
30+
go run main.go
31+
```
32+
33+
## Building Examples
34+
35+
Build all examples:
36+
```bash
37+
for example_dir in examples/*/; do
38+
(cd "$example_dir" && go build .)
39+
done
40+
```
41+
42+
Build a specific example:
43+
```bash
44+
cd examples/basic
45+
go build .
46+
```
47+
48+
## Example Structure
49+
50+
Each example is in its own subdirectory with a `main.go` file. This structure:
51+
- Allows each example to be built independently
52+
- Prevents conflicts between multiple `main()` functions
53+
- Makes it easy to add new examples

examples/adaptive/adaptive

2.33 MB
Binary file not shown.

examples/basic/basic

2.35 MB
Binary file not shown.
File renamed without changes.

examples/indexed_engine.go

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

0 commit comments

Comments
 (0)