Skip to content

Commit a2fb64a

Browse files
committed
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 - MIT license - Library src/lib.rs with #![warn(missing_docs)] and #![deny(unsafe_code)]
1 parent 8ac3308 commit a2fb64a

13 files changed

Lines changed: 391 additions & 1 deletion

File tree

.commitlintrc.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# commitlint configuration — Oxidized
2+
# https://commitlint.js.org/
3+
4+
rules:
5+
# Type is required and must be one of the allowed values
6+
type-enum:
7+
- 2
8+
- always
9+
- - feat
10+
- fix
11+
- perf
12+
- refactor
13+
- test
14+
- docs
15+
- chore
16+
- ci
17+
type-empty:
18+
- 2
19+
- never
20+
type-case:
21+
- 2
22+
- always
23+
- lower-case
24+
25+
# Scope is optional but must be one of the allowed values when present
26+
scope-enum:
27+
- 2
28+
- always
29+
- - chat
30+
- ci
31+
- deps
32+
scope-case:
33+
- 2
34+
- always
35+
- lower-case
36+
37+
# Subject (description) rules
38+
subject-empty:
39+
- 2
40+
- never
41+
subject-case:
42+
- 2
43+
- always
44+
- lower-case
45+
subject-full-stop:
46+
- 2
47+
- never
48+
- "."
49+
50+
# Header length
51+
header-max-length:
52+
- 2
53+
- always
54+
- 100
55+
56+
# Body rules
57+
body-max-line-length:
58+
- 1
59+
- always
60+
- 100
61+
62+
# Footer rules
63+
footer-max-line-length:
64+
- 1
65+
- always
66+
- 100

.github/dependabot.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: cargo
4+
directory: "/"
5+
schedule:
6+
interval: weekly
7+
day: monday
8+
time: "08:00"
9+
open-pull-requests-limit: 10
10+
labels:
11+
- "chore(deps)"
12+
commit-message:
13+
prefix: "chore(deps)"
14+
15+
- package-ecosystem: github-actions
16+
directory: "/"
17+
schedule:
18+
interval: weekly
19+
day: monday
20+
commit-message:
21+
prefix: "ci"

.github/workflows/ci.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
RUST_BACKTRACE: 1
12+
13+
jobs:
14+
lint:
15+
name: Lint
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v6
19+
20+
- name: Install Rust (MSRV)
21+
uses: dtolnay/rust-toolchain@1.85
22+
with:
23+
components: rustfmt, clippy
24+
25+
- name: Cache cargo
26+
uses: actions/cache@v5
27+
with:
28+
path: |
29+
~/.cargo/registry/index/
30+
~/.cargo/registry/cache/
31+
~/.cargo/git/db/
32+
target/
33+
key: ${{ runner.os }}-lint-${{ hashFiles('**/Cargo.toml') }}
34+
restore-keys: ${{ runner.os }}-lint-
35+
36+
- name: Check formatting
37+
run: cargo fmt --check
38+
39+
- name: Clippy
40+
run: cargo clippy --all-targets -- -D warnings
41+
42+
test:
43+
name: Test (${{ matrix.os }})
44+
runs-on: ${{ matrix.os }}
45+
strategy:
46+
fail-fast: true
47+
matrix:
48+
os: [ubuntu-latest, windows-latest, macos-latest]
49+
steps:
50+
- uses: actions/checkout@v6
51+
52+
- name: Install Rust (stable)
53+
uses: dtolnay/rust-toolchain@stable
54+
55+
- name: Cache cargo
56+
uses: actions/cache@v5
57+
with:
58+
path: |
59+
~/.cargo/registry/index/
60+
~/.cargo/registry/cache/
61+
~/.cargo/git/db/
62+
target/
63+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
64+
restore-keys: ${{ runner.os }}-cargo-
65+
66+
- name: Test
67+
run: cargo test
68+
69+
- name: Check no-default-features
70+
run: cargo check --no-default-features
71+
72+
deny:
73+
name: cargo-deny (licences + advisories)
74+
runs-on: ubuntu-latest
75+
steps:
76+
- uses: actions/checkout@v6
77+
- uses: EmbarkStudios/cargo-deny-action@v2
78+
with:
79+
command: check
80+
81+
msrv:
82+
name: MSRV check (Rust 1.85)
83+
runs-on: ubuntu-latest
84+
steps:
85+
- uses: actions/checkout@v6
86+
- uses: dtolnay/rust-toolchain@1.85
87+
- name: Cache cargo
88+
uses: actions/cache@v5
89+
with:
90+
path: |
91+
~/.cargo/registry/index/
92+
~/.cargo/registry/cache/
93+
~/.cargo/git/db/
94+
target/
95+
key: ${{ runner.os }}-msrv-${{ hashFiles('**/Cargo.toml') }}
96+
restore-keys: ${{ runner.os }}-msrv-
97+
- name: Check MSRV
98+
run: cargo check --all-features

.github/workflows/commit-lint.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Commit Lint
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: read
10+
11+
jobs:
12+
commitlint:
13+
name: Validate conventional commits
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v6
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Validate PR commits
21+
uses: wagoid/commitlint-github-action@v6
22+
with:
23+
configFile: .commitlintrc.yml

.github/workflows/security.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Security audit
2+
3+
on:
4+
push:
5+
paths: ['**/Cargo.toml', '**/Cargo.lock']
6+
schedule:
7+
# Run every Monday at 08:00 UTC
8+
- cron: '0 8 * * 1'
9+
10+
permissions:
11+
contents: read
12+
13+
env:
14+
CARGO_TERM_COLOR: always
15+
16+
jobs:
17+
audit:
18+
name: cargo-audit
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v6
22+
23+
- name: Install Rust (stable)
24+
uses: dtolnay/rust-toolchain@stable
25+
26+
- name: Install cargo-audit
27+
run: cargo install cargo-audit --locked
28+
29+
- name: Run audit
30+
run: cargo audit --ignore RUSTSEC-2023-0071

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Compilation artifacts
2+
/target/
3+
**/target/
4+
5+
# Cargo.lock is NOT committed for library crates (Rust convention)
6+
Cargo.lock
7+
8+
# IDE
9+
.idea/
10+
.vscode/settings.json
11+
*.iml
12+
*.ipr
13+
*.iws
14+
.DS_Store
15+
16+
# Environment / secrets
17+
.env
18+
.env.*
19+
*.pem
20+
*.key
21+
*.p12
22+
*.jks
23+
24+
# Generated
25+
/dist/
26+
*.log
27+
logs/
28+
29+
# Profiling
30+
*.svg
31+
flamegraph.svg
32+
perf.data
33+
34+
# Fuzz testing artifacts (generated by cargo-fuzz)
35+
**/fuzz/artifacts/
36+
**/fuzz/corpus/

Cargo.toml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[package]
2+
name = "oxidized-chat"
3+
version = "0.1.0"
4+
edition = "2024"
5+
authors = ["Dogukan Metan <dogukanmetan@gmail.com>"]
6+
license = "MIT"
7+
repository = "https://github.com/oxidized-mc/chat"
8+
homepage = "https://github.com/oxidized-mc/chat"
9+
rust-version = "1.85"
10+
description = "Minecraft chat component system — Component tree, Style, ChatFormatting, TextColor, JSON/NBT serialization"
11+
keywords = ["minecraft", "oxidized-mc"]
12+
categories = ["game-development"]
13+
14+
[dependencies]
15+
16+
[dev-dependencies]
17+
proptest = "1"
18+
19+
[lints.rust]
20+
missing_docs = "warn"
21+
unsafe_code = "deny"
22+
unused_imports = "warn"
23+
24+
[lints.clippy]
25+
# Correctness — hard errors
26+
correctness = { level = "deny", priority = -1 }
27+
# Performance and style — warnings
28+
perf = { level = "warn", priority = -1 }
29+
style = { level = "warn", priority = -1 }
30+
complexity = { level = "warn", priority = -1 }
31+
suspicious = { level = "warn", priority = -1 }
32+
# Specific useful lints
33+
unwrap_used = "deny"
34+
expect_used = "deny"
35+
panic = "deny"
36+
print_stdout = "deny"
37+
print_stderr = "deny"
38+
needless_pass_by_value = "warn"
39+
redundant_clone = "warn"
40+
# Noisy lints intentionally suppressed
41+
module_name_repetitions = "allow"
42+
must_use_candidate = "allow"
43+
cast_possible_truncation = "allow"
44+
cast_sign_loss = "allow"
45+
cast_possible_wrap = "allow"

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2026 Oxidized
3+
Copyright (c) 2026 Oxidized Contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# oxidized-chat
2+
3+
[![CI](https://github.com/oxidized-mc/chat/actions/workflows/ci.yml/badge.svg)](https://github.com/oxidized-mc/chat/actions/workflows/ci.yml)
4+
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5+
6+
Minecraft chat component system — Component tree, Style, ChatFormatting, TextColor, JSON/NBT serialization
7+
8+
Part of the [Oxidized MC](https://github.com/oxidized-mc) ecosystem — a Minecraft Java Edition
9+
implementation in Rust.
10+
11+
## License
12+
13+
Licensed under the [MIT License](LICENSE).
14+
15+
## Contributing
16+
17+
Contributions are welcome! Please see the [Oxidized MC](https://github.com/oxidized-mc) organization
18+
for project-wide guidelines.

deny.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[advisories]
2+
version = 2
3+
ignore = [
4+
# rsa: Marvin Attack timing sidechannel (RUSTSEC-2023-0071)
5+
# No patched version available; rsa 0.10 is still RC.
6+
# We only use RSA for Minecraft login key exchange (not security-critical).
7+
"RUSTSEC-2023-0071",
8+
]
9+
10+
[licenses]
11+
version = 2
12+
allow = [
13+
"MIT",
14+
"Apache-2.0",
15+
"Apache-2.0 WITH LLVM-exception",
16+
"BSD-2-Clause",
17+
"BSD-3-Clause",
18+
"ISC",
19+
"Unicode-3.0",
20+
"Zlib",
21+
"CC0-1.0",
22+
"OpenSSL",
23+
"CDLA-Permissive-2.0",
24+
"BSL-1.0",
25+
]
26+
27+
[bans]
28+
multiple-versions = "warn"
29+
wildcards = "allow"
30+
31+
[sources]
32+
unknown-registry = "deny"
33+
unknown-git = "deny"
34+
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
35+
allow-git = ["https://github.com/oxidized-mc"]

0 commit comments

Comments
 (0)