Skip to content

Commit

Permalink
Merge pull request #6 from sebastienrousseau/feat/frontmatter-gen
Browse files Browse the repository at this point in the history
v3.0
  • Loading branch information
sebastienrousseau authored Nov 17, 2024
2 parents e182c30 + ebbd31d commit 82b0c19
Show file tree
Hide file tree
Showing 28 changed files with 6,757 additions and 1,600 deletions.
55 changes: 13 additions & 42 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,32 @@
name: 📶 Coverage

on:
push:
branches:
- main
pull_request:

env:
CARGO_TERM_COLOR: always
on: [push]

jobs:
coverage:
name: Code Coverage
lint:
runs-on: ubuntu-latest
env:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests"
RUSTDOCFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests"

steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v4

# Setup Rust nightly
- name: Install Rust
uses: actions-rs/toolchain@v1
id: toolchain
with:
toolchain: nightly
toolchain: stable
override: true

# Configure cache for Cargo
- name: Cache Cargo registry, index
uses: actions/cache@v4
id: cache-cargo
with:
path: |
~/.cargo/registry
~/.cargo/bin
~/.cargo/git
key: linux-${{ steps.toolchain.outputs.rustc_hash }}-rust-cov-${{ hashFiles('**/Cargo.lock') }}

# Run tests with all features
- name: Test (cargo test)
uses: actions-rs/cargo@v1
with:
command: test
args: "--workspace"
- name: Install Cargo Tarpaulin
run: cargo install cargo-tarpaulin

# Install grcov
- uses: actions-rs/[email protected]
id: coverage
- name: Run tests with coverage
run: cargo tarpaulin --out Lcov --all-features --no-fail-fast
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: '-Ccodegen-units=1 -Clink-dead-code -Coverflow-checks=off'
RUSTDOCFLAGS: ''

# Upload to Codecov.io
- name: Upload to Codecov.io
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ${{ steps.coverage.outputs.report }}
files: lcov.info
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ jobs:
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --verbose --release --target ${{ matrix.target }}
run: cargo build --verbose --release --target ${{ matrix.target }} --features="ssg"

- name: Package
run: |
if [ ! -d "target/package" ]; then
Expand Down
223 changes: 208 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[package]
name = "frontmatter-gen"
version = "0.0.2"
version = "0.0.3"
edition = "2021"
rust-version = "1.56.0"
license = "MIT OR Apache-2.0"
Expand All @@ -28,39 +28,104 @@ categories = [
"development-tools"
]

# Keywords for easier discoverability on Crates.io.
keywords = ["frontmatter", "yaml", "toml", "json", "frontmatter-gen"]

# Excluding unnecessary files from the package
exclude = [
"/.git/*", # Exclude version control files
"/.github/*", # Exclude GitHub workflows
"/.gitignore", # Ignore Git ignore file
"/.vscode/*" # Ignore VSCode settings
]

# Including necessary files in the package
include = [
"/CONTRIBUTING.md",
"/LICENSE-APACHE",
"/LICENSE-MIT",
"/benches/**",
"/build.rs",
"/Cargo.toml",
"/examples/**",
"/README.md",
"/src/**",
]

# -----------------------------------------------------------------------------
# Library Information
# -----------------------------------------------------------------------------

# The library file that contains the main logic for the binary.
[lib]
name = "frontmatter_gen"
path = "src/lib.rs"

# The main file that contains the entry point for the binary.
[[bin]]
name = "frontmatter_gen"
path = "src/main.rs"
required-features = ["cli"]

# -----------------------------------------------------------------------------
# Features
# -----------------------------------------------------------------------------
[features]
# Optional features that can be enabled or disabled.
default = [] # SSG is not enabled by default
cli = ["dep:clap"] # CLI functionality only
ssg = [ # Full SSG functionality
"cli", # Include CLI as part of SSG
"dep:tera",
"dep:pulldown-cmark",
"dep:tokio",
"dep:dtt",
"dep:log",
"dep:url",
]
logging = ["dep:log"] # Optional logging feature

# -----------------------------------------------------------------------------
# Dependencies
# -----------------------------------------------------------------------------

[dependencies]

serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
# Core dependencies
anyhow = "1.0.93"
serde = { version = "1.0.215", features = ["derive"] }
serde_json = "1.0.133"
serde_yml = "0.0.12"
thiserror = "2.0"
toml = "0.8"
tokio = { version = "1.0", features = ["full"] }
thiserror = "2.0.3"
toml = "0.8.19"
uuid = { version = "1.11.0", features = ["v4", "serde"] }

# Optional logging (only included when "logging" feature is enabled)
log = { version = "0.4.22", optional = true }

# Optional CLI and SSG dependencies - all must have optional = true
clap = { version = "4.5.21", features = ["derive"], optional = true }
dtt = { version = "0.0.8", optional = true }
pulldown-cmark = { version = "0.12.2", optional = true }
tempfile = "3.14.0"
tera = { version = "1.20.0", optional = true }
tokio = { version = "1.41.1", features = ["full"], optional = true }
url = { version = "2.5.3", optional = true }

# -----------------------------------------------------------------------------
# Build Dependencies
# -----------------------------------------------------------------------------

[build-dependencies]
version_check = "0.9"
version_check = "0.9.5"

# -----------------------------------------------------------------------------
# Development Dependencies
# -----------------------------------------------------------------------------

[dev-dependencies]
criterion = "0.5"
serde = { version = "1.0", features = ["derive"] }
criterion = "0.5.1"
pretty_assertions = "1.4.1"


# -----------------------------------------------------------------------------
# Examples
Expand Down Expand Up @@ -89,10 +154,138 @@ path = "examples/types_examples.rs"
# -----------------------------------------------------------------------------
# Criterion Benchmark
# -----------------------------------------------------------------------------
[[bench]] # Benchmarking configuration.
name = "frontmatter_benchmark" # Name of the benchmark.
harness = false # Disable the default benchmark harness.

# -----------------------------------------------------------------------------
# Documentation Configuration
# -----------------------------------------------------------------------------
[package.metadata.docs.rs]
# Settings for building and hosting documentation on docs.rs.
all-features = true # Build documentation with all features enabled
rustdoc-args = ["--cfg", "docsrs"] # Arguments passed to `rustdoc` when building the documentation
targets = ["x86_64-unknown-linux-gnu"] # Default target platform for the docs

# -----------------------------------------------------------------------------
# Linting Configuration
# -----------------------------------------------------------------------------
[lints.rust]
# Linting rules for the project.

## Warnings
missing_copy_implementations = "warn" # Warn if types can implement `Copy` but don’t
missing_docs = "warn" # Warn if public items lack documentation
unstable_features = "warn" # Warn on the usage of unstable features
unused_extern_crates = "warn" # Warn about unused external crates
unused_results = "warn" # Warn if a result type is unused (e.g., errors ignored)

## Allowances
bare_trait_objects = "allow" # Allow bare trait objects (e.g., `Box<dyn Trait>`)
elided_lifetimes_in_paths = "allow" # Allow lifetimes to be elided in paths
non_camel_case_types = "allow" # Allow non-camel-case types
non_upper_case_globals = "allow" # Allow non-uppercase global variables
trivial_bounds = "allow" # Allow trivial bounds in trait definitions
unsafe_code = "allow" # Allow the usage of unsafe code blocks

## Forbidden
missing_debug_implementations = "forbid" # Forbid missing `Debug` implementations
non_ascii_idents = "forbid" # Forbid non-ASCII identifiers
unreachable_pub = "forbid" # Forbid unreachable `pub` items

## Denials
dead_code = "deny" # Deny unused, dead code in the project
deprecated_in_future = "deny" # Deny code that will be deprecated in the future
ellipsis_inclusive_range_patterns = "deny" # Deny usage of inclusive ranges in match patterns (`...`)
explicit_outlives_requirements = "deny" # Deny unnecessary lifetime outlives requirements
future_incompatible = { level = "deny", priority = -1 } # Handle future compatibility issues
keyword_idents = { level = "deny", priority = -1 } # Deny usage of keywords as identifiers
macro_use_extern_crate = "deny" # Deny macro use of `extern crate`
meta_variable_misuse = "deny" # Deny misuse of meta variables in macros
missing_fragment_specifier = "deny" # Deny missing fragment specifiers in macros
noop_method_call = "deny" # Deny method calls that have no effect
rust_2018_idioms = { level = "deny", priority = -1 } # Enforce Rust 2018 idioms
rust_2021_compatibility = { level = "deny", priority = -1 } # Enforce Rust 2021 compatibility
single_use_lifetimes = "deny" # Deny lifetimes that are used only once
trivial_casts = "deny" # Deny trivial casts (e.g., `as` when unnecessary)
trivial_numeric_casts = "deny" # Deny trivial numeric casts (e.g., `i32` to `i64`)
unused = { level = "deny", priority = -1 } # Deny unused code, variables, etc.
unused_features = "deny" # Deny unused features
unused_import_braces = "deny" # Deny unnecessary braces around imports
unused_labels = "deny" # Deny unused labels in loops
unused_lifetimes = "deny" # Deny unused lifetimes
unused_macro_rules = "deny" # Deny unused macros
unused_qualifications = "deny" # Deny unnecessary type qualifications
variant_size_differences = "deny" # Deny enum variants with significant size differences

# -----------------------------------------------------------------------------
# Clippy Configuration
# -----------------------------------------------------------------------------
[package.metadata.clippy]
# Clippy lint configuration for enhanced code analysis.
warn-lints = [
"clippy::all", # Enable all common Clippy lints
"clippy::pedantic", # Enable pedantic lints for stricter checking
"clippy::cargo", # Enable lints specific to cargo
"clippy::nursery", # Enable experimental lints from Clippy’s nursery
"clippy::complexity", # Warn on code complexity and suggest improvements
"clippy::correctness", # Ensure code correctness, flagging potential issues
"clippy::perf", # Lints that catch performance issues
"clippy::style", # Suggest stylistic improvements
"clippy::suspicious", # Detect suspicious code patterns
"clippy::module_name_repetitions", # Avoid repeating module names in the crate name
]

# Customize Clippy to allow certain less critical lints.
allow-lints = [
"clippy::module_inception", # Allow modules with the same name as their parents
"clippy::too_many_arguments", # Allow functions with more than 7 arguments if justified
"clippy::missing_docs_in_private_items", # Skip requiring documentation for private items
]

# Enforce specific warnings and errors more strictly.
deny-lints = [
"clippy::unwrap_used", # Deny the use of unwrap to ensure error handling
"clippy::expect_used", # Deny the use of expect to avoid improper error handling
]

# -----------------------------------------------------------------------------
# Profiles
# -----------------------------------------------------------------------------
[profile.dev]
# Development profile configuration for fast builds and debugging.
codegen-units = 256 # Increase codegen units for faster compilation
debug = true # Enable debugging symbols
debug-assertions = true # Enable debug assertions
incremental = true # Enable incremental compilation
lto = false # Disable link-time optimization for development
opt-level = 0 # No optimizations in development
overflow-checks = true # Enable overflow checks for arithmetic operations
panic = 'unwind' # Enable unwinding for panics (useful in development)
rpath = false # Disable rpath generation
strip = false # Do not strip symbols in development builds

[[bench]]
name = "frontmatter_benchmark"
harness = false
[profile.release]
# Release profile configuration for optimized builds.
codegen-units = 1 # Reduce codegen units for better performance
debug = false # Disable debug symbols in release builds
debug-assertions = false # Disable debug assertions
incremental = false # Disable incremental compilation for optimal binary size
lto = true # Enable link-time optimization for smaller and faster binaries
opt-level = "z" # Optimize for binary size
overflow-checks = false # Disable overflow checks for performance
panic = "abort" # Use abort on panic for minimal overhead
rpath = false # Disable rpath generation
strip = "symbols" # Strip symbols for smaller binary size

[profile.bench]
debug = true
[profile.test]
# Test profile configuration for debugging and development.
codegen-units = 256 # Increase codegen units for faster test builds
debug = true # Enable debugging symbols for test builds
debug-assertions = true # Enable debug assertions for tests
incremental = true # Enable incremental compilation for tests
lto = false # Disable link-time optimization during testing
opt-level = 0 # No optimizations in test builds
overflow-checks = true # Enable overflow checks for tests
rpath = false # Disable rpath generation
strip = false # Do not strip symbols in test builds
Loading

0 comments on commit 82b0c19

Please sign in to comment.