Skip to content

Commit 2db47ff

Browse files
deftioclaude
andcommitted
Add project scaffolding: build system, API headers, stubs, tests, CI/CD
Complete Phase 1 scaffolding for triepack (compressed trie dictionary format): - CMake build system enforcing C99/C++11 with strict warnings (-Werror) - Public C API headers (bitstream, core trie codec, JSON) - Implemented bitstream reader/writer with bit/byte/varint/symbol/UTF-8 ops - Core encoder/decoder/iterator stubs wired to API - C++11 RAII wrappers for all three libraries - 16 Unity test files (all passing), 5 example programs - 6 language binding scaffolds (Python, TS, JS, Go, Swift, Rust) - CI: gcc/clang matrix, 32-bit, clang-tidy, clang-format, coverage, release - Documentation structure (Doxyfile, guides, internals) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7f9f6d4 commit 2db47ff

119 files changed

Lines changed: 8026 additions & 0 deletions

File tree

Some content is hidden

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

.clang-format

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
BasedOnStyle: LLVM
2+
IndentWidth: 4
3+
TabWidth: 4
4+
UseTab: Never
5+
ColumnLimit: 100
6+
BreakBeforeBraces: Linux
7+
AllowShortFunctionsOnASingleLine: Empty
8+
AllowShortIfStatementsOnASingleLine: false
9+
AllowShortLoopsOnASingleLine: false
10+
AlignConsecutiveMacros: true
11+
AlignEscapedNewlines: Left
12+
SortIncludes: true
13+
IncludeBlocks: Regroup
14+
PointerAlignment: Right
15+
SpaceAfterCStyleCast: false

.clang-tidy

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
Checks: >
3+
-*,
4+
bugprone-*,
5+
-bugprone-easily-swappable-parameters,
6+
cert-*,
7+
-cert-err33-c,
8+
clang-analyzer-*,
9+
misc-*,
10+
-misc-unused-parameters,
11+
performance-*,
12+
portability-*,
13+
readability-braces-around-statements,
14+
readability-inconsistent-declaration-parameter-name,
15+
readability-misleading-indentation,
16+
readability-non-const-parameter,
17+
readability-redundant-declaration
18+
19+
WarningsAsErrors: '*'
20+
21+
HeaderFilterRegex: 'include/triepack/.*'
22+
23+
CheckOptions:
24+
- key: readability-braces-around-statements.ShortStatementLines
25+
value: 1

.github/CONTRIBUTING.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Contributing to TXZ
2+
3+
Thank you for your interest in contributing to TXZ! This document outlines the
4+
process and guidelines for contributing.
5+
6+
## Getting Started
7+
8+
1. **Fork** the repository on GitHub.
9+
2. **Clone** your fork locally:
10+
```bash
11+
git clone https://github.com/<your-username>/txz.git
12+
cd txz
13+
```
14+
3. **Create a branch** for your work:
15+
```bash
16+
git checkout -b feature/my-feature
17+
```
18+
19+
## Building
20+
21+
```bash
22+
cmake -B build -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON
23+
cmake --build build
24+
ctest --test-dir build --output-on-failure
25+
```
26+
27+
## Code Style
28+
29+
- All C/C++ code must be formatted with **clang-format** using the project's
30+
`.clang-format` configuration.
31+
- Run before committing:
32+
```bash
33+
clang-format -i src/*.c include/txz/*.h
34+
```
35+
- Keep functions short and focused.
36+
- Use clear, descriptive names. Prefer `txz_` prefixed names for public API.
37+
38+
## Testing
39+
40+
- **100% test coverage is mandatory.** Every new feature or bug fix must include
41+
tests that cover all code paths.
42+
- Run the coverage check locally:
43+
```bash
44+
./tools/check-coverage.sh
45+
```
46+
- Tests use the Unity test framework (included in the project).
47+
48+
## Pull Request Process
49+
50+
1. Ensure your branch is up to date with `main`:
51+
```bash
52+
git fetch origin
53+
git rebase origin/main
54+
```
55+
2. Verify all tests pass and coverage is at 100%.
56+
3. Run `clang-format` on all modified files.
57+
4. Push your branch and open a Pull Request against `main`.
58+
5. Fill in the PR template with:
59+
- A clear description of what changed and why.
60+
- How to test the changes.
61+
6. Address any review feedback promptly.
62+
63+
## What We Accept
64+
65+
- Bug fixes with regression tests.
66+
- New features that align with the project roadmap.
67+
- Documentation improvements.
68+
- Performance improvements with benchmarks.
69+
70+
## What We Do Not Accept
71+
72+
- Breaking changes to the public API without prior discussion.
73+
- Code without tests.
74+
- Changes that reduce test coverage below 100%.
75+
76+
## Reporting Issues
77+
78+
- Use GitHub Issues for bug reports and feature requests.
79+
- Include a minimal reproduction case for bugs.
80+
- Specify your OS, compiler, and compiler version.
81+
82+
## License
83+
84+
By contributing, you agree that your contributions will be licensed under the
85+
same license as the project (see [LICENSE.txt](../LICENSE.txt)).

