Skip to content

Commit e945514

Browse files
Ci setup (#4)
* rust initial commit * update some rust * add python sdk * added nodes and edges fetch in rust * add additional rust implementations * Rename crate to causalgraphs and wire up Python bindings * Add initial implementation of causalgraphs with RustDAG and Python bindings * add requirements.txt * update README.md * conditional compilation: create python, js cargo features * fix get random wasm compilation * fix wasm compilation issue - removed the faulty default python flag - does not compile python code during wasm compilation now * js runtime tests * Refactor project structure: separate Rust core and Python bindings, remove unused files, and update dependencies * clean up * Restructure wasm_bindings module with initial setup and dependencies * Refactors: * rename WasmDAG -> RustDAG * Added a simple node test file(needs to be fixed) * Refactor ancestor retrieval in RustDAG * refactor `add_nodes_from` & test-wasm.js * Update pyo3 version to 0.21.2 and clean up imports in RustDAG * remove old js folder * update README.md's * initial r bindings changes * R bindings: extendr setup https://extendr.github.io/user-guide/r-pkgs/package-setup.html * R build + Ugly Temp Fixes * Revert dirty fixes by updating R bindings and configuration for compatibility with R 4.2+ * revert config.R temp change * add readme * update README.md * R remote installable by updating rust_core dependency * Add MakeFile & test setup * ci initial setup * Enable manual triggering of CI workflow * Update Python bindings installation in Makefile to use maturin release build * Add installation step for wasm-pack in CI workflow * r deps change * r deps update 2 * R devtools install step * add system dependencies * add pytest installation * macos test * refactor * refactor: ci: update CI configuration for macOS * update README.md * update README.md * test --------- Co-authored-by: Ankur Ankan <[email protected]>
1 parent e040f5f commit e945514

File tree

3 files changed

+121
-21
lines changed

3 files changed

+121
-21
lines changed

.github/workflows/ci.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build-and-test:
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest, macos-latest]
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
# Setup: Toolchains
22+
- name: Set up Rust
23+
uses: actions-rs/toolchain@v1
24+
with:
25+
toolchain: stable
26+
components: rustfmt, clippy
27+
override: true
28+
29+
- name: Set up Python
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: "3.10"
33+
34+
- name: Set up Node.js
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: "18"
38+
39+
- name: Set up R
40+
uses: r-lib/actions/setup-r@v2
41+
with:
42+
r-version: "4.5"
43+
44+
# OS-specific system dependencies (Linux only)
45+
- name: Install system dependencies (Linux only)
46+
if: runner.os == 'Linux'
47+
run: |
48+
sudo apt-get update
49+
sudo apt-get install -y \
50+
libcurl4-openssl-dev \
51+
libssl-dev \
52+
libfontconfig1-dev \
53+
libfreetype6-dev \
54+
libharfbuzz-dev \
55+
libfribidi-dev \
56+
libpng-dev \
57+
libtiff5-dev \
58+
libjpeg-dev
59+
60+
# Node dependencies
61+
- name: Install JS dependencies
62+
working-directory: wasm_bindings
63+
run: npm ci
64+
65+
# Python dependencies
66+
- name: Install Python dependencies
67+
working-directory: python_bindings
68+
run: |
69+
pip install --upgrade pip
70+
pip install maturin pytest
71+
72+
# R dependencies (Linux only)
73+
- name: Install R dependencies (Linux only)
74+
if: runner.os == 'Linux'
75+
run: |
76+
sudo apt-get install -y libcurl4-openssl-dev libssl-dev
77+
Rscript -e 'install.packages(c("devtools", "rextendr"), repos="https://cloud.r-project.org")'
78+
79+
# Build all bindings (Rust, Python, WASM, R)
80+
- name: Build all components
81+
run: make all
82+
83+
# Run full test suite
84+
- name: Run full test suite
85+
run: make test

Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@ core:
1616

1717
python: core
1818
@echo "\n=== Building Python Bindings ==="
19-
cd $(PY_BINDINGS) && maturin develop --release
19+
cd $(PY_BINDINGS) && \
20+
pip install -r requirements.txt && \
21+
maturin build --release --out target/wheels && \
22+
pip install target/wheels/*.whl
2023

2124
wasm: core
2225
@echo "\n=== Building WebAssembly Bindings ==="
26+
# ensure wasm-pack is in PATH (installs it 1st time only)
27+
@if ! command -v wasm-pack >/dev/null 2>&1; then \
28+
echo "→ Installing wasm-pack…"; \
29+
cargo install wasm-pack; \
30+
fi
2331
cd $(WASM_BINDINGS) && \
2432
npm install && \
2533
npm run build && \
@@ -28,7 +36,9 @@ wasm: core
2836
r: core
2937
@echo "\n=== Building R Bindings ==="
3038
cd $(R_BINDINGS) && \
31-
Rscript -e "rextendr::document()"
39+
Rscript -e "if(!require('devtools')) install.packages('devtools', repos='https://cloud.r-project.org')" && \
40+
Rscript -e "if(!require('rextendr')) install.packages('rextendr', repos='https://cloud.r-project.org')" && \
41+
Rscript -e "rextendr::document()"
3242

3343
install: python wasm r
3444

README.md

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,37 @@ To build and develop this project locally, you will need:
1818
* [R 4.2+](https://www.r-project.org/)
1919
* [make](https://www.gnu.org/software/make/) (usually pre-installed on Linux/macOS, available via build tools on Windows)
2020

21+
## Supported Platforms
22+
23+
This library is actively developed and tested on:
24+
- **Windows** (via WSL, or native MSVC toolchain for Rust + Rtools for R)
25+
- **Linux** (Ubuntu, other distros)
26+
- **macOS**
27+
2128
## Quick Start
2229

23-
### Rust
30+
We provide a top‑level `Makefile` to save you typing:
31+
32+
- **Build everything** (Rust core + Python + WASM + R):
2433

25-
```sh
26-
cd rust_core
27-
cargo test
28-
```
34+
```sh
35+
make all
36+
```
2937

30-
### Python
38+
- **Run all tests**:
3139

32-
```sh
33-
cd python_bindings
34-
maturin develop
35-
python -c "import causalgraphs; print(dir(causalgraphs))"
36-
```
40+
```sh
41+
make test
42+
```
3743

38-
### WebAssembly (Node.js)
44+
| Target | What it does |
45+
| ------------- | ------------------------------------------------ |
46+
| `make core` | Builds only the `rust_core` crate. |
47+
| `make python` | Builds & installs Python bindings. |
48+
| `make wasm` | Builds WASM modules for JS/Node via wasm-pack |
49+
| `make r` | Generates R wrappers via `rextendr::document()`. |
3950

40-
```sh
41-
cd wasm_bindings
42-
npm install
43-
npm run build
44-
npm run test
45-
```
4651

4752
## License
4853

49-
MIT
54+
MIT

0 commit comments

Comments
 (0)