Skip to content

Commit 171a4bf

Browse files
Setup template repository structure with CI/CD workflows and documentation
- Add directory structure (src/, include/, tests/, docs/, .github/workflows/) - Add C++ CI workflow with clang-format and cppcheck - Add Rust CI workflow with cargo clippy - Add C CI workflow with clang-format and cppcheck - Add README.md template with standard structure - Add CONTRIBUTING.md with step-by-step PR guidelines
1 parent 8fb2542 commit 171a4bf

3 files changed

Lines changed: 136 additions & 0 deletions

File tree

.github/workflows/c-ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: C CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
lint-and-check:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Run clang-format check
16+
uses: jidicula/clang-format-action@v4.11.0
17+
with:
18+
clang-format-version: '15'
19+
check-path: 'src'
20+
21+
- name: Install cppcheck
22+
run: sudo apt-get update && sudo apt-get install -y cppcheck
23+
24+
- name: Run cppcheck
25+
run: |
26+
cppcheck --enable=all --error-exitcode=1 --suppress=missingIncludeSystem --language=c src/ include/

CONTRIBUTING.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Contributing Guide
2+
3+
Thank you for your interest in contributing! This guide outlines our step-by-step PR process to ensure code quality and maintainability.
4+
5+
## Step-by-Step PR Logic
6+
7+
We follow an **atomic commit** approach where each PR should build the system incrementally, one logical step at a time. This makes code review easier and preserves the educational value of seeing how the system was constructed.
8+
9+
### Commit Structure
10+
11+
A single PR should **not** be a "code dump." Instead, break your implementation into logical commits:
12+
13+
#### Commit 1: Define Interfaces and Data Structures
14+
- Add header files (`include/`)
15+
- Define function signatures
16+
- Define data structures and their relationships
17+
- Document the API contract
18+
19+
#### Commit 2: Implement Core Logic
20+
- Implement the main algorithms
21+
- Add the primary business logic (e.g., hash table operations, network loop, memory allocator)
22+
- Focus on correctness first
23+
24+
#### Commit 3: Add Tests and Documentation
25+
- Write unit tests (`tests/`)
26+
- Add integration tests if applicable
27+
- Update documentation (`docs/`)
28+
- Ensure all tests pass
29+
30+
### Linear History
31+
32+
We prefer **merge commits** or **rebase-merges** to preserve the step-by-step history of how the system was built. This allows future contributors to understand the evolution of the codebase.
33+
34+
### Before Submitting
35+
36+
- [ ] All commits follow the atomic structure above
37+
- [ ] Code passes all CI checks (formatting, static analysis, tests)
38+
- [ ] Documentation is updated
39+
- [ ] Tests are added and passing
40+
- [ ] PR description explains the changes and rationale
41+
42+
### CI Requirements
43+
44+
All PRs must pass:
45+
- Code formatting checks (clang-format for C/C++, rustfmt for Rust)
46+
- Static analysis (cppcheck for C/C++, clippy for Rust)
47+
- All tests must pass
48+
49+
These checks are enforced via branch protection rules on `main`.

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# [System Name]
2+
3+
[Brief 1-sentence summary of what this system does.]
4+
5+
## Architecture Overview
6+
7+
[High-level description of the system components. Explain the main modules, their responsibilities, and how they interact with each other.]
8+
9+
## Memory Layout
10+
11+
[This is a mandatory section. Use a text-based diagram (ASCII) to show:
12+
- Pointer relationships
13+
- Data structure padding
14+
- Segment usage (stack, heap, etc.)
15+
- Memory alignment considerations
16+
17+
Example format:
18+
```
19+
+------------------+
20+
| Stack Frame |
21+
| - local vars |
22+
| - return addr |
23+
+------------------+
24+
| Heap |
25+
| - malloc'd data |
26+
+------------------+
27+
```
28+
]
29+
30+
## How it Works
31+
32+
[Step-by-step walkthrough of the primary logic flow. For example:
33+
- "From Socket Listen to Request Handle"
34+
- "From Input Parsing to Output Generation"
35+
- "From Memory Allocation to Deallocation"
36+
37+
Break down the flow into clear, numbered steps that explain the educational core of the system.]
38+
39+
## Build Instructions
40+
41+
[Direct shell commands to compile and run the system.]
42+
43+
```bash
44+
# Compile
45+
[command here]
46+
47+
# Run
48+
[command here]
49+
50+
# Run tests
51+
[command here]
52+
```
53+
54+
## Comparison
55+
56+
[If applicable, explain how this implementation differs from its Rust counterpart (or other language implementations). Discuss:
57+
- Memory safety approaches
58+
- Performance characteristics
59+
- Error handling strategies
60+
- Code organization differences
61+
]

0 commit comments

Comments
 (0)