Skip to content

Commit 61b9c23

Browse files
Richard BaahRichard Baah
authored andcommitted
Added lots of configuration and documentation to start the project
1 parent 1e86945 commit 61b9c23

File tree

12 files changed

+340
-15
lines changed

12 files changed

+340
-15
lines changed

.github/workflows/go-test.yml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@ on:
77
branches: [ main ]
88

99
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v5
18+
with:
19+
go-version: '1.24'
20+
21+
- name: Run golangci-lint
22+
uses: golangci/golangci-lint-action@v6
23+
with:
24+
version: latest
25+
working-directory: ./src/Backend/opti-sql-go
26+
1027
test:
1128
runs-on: ubuntu-latest
1229

@@ -16,16 +33,23 @@ jobs:
1633
- name: Set up Go
1734
uses: actions/setup-go@v5
1835
with:
19-
go-version: '1.21'
36+
go-version: '1.24'
2037

2138
- name: Run tests
2239
working-directory: ./src/Backend/opti-sql-go
2340
run: go test -v ./...
2441

25-
- name: Run tests with coverage
26-
working-directory: ./src/Backend/opti-sql-go
27-
run: go test -v -coverprofile=coverage.out ./...
42+
race:
43+
runs-on: ubuntu-latest
44+
45+
steps:
46+
- uses: actions/checkout@v4
47+
48+
- name: Set up Go
49+
uses: actions/setup-go@v5
50+
with:
51+
go-version: '1.24'
2852

29-
- name: Display coverage
53+
- name: Run tests with race detector
3054
working-directory: ./src/Backend/opti-sql-go
31-
run: go tool cover -func=coverage.out
55+
run: go test -race -v ./...

.github/workflows/rust-test.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Rust Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Rust
17+
uses: actions-rust-lang/setup-rust-toolchain@v1
18+
with:
19+
toolchain: stable
20+
components: clippy, rustfmt
21+
22+
- name: Run clippy
23+
working-directory: ./src/Backend/opti-sql-rs
24+
run: cargo clippy --all-targets --all-features -- -D warnings
25+
26+
- name: Check formatting
27+
working-directory: ./src/Backend/opti-sql-rs
28+
run: cargo fmt -- --check
29+
30+
test:
31+
runs-on: ubuntu-latest
32+
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Set up Rust
37+
uses: actions-rust-lang/setup-rust-toolchain@v1
38+
with:
39+
toolchain: stable
40+
41+
- name: Run tests
42+
working-directory: ./src/Backend/opti-sql-rs
43+
run: cargo test --verbose
44+

