diff --git a/.github/actions/project-setup/action.yml b/.github/actions/project-setup/action.yml index 42912829..d0e90d11 100644 --- a/.github/actions/project-setup/action.yml +++ b/.github/actions/project-setup/action.yml @@ -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 diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 62ad303a..8bce3945 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a56c5630..3dde5382 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 @@ -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: @@ -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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7d30b386..8c64fa4e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 ``` \ No newline at end of file diff --git a/Justfile b/Justfile new file mode 100644 index 00000000..79ecf39c --- /dev/null +++ b/Justfile @@ -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 diff --git a/README.md b/README.md index de7c4dc3..e2b0c9f4 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/allowlist.txt b/allowlist.txt index 23cd761d..43a14834 100644 --- a/allowlist.txt +++ b/allowlist.txt @@ -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 diff --git a/docs/reference/building.md b/docs/reference/building.md index 29ea8782..07acfafb 100644 --- a/docs/reference/building.md +++ b/docs/reference/building.md @@ -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: