Skip to content

Commit 89b109a

Browse files
feat: initial release of warcraft-rs with the MPQ crate
0 parents  commit 89b109a

File tree

218 files changed

+51460
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

218 files changed

+51460
-0
lines changed

.editorconfig

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
; top-most EditorConfig file
2+
root = true
3+
4+
; Unix-style newlines
5+
[*]
6+
charset = utf-8
7+
end_of_line = lf
8+
indent_size = 4
9+
indent_style = space
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
[*.md]
14+
indent_size = 2
15+
trim_trailing_whitespace = false
16+
17+
[{Makefile,justfile,*.bash,*.sh}]
18+
indent_style = tab
19+
20+
[*.{ps1,bat,cmd,inf}]
21+
indent_style = tab
22+
end_of_line = crlf
23+
24+
[*.{json,toml,yml,yaml,xml}]
25+
indent_size = 4
26+
27+
[*.{js,jsx,php,ts,tsx,twig}]
28+
indent_size = 4
29+
30+
[*.{html,css}]
31+
indent_size = 4
32+
33+
[{Capfile,Gemfile,*.rb,*.rake}]
34+
indent_size = 2
35+
36+
[*.rs]
37+
charset = utf-8
38+
end_of_line = lf
39+
indent_style = space
40+
indent_size = 4
41+
trim_trailing_whitespace = true
42+
43+
[*.{hcl,tf,tfvars}]
44+
indent_size = 2
45+
46+
[.pass-template]
47+
indent_size = 2

.gitattributes

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Handle line endings automatically for files detected as text
2+
# and leave all files detected as binary untouched.
3+
* text=auto
4+
5+
#
6+
# The above will handle all files NOT found below
7+
#
8+
# These files are text and should be normalized (Convert crlf => lf)
9+
*.gitattributes text
10+
.gitignore text
11+
*.md text
12+
13+
#
14+
# The following files are Windows specific and will thus be allowed
15+
# in crlf form
16+
*.ps1 text eol=crlf
17+
*.bat text eol=crlf
18+
*.cmd text eol=crlf
19+
*.inf text eol=crlf
20+
21+
#
22+
# This will allow git to show diffs using GPG.
23+
*.gpg filter=gpg diff=gpg
24+
*.asc filter=gpg diff=gpg

.github/workflows/benchmarks.yml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
name: Benchmarks
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
CARGO_INCREMENTAL: 0
13+
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
14+
15+
permissions:
16+
contents: write
17+
deployments: write
18+
19+
jobs:
20+
benchmark:
21+
name: Performance Benchmarks
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: dtolnay/rust-toolchain@stable
26+
with:
27+
toolchain: stable
28+
- uses: Swatinem/rust-cache@v2
29+
with:
30+
shared-key: 'benchmarks'
31+
cache-on-failure: true
32+
33+
# Run benchmarks
34+
- name: Run benchmarks
35+
run: cargo bench
36+
37+
criterion-benchmarks:
38+
name: Criterion Benchmarks
39+
runs-on: ubuntu-latest
40+
if: github.event_name == 'pull_request'
41+
steps:
42+
- uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0
45+
46+
- uses: dtolnay/rust-toolchain@stable
47+
with:
48+
toolchain: stable
49+
50+
- uses: Swatinem/rust-cache@v2
51+
with:
52+
shared-key: 'criterion'
53+
cache-on-failure: true
54+
55+
# Cache critcmp installation
56+
- name: Cache critcmp
57+
id: cache-critcmp
58+
uses: actions/cache@v4
59+
with:
60+
path: ~/.cargo/bin/critcmp
61+
key: critcmp-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
62+
63+
# Install critcmp for comparing results
64+
- name: Install critcmp
65+
if: steps.cache-critcmp.outputs.cache-hit != 'true'
66+
run: |
67+
# Try cargo-binstall first for faster installation
68+
if command -v cargo-binstall >/dev/null 2>&1; then
69+
cargo binstall --no-confirm critcmp
70+
else
71+
cargo install critcmp
72+
fi
73+
74+
# Checkout base branch
75+
- name: Checkout base branch
76+
run: |
77+
git fetch origin ${{ github.base_ref }}
78+
git checkout origin/${{ github.base_ref }}
79+
80+
# Run benchmarks on base branch
81+
- name: Run base benchmarks
82+
run: |
83+
cargo bench -- --save-baseline base
84+
85+
# Checkout PR branch
86+
- name: Checkout PR branch
87+
run: git checkout ${{ github.sha }}
88+
89+
# Run benchmarks on PR branch
90+
- name: Run PR benchmarks
91+
run: |
92+
cargo bench -- --save-baseline pr
93+
94+
# Compare results
95+
- name: Compare benchmarks
96+
run: |
97+
critcmp base pr > comparison.txt
98+
cat comparison.txt
99+
100+
# Comment on PR
101+
- name: Comment PR
102+
uses: actions/github-script@v7
103+
if: github.event_name == 'pull_request'
104+
with:
105+
script: |
106+
const fs = require('fs');
107+
const comparison = fs.readFileSync('comparison.txt', 'utf8');
108+
109+
// Find existing comment
110+
const { data: comments } = await github.rest.issues.listComments({
111+
owner: context.repo.owner,
112+
repo: context.repo.repo,
113+
issue_number: context.issue.number,
114+
});
115+
116+
const botComment = comments.find(comment =>
117+
comment.user.type === 'Bot' &&
118+
comment.body.includes('## Benchmark Results')
119+
);
120+
121+
const body = `## Benchmark Results\n\n\`\`\`\n${comparison}\n\`\`\``;
122+
123+
if (botComment) {
124+
await github.rest.issues.updateComment({
125+
owner: context.repo.owner,
126+
repo: context.repo.repo,
127+
comment_id: botComment.id,
128+
body
129+
});
130+
} else {
131+
await github.rest.issues.createComment({
132+
owner: context.repo.owner,
133+
repo: context.repo.repo,
134+
issue_number: context.issue.number,
135+
body
136+
});
137+
}

.github/workflows/ci.yml

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
merge_group:
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
RUST_BACKTRACE: 1
13+
RUSTFLAGS: -D warnings
14+
CARGO_INCREMENTAL: 0
15+
CARGO_NET_RETRY: 10
16+
RUSTUP_MAX_RETRIES: 10
17+
# Performance improvements
18+
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
19+
CARGO_PROFILE_DEV_DEBUG: 0
20+
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.ref }}
23+
cancel-in-progress: true
24+
25+
jobs:
26+
# Quick checks that should fail fast
27+
quick-checks:
28+
name: Quick Checks
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
- uses: dtolnay/rust-toolchain@stable
33+
with:
34+
toolchain: 1.86.0
35+
components: rustfmt, clippy
36+
- uses: Swatinem/rust-cache@v2
37+
with:
38+
shared-key: 'quick-checks'
39+
cache-on-failure: true
40+
41+
# Format check (fastest)
42+
- name: Check formatting
43+
run: cargo fmt --all -- --check
44+
45+
# Check compilation
46+
- name: Check compilation
47+
run: cargo check --all-features --all-targets
48+
49+
# Clippy lints
50+
- name: Clippy
51+
run: cargo clippy --all-features --all-targets -- -D warnings
52+
53+
# Main test suite with optimized matrix
54+
test:
55+
name: Test (${{ matrix.rust }} on ${{ matrix.os }})
56+
needs: [quick-checks]
57+
strategy:
58+
fail-fast: false
59+
matrix:
60+
include:
61+
# MSRV check on Linux only
62+
- os: ubuntu-latest
63+
rust: 1.86.0
64+
# Stable on all platforms
65+
- os: ubuntu-latest
66+
rust: stable
67+
- os: windows-latest
68+
rust: stable
69+
- os: macos-latest
70+
rust: stable
71+
# Beta on Linux only
72+
- os: ubuntu-latest
73+
rust: beta
74+
runs-on: ${{ matrix.os }}
75+
steps:
76+
- uses: actions/checkout@v4
77+
- uses: dtolnay/rust-toolchain@master
78+
with:
79+
toolchain: ${{ matrix.rust }}
80+
- uses: Swatinem/rust-cache@v2
81+
with:
82+
shared-key: 'tests-${{ matrix.os }}-${{ matrix.rust }}'
83+
cache-on-failure: true
84+
cache-all-crates: true
85+
86+
# Test with all features
87+
- name: Test all features
88+
run: cargo test --all-features --workspace
89+
90+
# Test with no default features
91+
- name: Test no default features
92+
run: cargo test --no-default-features --workspace
93+
94+
# Test each crate individually (only on stable Linux)
95+
- name: Test individual crates
96+
if: matrix.os == 'ubuntu-latest' && matrix.rust == 'stable'
97+
run: |
98+
cargo test -p wow-mpq --all-features
99+
cargo test -p wow-blp --all-features
100+
cargo test -p wow-m2 --all-features
101+
cargo test -p wow-wmo --all-features
102+
cargo test -p wow-adt --all-features
103+
cargo test -p wow-wdl --all-features
104+
cargo test -p wow-wdt --all-features
105+
cargo test -p wow-dbc --all-features
106+
cargo test -p warcraft-cli-utils --all-features
107+
108+
# Documentation build - runs in parallel
109+
docs:
110+
name: Documentation
111+
runs-on: ubuntu-latest
112+
steps:
113+
- uses: actions/checkout@v4
114+
- uses: dtolnay/rust-toolchain@stable
115+
with:
116+
toolchain: 1.86.0
117+
- uses: Swatinem/rust-cache@v2
118+
with:
119+
shared-key: 'docs'
120+
cache-on-failure: true
121+
- name: Build documentation
122+
run: cargo doc --all-features --no-deps
123+
env:
124+
RUSTDOCFLAGS: -D warnings
125+
- name: Check for broken links
126+
run: cargo doc --all-features --no-deps --document-private-items
127+
128+
# Coverage collection - runs in parallel
129+
coverage:
130+
name: Code Coverage
131+
runs-on: ubuntu-latest
132+
steps:
133+
- uses: actions/checkout@v4
134+
- uses: dtolnay/rust-toolchain@stable
135+
with:
136+
toolchain: stable
137+
components: llvm-tools-preview
138+
- uses: Swatinem/rust-cache@v2
139+
with:
140+
shared-key: 'coverage'
141+
cache-on-failure: true
142+
- uses: taiki-e/install-action@cargo-llvm-cov
143+
144+
- name: Collect coverage
145+
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
146+
147+
- name: Upload to Codecov
148+
uses: codecov/codecov-action@v5
149+
with:
150+
files: lcov.info
151+
fail_ci_if_error: true
152+
token: ${{ secrets.CODECOV_TOKEN }}
153+
154+
# Success marker for branch protection
155+
ci-success:
156+
name: CI Success
157+
if: always()
158+
needs: [quick-checks, test, docs, coverage]
159+
runs-on: ubuntu-latest
160+
steps:
161+
- name: Check all jobs
162+
run: |
163+
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
164+
echo "One or more jobs failed"
165+
exit 1
166+
else
167+
echo "All jobs succeeded"
168+
fi

0 commit comments

Comments
 (0)