CONTRIBUTING.md

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# Contributing to OptiSQL
2+
3+
Thank you for your interest in contributing to OptiSQL! This guide will help you get started.
4+
5+
## How to Write and Run Tests
6+
7+
We use a Makefile to simplify common development tasks. All commands should be run from the project root.
8+
9+
### Go Tests
10+
- Run all tests
11+
```bash
12+
make go-test
13+
```
14+
- Run tests with race detector
15+
```bash
16+
make go-test-race
17+
```
18+
- Run tests with coverage
19+
```bash
20+
make go-test-coverage
21+
```
22+
23+
### Rust Tests
24+
- Run all tests
25+
```bash
26+
make rust-test
27+
```
28+
29+
### Run All Tests (Go + Rust)
30+
- Run tests for both backends
31+
```bash
32+
make test-all
33+
```
34+
35+
## Pull Request (PR) Format
36+
37+
- Create a descriptive PR title that summarizes the change
38+
- Include the following sections in your PR description:
39+
- **What**: Brief description of what this PR does
40+
- **Why**: Explanation of why this change is needed
41+
- **How**: Technical details of how the change was implemented
42+
- **Testing**: How you tested the changes
43+
- Reference any related issues using `Fixes #<issue-number>` or `Closes #<issue-number>`
44+
- Ensure all CI checks pass
45+
46+
## Git Commit Message Format
47+
48+
- Use conventional commit format:
49+
```bash
50+
<type>(<scope>): <subject>
51+
52+
<body>
53+
54+
<footer>
55+
```
56+
- **Types**: `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`
57+
- **Examples**:
58+
```bash
59+
feat(operators): add hash join implementation
60+
61+
fix(parser): handle edge case in substrait parsing
62+
63+
docs(readme): update installation instructions
64+
65+
test(filter): add unit tests for wildcard filter
66+
```
67+
- Keep subject line under 50 characters
68+
- Capitalize the subject line
69+
- Use imperative mood ("add" not "added")
70+
- Separate subject from body with a blank line
71+
- Wrap body at 72 characters
72+
73+
## Areas Where We Currently Need Help / Open Contributions
74+
75+
- **Operator Implementations**: Help implement missing SQL operators (join, filter, aggregation)
76+
- **Substrait Integration**: Improve substrait plan parsing and optimization
77+
- **Test Coverage**: Add unit tests and integration tests for existing functionality
78+
- **Documentation**: Improve code comments, API documentation, and user guides
79+
- **Performance Optimization**: Profile and optimize query execution performance
80+
- **Bug Fixes**: Check the issues tab for open bugs that need fixing
81+
82+
## How to Build, Test, and Run the Application
83+
84+
### Prerequisites
85+
- Go 1.24 or higher
86+
- Rust 1.70 or higher
87+
- Git
88+
- Make
89+
90+
### Clone the Repository
91+
```bash
92+
git clone https://github.com/Rich-T-kid/OptiSQL.git
93+
cd OptiSQL
94+
```
95+
96+
### Quick Start with Makefile
97+
98+
See all available commands:
99+
```bash
100+
make help
101+
```
102+
103+
### Build and Run Go Backend
104+
```bash
105+
make go-run
106+
```
107+
108+
### Build and Run Rust Backend
109+
```bash
110+
make rust-run
111+
```
112+
113+
### Run All Tests
114+
```bash
115+
make test-all
116+
```
117+
118+
Or run individually:
119+
```bash
120+
make go-test
121+
make rust-test
122+
```
123+
124+
### Run Linters
125+
```bash
126+
make lint-all
127+
```
128+
129+
Or run individually:
130+
```bash
131+
make go-lint
132+
make rust-lint
133+
```
134+
135+
### Format Code
136+
```bash
137+
make fmt-all
138+
```
139+
140+
### Clean Build Artifacts
141+
```bash
142+
make clean-all
143+
```
144+
145+
### Verify CI Pipeline Locally
146+
Before pushing, run the pre-push check:
147+
```bash
148+
make pre-push
149+
```
150+
151+
This runs formatting, linting, and all tests to ensure your changes will pass CI.
152+
153+
---
154+
155+
For questions or help, please open an issue.

Makefile

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
.PHONY: help go-test rust-test go-run rust-run go-lint rust-lint go-fmt rust-fmt test-all lint-all fmt-all pre-push
2+
3+
# Default target
4+
help:
5+
@echo "Available targets:"
6+
@echo " make go-test - Run Go tests"
7+
@echo " make rust-test - Run Rust tests"
8+
@echo " make go-run - Run Go application"
9+
@echo " make rust-run - Run Rust application"
10+
@echo " make go-lint - Run Go linter"
11+
@echo " make rust-lint - Run Rust linter and formatter check"
12+
@echo " make go-fmt - Format Go code"
13+
@echo " make rust-fmt - Format Rust code"
14+
@echo " make test-all - Run all tests (Go + Rust)"
15+
@echo " make lint-all - Run all linters (Go + Rust)"
16+
@echo " make fmt-all - Format all code (Go + Rust)"
17+
@echo " make pre-push - Run fmt, lint, and test (use before pushing)"
18+
19+
# Go targets
20+
go-test:
21+
@echo "Running Go tests..."
22+
cd src/Backend/opti-sql-go && go test -v ./...
23+
24+
go-test-race:
25+
@echo "Running Go tests with race detector..."
26+
cd src/Backend/opti-sql-go && go test -race -v ./...
27+
28+
go-test-coverage:
29+
@echo "Running Go tests with coverage..."
30+
cd src/Backend/opti-sql-go && go test -v -coverprofile=coverage.out ./...
31+
cd src/Backend/opti-sql-go && go tool cover -func=coverage.out
32+
33+
go-run:
34+
@echo "Running Go application..."
35+
cd src/Backend/opti-sql-go && go run main.go
36+
37+
go-build:
38+
@echo "Building Go application..."
39+
cd src/Backend/opti-sql-go && go build -o opti-sql-go
40+
41+
go-lint:
42+
@echo "Running Go linter..."
43+
cd src/Backend/opti-sql-go && golangci-lint run ./...
44+
45+
go-fmt:
46+
@echo "Formatting Go code..."
47+
cd src/Backend/opti-sql-go && go fmt ./...
48+
49+
# Rust targets
50+
rust-test:
51+
@echo "Running Rust tests..."
52+
cd src/Backend/opti-sql-rs && cargo test --verbose
53+
54+
rust-run:
55+
@echo "Running Rust application..."
56+
cd src/Backend/opti-sql-rs && cargo run
57+
58+
rust-build:
59+
@echo "Building Rust application..."
60+
cd src/Backend/opti-sql-rs && cargo build --release
61+
62+
rust-lint:
63+
@echo "Running Rust linter..."
64+
cd src/Backend/opti-sql-rs && cargo clippy --all-targets --all-features -- -D warnings
65+
66+
rust-fmt:
67+
@echo "Formatting Rust code..."
68+
cd src/Backend/opti-sql-rs && cargo fmt
69+
70+
rust-fmt-check:
71+
@echo "Checking Rust formatting..."
72+
cd src/Backend/opti-sql-rs && cargo fmt --check
73+
74+
# Combined targets
75+
test-all: go-test rust-test
76+
@echo "All tests completed!"
77+
78+
lint-all: go-lint rust-lint
79+
@echo "All linting completed!"
80+
81+
fmt-all: go-fmt rust-fmt
82+
@echo "All formatting completed!"
83+
84+
# Pre-push verification
85+
pre-push: fmt-all lint-all test-all
86+
@echo "All checks passed! Ready to push."
87+
88+
# Clean targets
89+
clean-go:
90+
@echo "Cleaning Go build artifacts..."
91+
cd src/Backend/opti-sql-go && go clean
92+
rm -f src/Backend/opti-sql-go/opti-sql-go
93+
rm -f src/Backend/opti-sql-go/coverage.out
94+
95+
clean-rust:
96+
@echo "Cleaning Rust build artifacts..."
97+
cd src/Backend/opti-sql-rs && cargo clean
98+
99+
clean-all: clean-go clean-rust
100+
@echo "All build artifacts cleaned!"

src/Backend/opti-sql-go/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module opti-sql-go
22

3-
go 1.25.0
3+
go 1.24.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
package physicaloptimizer
2+
// optimize the parsed plan
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use datafusion::arrow::record_batch::RecordBatch;
1+
//use datafusion::arrow::record_batch::RecordBatch;
22
mod project;
3-
fn main(){
3+
#[allow(dead_code)]
4+
fn main() {
45
println!("Hello, world!");
56
project::project_exec::project_execute();
67
project::source::csv::read_csv();
7-
8-
}
8+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pub mod source; // folder = "source"
2-
pub mod project_exec; // file = "project_exec.rs"
1+
pub mod project_exec;
2+
pub mod source; // folder = "source" // file = "project_exec.rs"
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
pub fn read_csv() {
32
println!("Reading CSV...");
43
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)