diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 8c9aaec..fab41af 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -4,7 +4,7 @@ on: push: branches: [ none ] pull_request: - branches: [ main ] + branches: [ none ] workflow_dispatch: env: diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml deleted file mode 100644 index 371d90e..0000000 --- a/.github/workflows/build_linux.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Linux - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - workflow_dispatch: - -env: - CARGO_TERM_COLOR: always - -jobs: - test: - name: test - runs-on: ubuntu-latest - steps: - - name: Nix dependencies - run: sudo apt-get update; sudo apt-get -y install libasound2-dev libudev-dev lld - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - - run: cargo test --release --workspace - build: - name: build - runs-on: ubuntu-latest - steps: - - name: Nix dependencies - run: sudo apt-get update; sudo apt-get -y install libasound2-dev libudev-dev lld - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - - run: cargo build --release --workspace diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml deleted file mode 100644 index 750224a..0000000 --- a/.github/workflows/build_macos.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: MacOS - -on: - push: - branches: [ none ] - pull_request: - branches: [ main ] - workflow_dispatch: - -env: - CARGO_TERM_COLOR: always - -jobs: - test: - name: test - runs-on: macos-latest - steps: - - name: deps - run: brew install michaeleisel/zld/zld - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - - run: cargo build --release --workspace - build: - name: build - runs-on: macos-latest - steps: - - name: deps - run: brew install michaeleisel/zld/zld - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - - run: cargo build --release --workspace diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml deleted file mode 100644 index 2e598bc..0000000 --- a/.github/workflows/build_windows.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Windows - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - workflow_dispatch: - -env: - CARGO_TERM_COLOR: always - -jobs: - test: - name: test - runs-on: windows-latest - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - - run: cargo test --release --workspace - # - name: Install latest - # uses: actions-rs/toolchain@v1 - # with: - # toolchain: stable - # override: true - # - name: Install fast compile deps - # uses: actions-rs/cargo@v1 - # with: - # command: install - # args: -f cargo-binutils - # - name: Install linker - # uses: actions-rs/toolchain@v1 - # with: - # components: llvm-tools-preview - build: - name: build - runs-on: windows-latest - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - - run: cargo build --release --workspace - # - name: Install Just - # uses: actions-rs/cargo@v1 - # with: - # command: install - # args: just - # - name: Generate Examples - # run: just generate-examples -vv - # shell: powershell diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b7796cb --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,64 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + +jobs: + nix_test: + name: nix_test + runs-on: ubuntu-latest + steps: + - name: Nix dependencies + run: sudo apt-get update; sudo apt-get -y install libasound2-dev libudev-dev lld + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - run: cargo test --release --workspace --all-features + nix_build: + name: nix_build + runs-on: ubuntu-latest + steps: + - name: Nix dependencies + run: sudo apt-get update; sudo apt-get -y install libasound2-dev libudev-dev lld + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - run: cargo build --release --workspace + win_test: + name: win_test + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - run: cargo test --release --workspace --all-features + win_build: + name: win_build + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - run: cargo build --release --workspace + # uses so many build action minutes :( + # macos_test: + # name: macos_test + # runs-on: macos-latest + # steps: + # - name: deps + # run: brew install michaeleisel/zld/zld + # - uses: actions/checkout@v3 + # - uses: dtolnay/rust-toolchain@stable + # - run: cargo build --release --workspace --all-features + # macos_build: + # name: macos_build + # runs-on: macos-latest + # steps: + # - name: deps + # run: brew install michaeleisel/zld/zld + # - uses: actions/checkout@v3 + # - uses: dtolnay/rust-toolchain@stable + # - run: cargo build --release --workspace diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index 474795e..daa1662 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -2,7 +2,7 @@ name: Clippy on: push: - branches: [ none ] + branches: [ main ] pull_request: branches: [ main ] workflow_dispatch: @@ -19,5 +19,5 @@ jobs: run: sudo apt-get update; sudo apt-get -y install libasound2-dev libudev-dev lld - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@stable - - run: cargo clippy --workspace --all-targets --all-features -- -D warnings -D clippy::cargo_common_metadata -D clippy::missing_docs_in_private_items -W clippy::todo -W clippy::unimplemented + - run: cargo clippy --workspace --all-targets --all-features -- -D warnings -D clippy::cargo_common_metadata -D clippy::missing_docs_in_private_items -D clippy::todo -W clippy::unimplemented diff --git a/.github/workflows/code-cov.yml b/.github/workflows/code-cov.yml new file mode 100644 index 0000000..5b2d162 --- /dev/null +++ b/.github/workflows/code-cov.yml @@ -0,0 +1,24 @@ +name: Code-cov + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + +jobs: + code_cov: + name: code_cov + runs-on: ubuntu-latest + steps: + - name: Nix dependencies + run: sudo apt-get update; sudo apt-get -y install libasound2-dev libudev-dev lld + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly + - run: | + cargo install cargo-tarpaulin + cargo tarpaulin --release --workspace --all-features --include-tests --engine=llvm --fail-under 85 --ignore-panics diff --git a/.github/workflows/doc-cov.yml b/.github/workflows/doc-cov.yml new file mode 100644 index 0000000..b44c2a6 --- /dev/null +++ b/.github/workflows/doc-cov.yml @@ -0,0 +1,24 @@ +name: Doc-cov + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + +jobs: + doc_cov: + name: doc_cov + runs-on: ubuntu-latest + steps: + - name: Nix dependencies + run: sudo apt-get update; sudo apt-get -y install libasound2-dev libudev-dev lld + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly + - run: | + export RUSTDOCFLAGS="-Z unstable-options --show-coverage" + cargo +nightly doc --workspace --all-features --no-deps --release diff --git a/Cargo.toml b/Cargo.toml index 5584383..a33d7cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ version = "0.1.0" authors = ["BlondeBurrito"] edition = "2021" -rust-version = "1.70" +rust-version = "1.74" readme = "README.md" homepage = "https://github.com/BlondeBurrito/repo_template" repository = "https://github.com/BlondeBurrito/repo_template" @@ -10,6 +10,13 @@ keywords = ["utility"] [workspace] members = ["crates/*"] + +[workspace.lints.clippy] +cargo_common_metadata = "deny" +missing_docs_in_private_items = "deny" +todo = "deny" +unimplemented = "warn" + # Centralised way of managing versions across all crates and packages [workspace.dependencies] example_crate = { path = "crates/example_crate" } @@ -36,6 +43,8 @@ criterion = "0.5" [dependencies] example_crate = { workspace = true } +[features] + [profile.dev] opt-level = 1 @@ -46,6 +55,7 @@ strip = false [profile.release] codegen-units = 1 +# lto = true # slow strip = true # strip symbols to reduce binary size on linux and mac [[bench]] @@ -54,4 +64,5 @@ harness = false [[example]] name = "hello" -path = "examples/hello.rs" \ No newline at end of file +path = "examples/hello.rs" +required-features = [] \ No newline at end of file diff --git a/crates/example_crate/Cargo.toml b/crates/example_crate/Cargo.toml index eaedaf0..6c91811 100644 --- a/crates/example_crate/Cargo.toml +++ b/crates/example_crate/Cargo.toml @@ -13,3 +13,6 @@ publish = false [dependencies] # clap = { workspace = true } + +[lints] +workspace = true diff --git a/justfile b/justfile index 5826721..07bfd31 100644 --- a/justfile +++ b/justfile @@ -6,6 +6,7 @@ alias db := debug alias t := test alias b := build alias r := run +alias clogu := changelog-unreleased alias clog := changelog # alias cn := clean @@ -17,28 +18,47 @@ export RUST_BACKTRACE := bt default: just --list # lint the code aggressively -copyassets: - ./copy_assets.ps1 clippy: - cargo clippy --workspace --all-targets --all-features -- -D warnings -D clippy::cargo_common_metadata -D clippy::missing_docs_in_private_items -W clippy::todo -W clippy::unimplemented + cargo clippy --workspace --all-targets --all-features # run a chosen example example NAME: - cargo run --release --example {{NAME}} + cargo run --release --example {{NAME}} --all-features # run benchmarks bench: - cargo bench -q --benches --workspace + cargo bench -q --benches --workspace --all-features +# run a particular benchmark +bench-one BENCH: + cargo bench --benches --workspace --all-features {{BENCH}} +# save each benchmark, this should be run on the main branch for comparing with your own branch +bench-save-main: + cargo bench -q --bench calc_route --workspace --all-features -- --save-baseline main_calc_route + cargo bench -q --bench calc_flow_open --workspace --all-features -- --save-baseline main_calc_flow_open + cargo bench -q --bench calc_flow_maze --workspace --all-features -- --save-baseline main_calc_flow_maze + cargo bench -q --bench init_bundle --workspace --all-features -- --save-baseline main_init_bundle + cargo bench -q --bench init_cost_fields --workspace --all-features -- --save-baseline main_init_cost_fields + cargo bench -q --bench init_portals --workspace --all-features -- --save-baseline main_init_portals + cargo bench -q --bench init_portal_graph --workspace --all-features -- --save-baseline main_init_portal_graph +# compare each benchmark against a saved bench taken from main +bench-compare: + cargo bench -q --bench calc_route --workspace --all-features -- --baseline main_calc_route + cargo bench -q --bench calc_flow_open --workspace --all-features -- --baseline main_calc_flow_open + cargo bench -q --bench calc_flow_maze --workspace --all-features -- --baseline main_calc_flow_maze + cargo bench -q --bench init_bundle --workspace --all-features -- --baseline main_init_bundle + cargo bench -q --bench init_cost_fields --workspace --all-features -- --baseline main_init_cost_fields + cargo bench -q --bench init_portals --workspace --all-features -- --baseline main_init_portals + cargo bench -q --bench init_portal_graph --workspace --all-features -- --baseline main_init_portal_graph # run a debug build so the compiler can call out overflow errors etc, rather than making assumptions debug: - cargo build --workspace + cargo build --workspace --all-features # run tests test: debug - cargo test --release --workspace + cargo test --release --workspace --all-features # generate documentation doc: - cargo doc --release --workspace + cargo doc --release --workspace --all-features # build release bin/lib build: test doc - cargo build --release --workspace + cargo build --release --workspace --all-features --package repo_template # build and execute bin run: build cargo run --release --package repo_template @@ -51,13 +71,19 @@ push MESSAGE +BRANCH='main': git commit -m "{{MESSAGE}}" git push origin {{BRANCH}} # generate a changelog with git-cliff-based on conventional commits +changelog-unreleased: + git cliff -u -p CHANGELOG.md +# generate a changelog with git-cliff-based on conventional commits changelog TAG: git cliff --tag {{TAG}} --output CHANGELOG.md # evaluate documentation coverage doc-coverage: $env:RUSTDOCFLAGS="-Z unstable-options --show-coverage" - cargo +nightly doc --workspace --all-features --no-deps + cargo +nightly doc --workspace --all-features --no-deps --release # https://github.com/rust-lang/rust/issues/58154 +# evaluate test coverage +code-coverage: + cargo tarpaulin --release --workspace --all-features --include-tests --engine=llvm --ignore-panics # install the crate from the local source rather than remote install: cargo install --path . @@ -65,6 +91,7 @@ install: dev-tools: cargo install loc; cargo install git-cliff; + cargo install blondie; cargo install flamegraph; cargo install cargo-bloat; cargo install cargo-deadlinks; @@ -76,9 +103,10 @@ dev-tools: cargo install rust-script; rust-script --install-file-association; cargo install --locked cargo-deny -# Generate a diagram from a puml ile under ./docs + cargo install cargo-tarpaulin +# Generate a diagram from a puml file under ./docs/png diagram NAME: - java -jar "C:\ProgramData\chocolatey\lib\plantuml\tools\plantuml.jar" docs/{{NAME}}.puml -# Generate all diagrams under ./docs + java -jar "C:\ProgramData\chocolatey\lib\plantuml\tools\plantuml.jar" docs/png/{{NAME}}.puml +# Generate all puml diagrams under ./docs/png diagrams: - ForEach ($i in Get-ChildItem -Path "./docs/*.puml") {java -jar "C:\ProgramData\chocolatey\lib\plantuml\tools\plantuml.jar" $i.FullName} \ No newline at end of file + ForEach ($i in Get-ChildItem -Path "./docs/png/*.puml") {java -jar "C:\ProgramData\chocolatey\lib\plantuml\tools\plantuml.jar" $i.FullName} \ No newline at end of file