.github/workflows/bindings.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Language Binding Tests
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
branches: ["**"]
8+
9+
jobs:
10+
python:
11+
name: Python Bindings
12+
runs-on: ubuntu-latest
13+
continue-on-error: true
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: "3.12"
23+
24+
- name: Install and test
25+
run: |
26+
pip install -e bindings/python
27+
pytest bindings/python/tests
28+
29+
typescript:
30+
name: TypeScript Bindings
31+
runs-on: ubuntu-latest
32+
continue-on-error: true
33+
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
38+
- name: Set up Node.js
39+
uses: actions/setup-node@v4
40+
with:
41+
node-version: "20"
42+
43+
- name: Install and test
44+
run: |
45+
cd bindings/typescript
46+
npm ci
47+
npm test
48+
49+
javascript:
50+
name: JavaScript Bindings
51+
runs-on: ubuntu-latest
52+
continue-on-error: true
53+
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v4
57+
58+
- name: Set up Node.js
59+
uses: actions/setup-node@v4
60+
with:
61+
node-version: "20"
62+
63+
- name: Install and test
64+
run: |
65+
cd bindings/javascript
66+
npm ci
67+
npm test
68+
69+
go:
70+
name: Go Bindings
71+
runs-on: ubuntu-latest
72+
continue-on-error: true
73+
74+
steps:
75+
- name: Checkout
76+
uses: actions/checkout@v4
77+
78+
- name: Set up Go
79+
uses: actions/setup-go@v5
80+
with:
81+
go-version: "1.22"
82+
83+
- name: Test
84+
run: |
85+
cd bindings/go
86+
go test ./...
87+
88+
swift:
89+
name: Swift Bindings
90+
runs-on: macos-latest
91+
continue-on-error: true
92+
93+
steps:
94+
- name: Checkout
95+
uses: actions/checkout@v4
96+
97+
- name: Test
98+
run: |
99+
cd bindings/swift
100+
swift test
101+
102+
rust:
103+
name: Rust Bindings
104+
runs-on: ubuntu-latest
105+
continue-on-error: true
106+
107+
steps:
108+
- name: Checkout
109+
uses: actions/checkout@v4
110+
111+
- name: Install Rust
112+
uses: dtolnay/rust-toolchain@stable
113+
114+
- name: Test
115+
run: |
116+
cd bindings/rust
117+
cargo test

.github/workflows/ci.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: CI Build & Test
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
branches: ["**"]
8+
9+
jobs:
10+
build:
11+
name: ${{ matrix.os }} / ${{ matrix.compiler }}
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest, macos-latest]
17+
compiler: [gcc, clang]
18+
exclude:
19+
- os: macos-latest
20+
compiler: gcc
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Install GCC (Ubuntu)
27+
if: matrix.os == 'ubuntu-latest' && matrix.compiler == 'gcc'
28+
run: |
29+
sudo apt-get update
30+
sudo apt-get install -y gcc g++
31+
32+
- name: Install Clang (Ubuntu)
33+
if: matrix.os == 'ubuntu-latest' && matrix.compiler == 'clang'
34+
run: |
35+
sudo apt-get update
36+
sudo apt-get install -y clang
37+
38+
- name: Set compiler (GCC)
39+
if: matrix.compiler == 'gcc'
40+
run: |
41+
echo "CC=gcc" >> $GITHUB_ENV
42+
echo "CXX=g++" >> $GITHUB_ENV
43+
44+
- name: Set compiler (Clang)
45+
if: matrix.compiler == 'clang'
46+
run: |
47+
echo "CC=clang" >> $GITHUB_ENV
48+
echo "CXX=clang++" >> $GITHUB_ENV
49+
50+
- name: Configure
51+
run: cmake -B build -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON
52+
53+
- name: Build (zero warnings required)
54+
run: cmake --build build 2>&1 | tee build.log
55+
56+
- name: Verify zero warnings
57+
run: |
58+
if grep -iE "warning:" build.log | grep -v "In file included"; then
59+
echo "::error::Build produced warnings — see above"
60+
exit 1
61+
fi
62+
63+
- name: Test
64+
run: ctest --test-dir build --output-on-failure
65+
66+
lint:
67+
name: clang-tidy
68+
runs-on: ubuntu-latest
69+
70+
steps:
71+
- name: Checkout
72+
uses: actions/checkout@v4
73+
74+
- name: Install clang-tidy
75+
run: |
76+
sudo apt-get update
77+
sudo apt-get install -y clang-tidy
78+
79+
- name: Configure (with compile_commands.json)
80+
run: cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF
81+
82+
- name: Build (needed for generated headers)
83+
run: cmake --build build
84+
85+
- name: Run clang-tidy
86+
run: |
87+
find src -name '*.c' | xargs clang-tidy -p build --warnings-as-errors='*'
88+
89+
format-check:
90+
name: clang-format check
91+
runs-on: ubuntu-latest
92+
93+
steps:
94+
- name: Checkout
95+
uses: actions/checkout@v4
96+
97+
- name: Install clang-format
98+
run: |
99+
sudo apt-get update
100+
sudo apt-get install -y clang-format
101+
102+
- name: Check formatting
103+
run: |
104+
find include src wrapper/src wrapper/include -name '*.c' -o -name '*.h' -o -name '*.cpp' -o -name '*.hpp' | \
105+
xargs clang-format --dry-run --Werror
106+
107+
build-32bit:
108+
name: Ubuntu / GCC / 32-bit
109+
runs-on: ubuntu-latest
110+
111+
steps:
112+
- name: Checkout
113+
uses: actions/checkout@v4
114+
115+
- name: Install 32-bit toolchain
116+
run: |
117+
sudo apt-get update
118+
sudo apt-get install -y gcc-multilib g++-multilib
119+
120+
- name: Configure (32-bit)
121+
run: |
122+
cmake -B build \
123+
-DBUILD_TESTS=ON \
124+
-DBUILD_EXAMPLES=ON \
125+
-DCMAKE_C_FLAGS=-m32 \
126+
-DCMAKE_CXX_FLAGS=-m32
127+
128+
- name: Build
129+
run: cmake --build build
130+
131+
- name: Test
132+
run: ctest --test-dir build --output-on-failure

0 commit comments

Comments
 (0)