From d67e9ae310d63d89637f93811ad842e79a4f4dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fukan=20Metan?= Date: Thu, 2 Apr 2026 16:32:23 +0300 Subject: [PATCH 1/2] chore: scaffold library crate with CI, linting, and licenses Set up the Rust library crate with: - Cargo.toml with package metadata and lint configuration - CI workflow (fmt + clippy + test on Linux/macOS/Windows, cargo-deny, MSRV) - Security audit workflow (cargo-audit, weekly schedule) - Commit lint workflow (conventional commits) - Dependabot configuration (cargo + github-actions) - rustfmt.toml, rust-toolchain.toml, deny.toml - Dual MIT/Apache-2.0 license files - Library src/lib.rs with #![warn(missing_docs)] and #![deny(unsafe_code)] --- .commitlintrc.yml | 66 +++++++++++++++++++++ .github/dependabot.yml | 21 +++++++ .github/workflows/ci.yml | 98 +++++++++++++++++++++++++++++++ .github/workflows/commit-lint.yml | 23 ++++++++ .github/workflows/security.yml | 30 ++++++++++ .gitignore | 36 ++++++++++++ Cargo.toml | 45 ++++++++++++++ LICENSE => LICENSE-MIT | 2 +- README.md | 18 ++++++ deny.toml | 35 +++++++++++ rust-toolchain.toml | 3 + rustfmt.toml | 11 ++++ src/lib.rs | 4 ++ 13 files changed, 391 insertions(+), 1 deletion(-) create mode 100644 .commitlintrc.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/commit-lint.yml create mode 100644 .github/workflows/security.yml create mode 100644 .gitignore create mode 100644 Cargo.toml rename LICENSE => LICENSE-MIT (96%) create mode 100644 README.md create mode 100644 deny.toml create mode 100644 rust-toolchain.toml create mode 100644 rustfmt.toml create mode 100644 src/lib.rs diff --git a/.commitlintrc.yml b/.commitlintrc.yml new file mode 100644 index 0000000..80c38d0 --- /dev/null +++ b/.commitlintrc.yml @@ -0,0 +1,66 @@ +# commitlint configuration — Oxidized +# https://commitlint.js.org/ + +rules: + # Type is required and must be one of the allowed values + type-enum: + - 2 + - always + - - feat + - fix + - perf + - refactor + - test + - docs + - chore + - ci + type-empty: + - 2 + - never + type-case: + - 2 + - always + - lower-case + + # Scope is optional but must be one of the allowed values when present + scope-enum: + - 2 + - always + - - chunks + - ci + - deps + scope-case: + - 2 + - always + - lower-case + + # Subject (description) rules + subject-empty: + - 2 + - never + subject-case: + - 2 + - always + - lower-case + subject-full-stop: + - 2 + - never + - "." + + # Header length + header-max-length: + - 2 + - always + - 100 + + # Body rules + body-max-line-length: + - 1 + - always + - 100 + + # Footer rules + footer-max-line-length: + - 1 + - always + - 100 diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..fa622db --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,21 @@ +version: 2 +updates: + - package-ecosystem: cargo + directory: "/" + schedule: + interval: weekly + day: monday + time: "08:00" + open-pull-requests-limit: 10 + labels: + - "chore(deps)" + commit-message: + prefix: "chore(deps)" + + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: weekly + day: monday + commit-message: + prefix: "ci" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2f587ec --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,98 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: 1 + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - name: Install Rust (MSRV) + uses: dtolnay/rust-toolchain@1.85 + with: + components: rustfmt, clippy + + - name: Cache cargo + uses: actions/cache@v5 + with: + path: | + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-lint-${{ hashFiles('**/Cargo.toml') }} + restore-keys: ${{ runner.os }}-lint- + + - name: Check formatting + run: cargo fmt --check + + - name: Clippy + run: cargo clippy --all-targets -- -D warnings + + test: + name: Test (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v6 + + - name: Install Rust (stable) + uses: dtolnay/rust-toolchain@stable + + - name: Cache cargo + uses: actions/cache@v5 + with: + path: | + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }} + restore-keys: ${{ runner.os }}-cargo- + + - name: Test + run: cargo test + + - name: Check no-default-features + run: cargo check --no-default-features + + deny: + name: cargo-deny (licences + advisories) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: EmbarkStudios/cargo-deny-action@v2 + with: + command: check + + msrv: + name: MSRV check (Rust 1.85) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: dtolnay/rust-toolchain@1.85 + - name: Cache cargo + uses: actions/cache@v5 + with: + path: | + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-msrv-${{ hashFiles('**/Cargo.toml') }} + restore-keys: ${{ runner.os }}-msrv- + - name: Check MSRV + run: cargo check --all-features diff --git a/.github/workflows/commit-lint.yml b/.github/workflows/commit-lint.yml new file mode 100644 index 0000000..43ccb74 --- /dev/null +++ b/.github/workflows/commit-lint.yml @@ -0,0 +1,23 @@ +name: Commit Lint + +on: + pull_request: + branches: [main] + +permissions: + contents: read + pull-requests: read + +jobs: + commitlint: + name: Validate conventional commits + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Validate PR commits + uses: wagoid/commitlint-github-action@v6 + with: + configFile: .commitlintrc.yml diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml new file mode 100644 index 0000000..cc1a8f9 --- /dev/null +++ b/.github/workflows/security.yml @@ -0,0 +1,30 @@ +name: Security audit + +on: + push: + paths: ['**/Cargo.toml', '**/Cargo.lock'] + schedule: + # Run every Monday at 08:00 UTC + - cron: '0 8 * * 1' + +permissions: + contents: read + +env: + CARGO_TERM_COLOR: always + +jobs: + audit: + name: cargo-audit + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - name: Install Rust (stable) + uses: dtolnay/rust-toolchain@stable + + - name: Install cargo-audit + run: cargo install cargo-audit --locked + + - name: Run audit + run: cargo audit --ignore RUSTSEC-2023-0071 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8f9849e --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +# Compilation artifacts +/target/ +**/target/ + +# Cargo.lock is NOT committed for library crates (Rust convention) +Cargo.lock + +# IDE +.idea/ +.vscode/settings.json +*.iml +*.ipr +*.iws +.DS_Store + +# Environment / secrets +.env +.env.* +*.pem +*.key +*.p12 +*.jks + +# Generated +/dist/ +*.log +logs/ + +# Profiling +*.svg +flamegraph.svg +perf.data + +# Fuzz testing artifacts (generated by cargo-fuzz) +**/fuzz/artifacts/ +**/fuzz/corpus/ diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..e7d236b --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,45 @@ +[package] +name = "oxidized-chunks" +version = "0.1.0" +edition = "2024" +authors = ["Dogukan Metan "] +license = "MIT" +repository = "https://github.com/oxidized-mc/chunks" +homepage = "https://github.com/oxidized-mc/chunks" +rust-version = "1.85" +description = "Chunk data structures — LevelChunk, PalettedContainer, BitStorage, Palette, Heightmap" +keywords = ["minecraft", "oxidized-mc"] +categories = ["game-development"] + +[dependencies] + +[dev-dependencies] +proptest = "1" + +[lints.rust] +missing_docs = "warn" +unsafe_code = "deny" +unused_imports = "warn" + +[lints.clippy] +# Correctness — hard errors +correctness = { level = "deny", priority = -1 } +# Performance and style — warnings +perf = { level = "warn", priority = -1 } +style = { level = "warn", priority = -1 } +complexity = { level = "warn", priority = -1 } +suspicious = { level = "warn", priority = -1 } +# Specific useful lints +unwrap_used = "deny" +expect_used = "deny" +panic = "deny" +print_stdout = "deny" +print_stderr = "deny" +needless_pass_by_value = "warn" +redundant_clone = "warn" +# Noisy lints intentionally suppressed +module_name_repetitions = "allow" +must_use_candidate = "allow" +cast_possible_truncation = "allow" +cast_sign_loss = "allow" +cast_possible_wrap = "allow" diff --git a/LICENSE b/LICENSE-MIT similarity index 96% rename from LICENSE rename to LICENSE-MIT index 9e6a4cc..4319c0d 100644 --- a/LICENSE +++ b/LICENSE-MIT @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2026 Oxidized +Copyright (c) 2026 Oxidized Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md new file mode 100644 index 0000000..b76d50f --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# oxidized-chunks + +[![CI](https://github.com/oxidized-mc/chunks/actions/workflows/ci.yml/badge.svg)](https://github.com/oxidized-mc/chunks/actions/workflows/ci.yml) +[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE-MIT) + +Chunk data structures — LevelChunk, PalettedContainer, BitStorage, Palette, Heightmap + +Part of the [Oxidized MC](https://github.com/oxidized-mc) ecosystem — a Minecraft Java Edition +implementation in Rust. + +## License + +Licensed under the [MIT License](LICENSE-MIT). + +## Contributing + +Contributions are welcome! Please see the [Oxidized MC](https://github.com/oxidized-mc) organization +for project-wide guidelines. diff --git a/deny.toml b/deny.toml new file mode 100644 index 0000000..8446410 --- /dev/null +++ b/deny.toml @@ -0,0 +1,35 @@ +[advisories] +version = 2 +ignore = [ + # rsa: Marvin Attack timing sidechannel (RUSTSEC-2023-0071) + # No patched version available; rsa 0.10 is still RC. + # We only use RSA for Minecraft login key exchange (not security-critical). + "RUSTSEC-2023-0071", +] + +[licenses] +version = 2 +allow = [ + "MIT", + "Apache-2.0", + "Apache-2.0 WITH LLVM-exception", + "BSD-2-Clause", + "BSD-3-Clause", + "ISC", + "Unicode-3.0", + "Zlib", + "CC0-1.0", + "OpenSSL", + "CDLA-Permissive-2.0", + "BSL-1.0", +] + +[bans] +multiple-versions = "warn" +wildcards = "allow" + +[sources] +unknown-registry = "deny" +unknown-git = "deny" +allow-registry = ["https://github.com/rust-lang/crates.io-index"] +allow-git = ["https://github.com/oxidized-mc"] diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..73cb934 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "stable" +components = ["rustfmt", "clippy"] diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..e5a077f --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,11 @@ +edition = "2024" + +# Line length +max_width = 100 +hard_tabs = false +tab_spaces = 4 + +# Style +use_small_heuristics = "Default" +match_block_trailing_comma = true +newline_style = "Unix" diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..92fd49b --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,4 @@ +//! Chunk data structures — LevelChunk, PalettedContainer, BitStorage, Palette, Heightmap + +#![warn(missing_docs)] +#![deny(unsafe_code)] From ceed244d942b11e973aa03deab26626dfa0ffffe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Apr 2026 13:37:44 +0000 Subject: [PATCH 2/2] ci: bump dtolnay/rust-toolchain from 1.85 to 1.100 Bumps [dtolnay/rust-toolchain](https://github.com/dtolnay/rust-toolchain) from 1.85 to 1.100. - [Release notes](https://github.com/dtolnay/rust-toolchain/releases) - [Commits](https://github.com/dtolnay/rust-toolchain/compare/1.85...1.100) --- updated-dependencies: - dependency-name: dtolnay/rust-toolchain dependency-version: '1.100' dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f587ec..c859a04 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v6 - name: Install Rust (MSRV) - uses: dtolnay/rust-toolchain@1.85 + uses: dtolnay/rust-toolchain@1.100 with: components: rustfmt, clippy @@ -83,7 +83,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - - uses: dtolnay/rust-toolchain@1.85 + - uses: dtolnay/rust-toolchain@1.100 - name: Cache cargo uses: actions/cache@v5 with: