diff --git a/Cargo.toml b/Cargo.toml index 2d36774..59a619c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,30 +1,8 @@ -[package] -name = "codecov-rs" -version = "0.1.0" -edition = "2021" +[workspace] -[features] -default = ["pyreport"] -pyreport = [] +resolver = "2" +members = ["core"] [profile.release] -debug = 1 - -[dependencies] -include_dir = "0.7.3" -memmap2 = "0.9.4" -rand = "0.8.5" -rusqlite = { version = "0.31.0", features = ["bundled", "limits"] } -rusqlite_migration = { version = "1.2.0", features = ["from-directory"] } -seahash = "4.1.0" -serde_json = "1.0.117" -thiserror = "1.0.59" -winnow = "0.5.34" -[dev-dependencies] -divan = "0.1.14" -tempfile = "3.9.0" - -[[bench]] -name = "pyreport" -harness = false +debug = 1 diff --git a/README.md b/README.md index d838bee..ae7701d 100644 --- a/README.md +++ b/README.md @@ -16,22 +16,26 @@ All details (e.g. SQLite schema, code interfaces) subject to breaking changes un ## Developing -At time of writing, `codecov-rs` requires the nightly compiler for niceties such as `#[feature(trait_alias)]` in the library itself and some convenient `mockall` behavior in tests. +At time of writing, `codecov-rs` requires the nightly compiler for niceties such as `#[feature(trait_alias)]` in the library itself. `codecov-rs` aims to serve as effective documentation for every flavor of every format it supports. To that end, the following are greatly appreciated in submissions: - Thorough doc comments (`///` / `/**`). For parsers, include snippets that show what inputs look like -- Granular, in-module unit tests (`mockall` may help) +- Granular, in-module unit tests - Integration tests with real-world samples (that are safe to distribute; don't send us data from your private repo) +Large sample test reports are checked in using [Git LFS](https://git-lfs.com/) in `core/fixtures/**/large` directories (e.g. `core/fixtures/pyreport/large`). Tests and benchmarks may reference them so installing it yourself is recommended. + The `examples/` directory contains runnable commands for developers including: - `parse_pyreport`: converts a given pyreport into a SQLite report - `sql_to_pyreport`: converts a given SQLite report into a pyreport (report JSON + chunks file) -Considering following suit for your own new feature. +You can run an example with `cargo run --example `. Consider following suit for your own new feature. Install lint hooks with `pip install pre-commit && pre-commit install`. -Large sample test reports are checked in using [Git LFS](https://git-lfs.com/). Tests and benchmarks may reference them so installing it yourself is recommended. +### Repository structure + +- `core/`: Rust crate with all of the core coverage-processing functionality ### Writing new parsers diff --git a/core/Cargo.toml b/core/Cargo.toml new file mode 100644 index 0000000..bbbce34 --- /dev/null +++ b/core/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "codecov-rs" +version = "0.1.0" +edition = "2021" + +[features] +default = ["pyreport"] +pyreport = [] + +[dependencies] +include_dir = "0.7.3" +memmap2 = "0.9.4" +rand = "0.8.5" +rusqlite = { version = "0.31.0", features = ["bundled", "limits"] } +rusqlite_migration = { version = "1.2.0", features = ["from-directory"] } +seahash = "4.1.0" +serde_json = "1.0.117" +thiserror = "1.0.59" +winnow = "0.5.34" + +[dev-dependencies] +divan = "0.1.14" +tempfile = "3.9.0" + +[[bench]] +name = "pyreport" +harness = false diff --git a/benches/pyreport.rs b/core/benches/pyreport.rs similarity index 100% rename from benches/pyreport.rs rename to core/benches/pyreport.rs diff --git a/examples/parse_pyreport.rs b/core/examples/parse_pyreport.rs similarity index 100% rename from examples/parse_pyreport.rs rename to core/examples/parse_pyreport.rs diff --git a/examples/sql_to_pyreport.rs b/core/examples/sql_to_pyreport.rs similarity index 100% rename from examples/sql_to_pyreport.rs rename to core/examples/sql_to_pyreport.rs diff --git a/fixtures/pyreport/large/worker-c71ddfd4cb1753c7a540e5248c2beaa079fc3341-chunks.txt b/core/fixtures/pyreport/large/worker-c71ddfd4cb1753c7a540e5248c2beaa079fc3341-chunks.txt similarity index 100% rename from fixtures/pyreport/large/worker-c71ddfd4cb1753c7a540e5248c2beaa079fc3341-chunks.txt rename to core/fixtures/pyreport/large/worker-c71ddfd4cb1753c7a540e5248c2beaa079fc3341-chunks.txt diff --git a/fixtures/pyreport/large/worker-c71ddfd4cb1753c7a540e5248c2beaa079fc3341-report_json.json b/core/fixtures/pyreport/large/worker-c71ddfd4cb1753c7a540e5248c2beaa079fc3341-report_json.json similarity index 100% rename from fixtures/pyreport/large/worker-c71ddfd4cb1753c7a540e5248c2beaa079fc3341-report_json.json rename to core/fixtures/pyreport/large/worker-c71ddfd4cb1753c7a540e5248c2beaa079fc3341-report_json.json diff --git a/migrations/01-init/down.sql b/core/migrations/01-init/down.sql similarity index 100% rename from migrations/01-init/down.sql rename to core/migrations/01-init/down.sql diff --git a/migrations/01-init/up.sql b/core/migrations/01-init/up.sql similarity index 100% rename from migrations/01-init/up.sql rename to core/migrations/01-init/up.sql diff --git a/src/error.rs b/core/src/error.rs similarity index 100% rename from src/error.rs rename to core/src/error.rs diff --git a/src/lib.rs b/core/src/lib.rs similarity index 100% rename from src/lib.rs rename to core/src/lib.rs diff --git a/src/parsers/common.rs b/core/src/parsers/common.rs similarity index 100% rename from src/parsers/common.rs rename to core/src/parsers/common.rs diff --git a/src/parsers/json.rs b/core/src/parsers/json.rs similarity index 100% rename from src/parsers/json.rs rename to core/src/parsers/json.rs diff --git a/src/parsers/mod.rs b/core/src/parsers/mod.rs similarity index 100% rename from src/parsers/mod.rs rename to core/src/parsers/mod.rs diff --git a/src/parsers/pyreport/chunks.rs b/core/src/parsers/pyreport/chunks.rs similarity index 100% rename from src/parsers/pyreport/chunks.rs rename to core/src/parsers/pyreport/chunks.rs diff --git a/src/parsers/pyreport/mod.rs b/core/src/parsers/pyreport/mod.rs similarity index 100% rename from src/parsers/pyreport/mod.rs rename to core/src/parsers/pyreport/mod.rs diff --git a/src/parsers/pyreport/report_json.rs b/core/src/parsers/pyreport/report_json.rs similarity index 100% rename from src/parsers/pyreport/report_json.rs rename to core/src/parsers/pyreport/report_json.rs diff --git a/src/parsers/pyreport/utils.rs b/core/src/parsers/pyreport/utils.rs similarity index 100% rename from src/parsers/pyreport/utils.rs rename to core/src/parsers/pyreport/utils.rs diff --git a/src/report/mod.rs b/core/src/report/mod.rs similarity index 100% rename from src/report/mod.rs rename to core/src/report/mod.rs diff --git a/src/report/models.rs b/core/src/report/models.rs similarity index 100% rename from src/report/models.rs rename to core/src/report/models.rs diff --git a/src/report/pyreport/chunks.rs b/core/src/report/pyreport/chunks.rs similarity index 100% rename from src/report/pyreport/chunks.rs rename to core/src/report/pyreport/chunks.rs diff --git a/src/report/pyreport/mod.rs b/core/src/report/pyreport/mod.rs similarity index 100% rename from src/report/pyreport/mod.rs rename to core/src/report/pyreport/mod.rs diff --git a/src/report/pyreport/queries/chunks_file_header.sql b/core/src/report/pyreport/queries/chunks_file_header.sql similarity index 100% rename from src/report/pyreport/queries/chunks_file_header.sql rename to core/src/report/pyreport/queries/chunks_file_header.sql diff --git a/src/report/pyreport/queries/files_to_report_json.sql b/core/src/report/pyreport/queries/files_to_report_json.sql similarity index 100% rename from src/report/pyreport/queries/files_to_report_json.sql rename to core/src/report/pyreport/queries/files_to_report_json.sql diff --git a/src/report/pyreport/queries/samples_to_chunks.sql b/core/src/report/pyreport/queries/samples_to_chunks.sql similarity index 100% rename from src/report/pyreport/queries/samples_to_chunks.sql rename to core/src/report/pyreport/queries/samples_to_chunks.sql diff --git a/src/report/pyreport/queries/sessions_to_report_json.sql b/core/src/report/pyreport/queries/sessions_to_report_json.sql similarity index 100% rename from src/report/pyreport/queries/sessions_to_report_json.sql rename to core/src/report/pyreport/queries/sessions_to_report_json.sql diff --git a/src/report/pyreport/report_json.rs b/core/src/report/pyreport/report_json.rs similarity index 100% rename from src/report/pyreport/report_json.rs rename to core/src/report/pyreport/report_json.rs diff --git a/src/report/pyreport/types.rs b/core/src/report/pyreport/types.rs similarity index 100% rename from src/report/pyreport/types.rs rename to core/src/report/pyreport/types.rs diff --git a/src/report/sqlite/mod.rs b/core/src/report/sqlite/mod.rs similarity index 100% rename from src/report/sqlite/mod.rs rename to core/src/report/sqlite/mod.rs diff --git a/src/report/sqlite/models.rs b/core/src/report/sqlite/models.rs similarity index 100% rename from src/report/sqlite/models.rs rename to core/src/report/sqlite/models.rs diff --git a/src/report/sqlite/queries/totals.sql b/core/src/report/sqlite/queries/totals.sql similarity index 100% rename from src/report/sqlite/queries/totals.sql rename to core/src/report/sqlite/queries/totals.sql diff --git a/src/report/sqlite/report.rs b/core/src/report/sqlite/report.rs similarity index 100% rename from src/report/sqlite/report.rs rename to core/src/report/sqlite/report.rs diff --git a/src/report/sqlite/report_builder.rs b/core/src/report/sqlite/report_builder.rs similarity index 100% rename from src/report/sqlite/report_builder.rs rename to core/src/report/sqlite/report_builder.rs diff --git a/src/report/test.rs b/core/src/report/test.rs similarity index 100% rename from src/report/test.rs rename to core/src/report/test.rs diff --git a/tests/common/mod.rs b/core/tests/common/mod.rs similarity index 100% rename from tests/common/mod.rs rename to core/tests/common/mod.rs diff --git a/tests/common/sample_data/codecov-rs-chunks-d2a9ba1.txt b/core/tests/common/sample_data/codecov-rs-chunks-d2a9ba1.txt similarity index 100% rename from tests/common/sample_data/codecov-rs-chunks-d2a9ba1.txt rename to core/tests/common/sample_data/codecov-rs-chunks-d2a9ba1.txt diff --git a/tests/common/sample_data/codecov-rs-reports-json-d2a9ba1.txt b/core/tests/common/sample_data/codecov-rs-reports-json-d2a9ba1.txt similarity index 100% rename from tests/common/sample_data/codecov-rs-reports-json-d2a9ba1.txt rename to core/tests/common/sample_data/codecov-rs-reports-json-d2a9ba1.txt diff --git a/tests/test_pyreport_shim.rs b/core/tests/test_pyreport_shim.rs similarity index 100% rename from tests/test_pyreport_shim.rs rename to core/tests/test_pyreport_shim.rs diff --git a/tests/test_sqlite_report.rs b/core/tests/test_sqlite_report.rs similarity index 100% rename from tests/test_sqlite_report.rs rename to core/tests/test_sqlite_report.rs