Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/actions/project-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,8 @@ runs:
shell: bash
run: |
curl -L https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash

- name: Install just
uses: extractions/setup-just@v3
with:
just-version: 1.46.0
20 changes: 1 addition & 19 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,17 @@ jobs:
steps:
- uses: actions/checkout@v4

# - name: Cache cargo
# uses: actions/cache@v4
# with:
# path: |
# ~/.cargo/registry
# ~/.cargo/git
# target
# key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

# - name: Cargo clean if target too large
# run: make clean

- name: Cache uv
uses: actions/cache@v4
with:
path: ~/.cache/uv
key: ${{ runner.os }}-uv-${{ hashFiles('pyproject.toml') }}

# - name: Cache cargo binaries
# uses: actions/cache@v4
# with:
# path: ~/.cargo/bin
# key: ${{ runner.os }}-cargo-bins

- name: Project setup
uses: ./.github/actions/project-setup

- name: Install test dependencies
run: make setup
run: just setup

- name: Install codspeed
run: cargo binstall cargo-codspeed --no-confirm --force
Expand Down
40 changes: 2 additions & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,12 @@ jobs:
steps:
- uses: actions/checkout@v4

# - name: Cache cargo
# uses: actions/cache@v4
# with:
# path: |
# ~/.cargo/registry
# ~/.cargo/git
# target
# key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

# - name: Cargo clean if target too large
# run: make clean

- name: Cache uv
uses: actions/cache@v4
with:
path: ~/.cache/uv
key: ${{ runner.os }}-uv-${{ hashFiles('pyproject.toml') }}

# - name: Cache cargo binaries
# uses: actions/cache@v4
# with:
# path: ~/.cargo/bin
# key: ${{ runner.os }}-cargo-bins

- name: Project setup
uses: ./.github/actions/project-setup

Expand All @@ -67,7 +49,7 @@ jobs:
run: cargo binstall cargo-llvm-cov --force --no-confirm

- name: Generate coverage
run: make coverage
run: just coverage

- name: Upload to codecov
uses: codecov/codecov-action@v2
Expand All @@ -82,30 +64,12 @@ jobs:
steps:
- uses: actions/checkout@v4

# - name: Cache cargo
# uses: actions/cache@v4
# with:
# path: |
# ~/.cargo/registry
# ~/.cargo/git
# target
# key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

# - name: Cargo clean if target too large
# run: make clean

- name: Cache uv
uses: actions/cache@v4
with:
path: ~/.cache/uv
key: ${{ runner.os }}-uv-${{ hashFiles('pyproject.toml') }}

# - name: Cache cargo binaries
# uses: actions/cache@v4
# with:
# path: ~/.cargo/bin
# key: ${{ runner.os }}-cargo-bins

- name: Project setup
uses: ./.github/actions/project-setup
with:
Expand All @@ -114,4 +78,4 @@ jobs:
- run: rustup component add --toolchain nightly-x86_64-unknown-linux-gnu clippy

- name: Run Clippy
run: make lint
run: just lint
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ git clone https://github.com/mozilla-ai/encoderfile.git
cd encoderfile

# Set up development environment
make setup
just setup

# Run tests
make test
just test

# Build documentation
make docs
just docs
```
93 changes: 93 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Setup
setup:
@echo "creating .venv"
@uv sync --locked

# Build
build-py:
uv run maturin develop \
-m encoderfile-py/Cargo.toml

# Docs
docs:
@uv run --group docs -m mkdocs serve

# Check, Test, & Coverage

check:
@cargo hack check --each-feature

coverage:
@cargo llvm-cov \
--workspace \
--all-features \
--lcov \
--output-path lcov.info

pre-commit:
@uv run --dev pre-commit run --all-files

# Lint & Format
[parallel]
format: format-rs format-py

format-rs:
@cargo fmt

format-py:
@uv run --dev -m ruff format

[parallel]
lint: lint-rs lint-py

lint-rs:
@cargo clippy \
--all-features \
--all-targets \
-- \
-D warnings

lint-py:
# ruff check
@uv run ruff check

stubtest:
@uv run \
--dev \
stubtest \
--allowlist=allowlist.txt \
encoderfile._core

# Assets
generate-test-models:
@uv run \
--group models \
scripts/generate_dummy_models.py

generate-docs:
# JSON schema for encoderfile config
@cargo run \
--bin generate-encoderfile-config-schema \
--all-features

licenses:
@echo "Generating licenses..."
@cargo about generate about.hbs > THIRDPARTY.md

# Utilities
target_max_mb := "2000"

clean:
#!/usr/bin/env bash
if [ -d target ]; then
target_size_mb=$(du -sm target | cut -f1)
echo "target/ size: ${target_size_mb} MB"
if [ "${target_size_mb}" -gt "{{target_max_mb}}" ]; then
echo "target/ exceeds {{target_max_mb}} MB — running cargo clean..."
cargo clean
else
echo "target/ size within limits — skipping clean."
fi
else
echo "target/ does not exist — skipping clean."
fi
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,19 +263,21 @@ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

### Development Setup

Make sure you have [Just](https://github.com/casey/just) installed.

```bash
# Clone the repository
git clone https://github.com/mozilla-ai/encoderfile.git
cd encoderfile

# Set up development environment
make setup
just setup

# Run tests
make test
just test

# Build documentation
make docs
just docs
```

## 📄 License
Expand Down
6 changes: 6 additions & 0 deletions allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# ignore missing __all__ in encoderfile
encoderfile._core.__all__
# encoderfile.encoderfile.EncoderfileBuilder.from_config

# allow 'n' parameter for Fixed
encoderfile._core.Fixed.__new__

# run_cli should not be exposed publicly
encoderfile._core.run_cli
2 changes: 1 addition & 1 deletion docs/reference/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ git clone https://github.com/mozilla-ai/encoderfile.git
cd encoderfile

# Set up the development environment
make setup
just setup
```

This will:
Expand Down
Loading