diff --git a/.config/dictionaries/project.dic b/.config/dictionaries/project.dic index 32cdfbf17..f0097e171 100644 --- a/.config/dictionaries/project.dic +++ b/.config/dictionaries/project.dic @@ -60,4 +60,17 @@ uniseg webkitallowfullscreen WORKDIR xerrors -zstd \ No newline at end of file +zstd +idents +rustflags +rustdoc +rustdocflags +rustfmt +codegen +lintfix +testunit +nextest +testcov +testdocs +fmtchk +fmtfix \ No newline at end of file diff --git a/.gitignore b/.gitignore index efe357d0d..d34942e63 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ node_modules # Local Build Artefacts target/ +Cargo.lock # Python junk **/*.pyc \ No newline at end of file diff --git a/docs/src/guides/languages/rust.md b/docs/src/guides/languages/rust.md index e7650adda..a54eb215e 100644 --- a/docs/src/guides/languages/rust.md +++ b/docs/src/guides/languages/rust.md @@ -9,7 +9,7 @@ tags: # :simple-rust: Rust - + ## Introduction @@ -53,13 +53,11 @@ VERSION --global-cache 0.7 # Set up our target toolchains, and copy our files. builder: - FROM ./../../earthly/rust+rust-base + DO ./../../earthly/rust+SETUP COPY --dir .cargo .config crates . - COPY Cargo.lock Cargo.toml . + COPY Cargo.toml . COPY clippy.toml deny.toml rustfmt.toml . - - DO ./../../earthly/rust+SETUP ``` The first target `builder` is responsible for preparing an already configured Rust environment, @@ -129,10 +127,8 @@ build: FROM +builder TRY - RUN /scripts/std_build.py --build_flags="" \ - --with_test \ - --with_bench \ - --cov_report="coverage-report.info" \ + RUN /scripts/std_build.py --cov_report="coverage-report.info" \ + --with_docs \ --libs="bar" \ --bins="foo/foo" FINALLY @@ -173,6 +169,9 @@ Here is the full list of configuration of this script: --build_flags BUILD_FLAGS Additional command-line flags that can be passed to the `cargo build` command. + --lint_flags LINT_FLAGS + Additional command-line flags that can be passed to + the `cargo lint` command. --doctest_flags DOCTEST_FLAGS Additional command-line flags that can be passed to the `cargo testdocs` command. @@ -182,16 +181,18 @@ Here is the full list of configuration of this script: --bench_flags BENCH_FLAGS Additional command-line flags that can be passed to the `cargo bench` command. - --with_test Flag to indicate whether to run tests (including unit - tests and doc tests). --cov_report COV_REPORT The output coverage report file path. If omitted, coverage will not be run. - --with_bench Flag to indicate whether to run benchmarks. + --disable_tests Flag to disable to run tests (including unit tests and + doc tests). + --disable_benches Flag to disable to run benchmarks. + --disable_docs Flag to disable docs building (including graphs, trees + etc.) or not. --libs LIBS The list of lib crates `cargo-modules` docs to build separated by comma. --bins BINS The list of binaries `cargo-modules` docs to build and - made a smoke tests on them. . + make a smoke tests on them. ``` Note that the `libs` argument takes a list of library crate's names in your Rust project, e.g. diff --git a/earthly/postgresql/scripts/std_checks.sh b/earthly/postgresql/scripts/std_checks.sh index 85364029a..9c8d47ee4 100755 --- a/earthly/postgresql/scripts/std_checks.sh +++ b/earthly/postgresql/scripts/std_checks.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# cspell: words fmtchk fmtfix rustfmt stdcfgs nextest +# cspell: words stdcfgs # This script is run inside the `check` stage for rust projects to perform all # high level non-compilation checks. diff --git a/earthly/postgresql/scripts/std_docs.py b/earthly/postgresql/scripts/std_docs.py index 5f088c2f7..09789a49c 100755 --- a/earthly/postgresql/scripts/std_docs.py +++ b/earthly/postgresql/scripts/std_docs.py @@ -3,7 +3,7 @@ # cspell: words dbmigrations dbviz dbhost dbuser dbuserpw Tsvg from typing import Optional -import python.cli as cli +import python.exec_manager as exec_manager import python.db_ops as db_ops import argparse import rich @@ -223,7 +223,7 @@ def dbviz( comments: Optional[bool] = None, column_description_wrap: Optional[int] = None, table_description_wrap: Optional[int] = None, - ) -> cli.Result: + ) -> exec_manager.Result: if len(title) > 0: title = f' --title "{title}"' @@ -256,7 +256,7 @@ def dbviz( else: table_description_wrap = "" - res = cli.run( + res = exec_manager.cli_run( f"dbviz -d {self.args.dbname}" + f" -h {self.args.dbhost}" + f" -u {self.args.dbuser}" @@ -274,7 +274,7 @@ def dbviz( ) # if res.ok: - # cli.run( + # exec_manager.cli_run( # f"dot -Tsvg {filename}.dot -o {filename}", # name=f"Render Schema Diagram to SVG: {name}", # verbose=True, @@ -282,7 +282,7 @@ def dbviz( return res - def full_schema_diagram(self) -> cli.Result: + def full_schema_diagram(self) -> exec_manager.Result: # Create a full Schema Diagram. return self.dbviz( "docs/full-schema.svg", @@ -294,7 +294,7 @@ def full_schema_diagram(self) -> cli.Result: table_description_wrap=self.full_schema_table_description_wrap(), ) - def migration_schema_diagram(self, ver: int) -> cli.Result: + def migration_schema_diagram(self, ver: int) -> exec_manager.Result: # Create a schema diagram for an individual migration. if ver in self.migrations: migration = self.migrations[ver] @@ -303,7 +303,7 @@ def migration_schema_diagram(self, ver: int) -> cli.Result: self.all_schema_included_tables(), self.all_schema_excluded_tables() ) if include_tables is None: - return cli.Result( + return exec_manager.Result( 0, "", "", @@ -316,8 +316,8 @@ def migration_schema_diagram(self, ver: int) -> cli.Result: title = f"{migration.migration_name}" if migration.title and len(migration.title) > 0: title = migration.title - - comments=None + + comments = None if migration.comments is not None: comments = migration.comments else: @@ -334,7 +334,7 @@ def migration_schema_diagram(self, ver: int) -> cli.Result: table_description_wrap=migration.table_description_wrap, ) - def create_diagrams(self, results: cli.Results) -> cli.Results: + def create_diagrams(self, results: exec_manager.Results) -> exec_manager.Results: # Create a full Schema Diagram first. res = self.full_schema_diagram() results.add(res) @@ -343,7 +343,7 @@ def create_diagrams(self, results: cli.Results) -> cli.Results: res = self.migration_schema_diagram(ver) results.add(res) - # cli.run("ls -al docs", verbose=True) + # exec_manager.cli_run("ls -al docs", verbose=True) return results @@ -398,7 +398,7 @@ def main(): db = db_ops.DBOps(args) - results = cli.Results("Generate Database Documentation") + results = exec_manager.Results("Generate Database Documentation") # Init the DB. res = db.init_database() @@ -418,7 +418,7 @@ def main(): results.add(res) if res.ok(): - cli.run("mkdir docs") # Where we build the docs. + exec_manager.cli_run("mkdir docs") # Where we build the docs. # Get all info about the migrations. migrations = Migrations(args) @@ -426,7 +426,7 @@ def main(): if results.ok(): migrations.create_markdown_file("docs/migrations.md") - # cli.run("cat /tmp/migrations.md", verbose=True) + # exec_manager.cli_run("cat /tmp/migrations.md", verbose=True) results.print() diff --git a/earthly/rust/Earthfile b/earthly/rust/Earthfile index 36a040256..e89930a69 100644 --- a/earthly/rust/Earthfile +++ b/earthly/rust/Earthfile @@ -1,10 +1,12 @@ # Common Rust UDCs and Builders. VERSION --global-cache --use-function-keyword 0.7 -# cspell: words rustup miri nextest ripgrep colordiff rustfmt stdcfgs toolset depgraph lcov psycopg +# cspell: words rustup miri ripgrep colordiff stdcfgs toolset depgraph lcov psycopg # cspell: words TARGETPLATFORM TARGETOS TARGETARCH TARGETVARIANT USERPLATFORM USEROS USERARCH USERVARIANT # Base Rustup build container. +# Parameters: +# * toolchain : The `rust-toolchain` toml file. rust-base: ARG TARGETPLATFORM ARG TARGETOS @@ -19,7 +21,7 @@ rust-base: # The ACTUAL version of rust that will be used, and available targets # is controlled by a `rust-toolchain.toml` file when the `SETUP` UDC is run. # HOWEVER, It is enforced that the rust version in `rust-toolchain.toml` MUST match this version. - FROM rust:1.73-alpine3.18 + FROM rust:1.75-alpine3.18 RUN echo "TARGETPLATFORM = $TARGETPLATFORM"; \ echo "TARGETOS = $TARGETOS"; \ @@ -102,19 +104,15 @@ rust-base-all-hosts: # * toolchain : The `rust-toolchain` toml file. SETUP: FUNCTION - ARG toolchain=./rust-toolchain.toml + FROM +rust-base + + ARG toolchain=./rust-toolchain.toml # Copy our toolchain dependency. COPY $toolchain ./rust-toolchain.toml - ENV default_rust_channel=$(rg -oP 'channel\s*=\s*"\K[^"]+' rust-toolchain.toml) - - # Check that `default_rust_channel` and $RUST_VERSION from the rust-base container are exactly the same. - # This ensures CI Rust version and local rust version are properly aligned and prevents version skew. - RUN /scripts/verify_toolchain.sh $default_rust_channel $RUST_VERSION # Install pinned Rustup from `rust-toolchain.toml` # Plus nightly latest so we can use it for docs, lints, etc. - RUN rustup default $default_rust_channel && \ - rustup show && \ + RUN rustup show && \ cargo --version && \ cargo +nightly --version diff --git a/earthly/rust/scripts/std_build.py b/earthly/rust/scripts/std_build.py index 22eea24d4..06d1ac122 100755 --- a/earthly/rust/scripts/std_build.py +++ b/earthly/rust/scripts/std_build.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 -# cspell: words lcov testdocs nextest testunit depgraph testcov readelf +# cspell: words lcov depgraph readelf -import python.cli as cli +import python.exec_manager as exec_manager import argparse import rich @@ -11,144 +11,260 @@ # This improves visibility into all issues that need to be corrected for `build` # to pass without needing to iterate excessively. -def cargo_build(results: cli.Results, flags: str): - results.add(cli.run("cargo build " - + f"{flags} " - + "--release ", - name="Build all code in the workspace")) -def cargo_clippy(results: cli.Results): - results.add(cli.run("cargo lint ", - name="Clippy Lints in the workspace check")) +def cargo_build(results: exec_manager.Results, flags: str): + results.add( + exec_manager.cli_run( + "cargo build " + "--release " + f"{flags} ", + name="Build all code in the workspace", + ) + ) + -def cargo_doctest(results: cli.Results, flags: str): - results.add(cli.run("cargo testdocs " - + f"{flags} ", - name="Documentation tests all pass check")) +def cargo_lint(results: exec_manager.Results, flags: str): + results.add( + exec_manager.cli_run( + "cargo lint " + f"{flags}", name="Clippy Lints in the workspace check" + ) + ) -def cargo_nextest(results: cli.Results, flags: str): - results.add(cli.run("cargo testunit " - + f"{flags} ", - name="Self contained Unit tests all pass check")) -def cargo_llvm_cov(results: cli.Results, flags: str, cov_report: str): +def cargo_doctest(results: exec_manager.Results, flags: str): + results.add( + exec_manager.cli_run( + "cargo +nightly testdocs " + f"{flags} ", + name="Documentation tests all pass check", + ) + ) + + +def cargo_nextest(results: exec_manager.Results, flags: str): + results.add( + exec_manager.cli_run( + "cargo testunit " + f"{flags} ", + name="Self contained Unit tests all pass check", + ) + ) + + +def cargo_llvm_cov(results: exec_manager.Results, flags: str, cov_report: str): # Remove artifacts that may affect the coverage results - res = cli.run("cargo llvm-cov clean", - name="Remove artifacts that may affect the coverage results") + res = exec_manager.cli_run( + "cargo llvm-cov clean", + name="Remove artifacts that may affect the coverage results", + ) results.add(res) # Run unit tests and generates test and coverage report artifacts if res.ok(): - res = cli.run("cargo testcov " - + f"{flags} ", - name="Self contained Unit tests and collect coverage") + res = exec_manager.cli_run( + "cargo testcov " + f"{flags} ", + name="Self contained Unit tests and collect coverage", + ) results.add(res) # Save coverage report to file if it is provided if res.ok(): - res = cli.run("cargo llvm-cov report " - + f"{flags} " - + "--release " - + f"--output-path {cov_report} ", - name=f"Generate lcov report to {cov_report}") + res = exec_manager.cli_run( + "cargo llvm-cov report " + + f"{flags} " + + "--release " + + f"--output-path {cov_report} ", + name=f"Generate lcov report to {cov_report}", + ) results.add(res) -def cargo_bench(results: cli.Results, flags: str): - results.add(cli.run("cargo bench " - + f"{flags} " - + "--all-targets ", - name="Benchmarks all run to completion check")) - -def cargo_doc(results: cli.Results): - results.add(cli.run("cargo +nightly docs ", - name="Documentation build")) - -def cargo_depgraph(results: cli.Results): - results.add(cli.run("cargo depgraph " - + "--workspace-only " - + "--dedup-transitive-deps " - + "> target/doc/workspace.dot ", - name="Workspace dependency graphs generation")) - results.add(cli.run("cargo depgraph " - + "--dedup-transitive-deps " - + "> target/doc/full.dot ", - name="Full dependency graphs generation")) - results.add(cli.run("cargo depgraph " - + "--all-deps " - + "--dedup-transitive-deps " - + "> target/doc/all.dot ", - name="All dependency graphs generation")) - -def cargo_modules_lib(results: cli.Results, lib: str): + +def cargo_bench(results: exec_manager.Results, flags: str): + results.add( + exec_manager.cli_run( + "cargo bench " + f"{flags} ", + name="Benchmarks all run to completion check", + ) + ) + + +def cargo_doc(results: exec_manager.Results): + results.add( + exec_manager.cli_run("cargo +nightly docs ", name="Documentation build") + ) + + +def cargo_depgraph(results: exec_manager.Results): + results.add( + exec_manager.cli_run( + "cargo depgraph " + + "--workspace-only " + + "--dedup-transitive-deps " + + "> target/doc/workspace.dot ", + name="Workspace dependency graphs generation", + ) + ) + results.add( + exec_manager.cli_run( + "cargo depgraph " + "--dedup-transitive-deps " + "> target/doc/full.dot ", + name="Full dependency graphs generation", + ) + ) + results.add( + exec_manager.cli_run( + "cargo depgraph " + + "--all-deps " + + "--dedup-transitive-deps " + + "> target/doc/all.dot ", + name="All dependency graphs generation", + ) + ) + + +def cargo_modules_lib(results: exec_manager.Results, lib: str): # Generate tree - results.add(cli.run("NO_COLOR=1 " - + "cargo modules generate tree --orphans --types --traits --tests --all-features " - + f"--package '{lib}' --lib > 'target/doc/{lib}.lib.modules.tree' ", - name=f"Generate Module Trees for {lib}")) + results.add( + exec_manager.cli_run( + "NO_COLOR=1 " + + "cargo modules generate tree --orphans --types --traits --tests --all-features " + + f"--package '{lib}' --lib > 'target/doc/{lib}.lib.modules.tree' ", + name=f"Generate Module Trees for {lib}", + ) + ) # Generate graph - results.add(cli.run("NO_COLOR=1 " - + "cargo modules generate graph --all-features --modules " - + f"--package '{lib}' --lib > 'target/doc/{lib}.lib.modules.dot' ", - name=f"Generate Module Graphs for {lib}")) + results.add( + exec_manager.cli_run( + "NO_COLOR=1 " + + "cargo modules generate graph --all-features --modules " + + f"--package '{lib}' --lib > 'target/doc/{lib}.lib.modules.dot' ", + name=f"Generate Module Graphs for {lib}", + ) + ) + -def cargo_modules_bin(results: cli.Results, package: str, bin: str): +def cargo_modules_bin(results: exec_manager.Results, package: str, bin: str): # Generate tree - results.add(cli.run("NO_COLOR=1 " - + "cargo modules generate tree --orphans --types --traits --tests --all-features " - + f"--package '{package}' --bin '{bin}' > 'target/doc/{package}.{bin}.bin.modules.tree' ", - name=f"Generate Module Trees for {package}/{bin}")) + results.add( + exec_manager.cli_run( + "NO_COLOR=1 " + + "cargo modules generate tree --orphans --types --traits --tests --all-features " + + f"--package '{package}' --bin '{bin}' > 'target/doc/{package}.{bin}.bin.modules.tree' ", + name=f"Generate Module Trees for {package}/{bin}", + ) + ) # Generate graph - results.add(cli.run("NO_COLOR=1 " - + "cargo modules generate graph --all-features --modules " - + f"--package '{package}' --bin '{bin}' > 'target/doc/{package}.{bin}.bin.modules.dot' ", - name=f"Generate Module Graphs for {package}/{bin}")) + results.add( + exec_manager.cli_run( + "NO_COLOR=1 " + + "cargo modules generate graph --all-features --modules " + + f"--package '{package}' --bin '{bin}' > 'target/doc/{package}.{bin}.bin.modules.dot' ", + name=f"Generate Module Graphs for {package}/{bin}", + ) + ) + # ALL executables MUST have `--help` as an option. -def help_check(results: cli.Results, bin: str): - results.add(cli.run(f"target/release/{bin} --help", - name=f"Executable '{bin}' MUST have `--help` as an option.")) +def help_check(results: exec_manager.Results, bin: str): + results.add( + exec_manager.cli_run( + f"target/release/{bin} --help", + name=f"Executable '{bin}' MUST have `--help` as an option.", + ) + ) + + +def ldd(results: exec_manager.Results, bin: str): + results.add( + exec_manager.cli_run( + f"ldd target/release/{bin}", name=f"ldd for '{bin}'", verbose=True + ) + ) + + +def readelf(results: exec_manager.Results, bin: str): + results.add( + exec_manager.cli_run( + f"readelf -p .comment target/release/{bin}", + name=f"readelf for '{bin}'", + verbose=True, + ) + ) -def ldd(results: cli.Results, bin: str): - results.add(cli.run(f"ldd target/release/{bin}", - name=f"ldd for '{bin}'", - verbose=True)) -def readelf(results: cli.Results, bin: str): - results.add(cli.run(f"readelf -p .comment target/release/{bin}", - name=f"readelf for '{bin}'", - verbose=True)) +def strip(results: exec_manager.Results, bin: str): + results.add( + exec_manager.cli_run( + f"strip -v target/release/{bin}", name=f"strip for '{bin}'", verbose=True + ) + ) -def strip(results: cli.Results, bin: str): - results.add(cli.run(f"strip -v target/release/{bin}", - name=f"strip for '{bin}'", - verbose=True)) def main(): # Force color output in CI rich.reconfigure(color_system="256") - parser = argparse.ArgumentParser( - description="Rust build processing." - ) - parser.add_argument("--build_flags", default="", help="Additional command-line flags that can be passed to the `cargo build` command.") - parser.add_argument("--doctest_flags", default="", help="Additional command-line flags that can be passed to the `cargo testdocs` command.") - parser.add_argument("--test_flags", default="", help="Additional command-line flags that can be passed to the `cargo testunit` command.") - parser.add_argument("--bench_flags", default="", help="Additional command-line flags that can be passed to the `cargo bench` command.") - parser.add_argument("--with_test", action='store_true', help="Flag to indicate whether to run tests (including unit tests and doc tests).") - parser.add_argument("--cov_report", default="", help="The output coverage report file path. If omitted, coverage will not be run.") - parser.add_argument("--with_bench", action='store_true', help="Flag to indicate whether to run benchmarks.") - parser.add_argument("--libs", default="", help="The list of lib crates `cargo-modules` docs to build separated by comma.") - parser.add_argument("--bins", default="", help="The list of binaries `cargo-modules` docs to build and made a smoke tests on them.") + parser = argparse.ArgumentParser(description="Rust build processing.") + parser.add_argument( + "--build_flags", + default="", + help="Additional command-line flags that can be passed to the `cargo build` command.", + ) + parser.add_argument( + "--lint_flags", + default="", + help="Additional command-line flags that can be passed to the `cargo lint` command.", + ) + parser.add_argument( + "--doctest_flags", + default="", + help="Additional command-line flags that can be passed to the `cargo testdocs` command.", + ) + parser.add_argument( + "--test_flags", + default="", + help="Additional command-line flags that can be passed to the `cargo testunit` command.", + ) + parser.add_argument( + "--bench_flags", + default="", + help="Additional command-line flags that can be passed to the `cargo bench` command.", + ) + parser.add_argument( + "--cov_report", + default="", + help="The output coverage report file path. If omitted, coverage will not be run.", + ) + parser.add_argument( + "--disable_tests", + action="store_true", + help="Flag to disable to run tests (including unit tests and doc tests).", + ) + parser.add_argument( + "--disable_benches", + action="store_true", + help="Flag to disable to run benchmarks.", + ) + parser.add_argument( + "--disable_docs", + action="store_true", + help="Flag to disable docs building (including graphs, trees etc.) or not.", + ) + parser.add_argument( + "--libs", + default="", + help="The list of lib crates `cargo-modules` docs to build separated by comma.", + ) + parser.add_argument( + "--bins", + default="", + help="The list of binaries `cargo-modules` docs to build and make a smoke tests on them.", + ) args = parser.parse_args() libs = filter(lambda lib: lib != "", args.libs.split(", ")) bins = list(filter(lambda bin: bin != "", args.bins.split(", "))) - results = cli.Results("Rust build") + results = exec_manager.Results("Rust build") # Build the code. cargo_build(results, args.build_flags) # Check the code passes all clippy lint checks. - cargo_clippy(results) + cargo_lint(results, args.lint_flags) # Check if all Self contained tests pass (Test that need no external resources). - if args.with_test: + if not args.disable_tests: # Check if all documentation tests pass. cargo_doctest(results, args.doctest_flags) if args.cov_report == "": @@ -159,30 +275,31 @@ def main(): cargo_llvm_cov(results, args.test_flags, args.cov_report) # Check if any benchmarks defined run (We don't validate the results.) - if args.with_bench: + if not args.disable_benches: cargo_bench(results, args.bench_flags) # Generate all the documentation. - cargo_doc(results) - # Generate dependency graphs - cargo_depgraph(results) - - for lib in libs: - cargo_modules_lib(results, lib) + if not args.disable_docs: + # Generate rust docs. + cargo_doc(results) + # Generate dependency graphs + cargo_depgraph(results) - for bin in bins: - package, bin_name = bin.split('/') - cargo_modules_bin(results, package, bin_name) + for lib in libs: + cargo_modules_lib(results, lib) + for bin in bins: + package, bin_name = bin.split("/") + cargo_modules_bin(results, package, bin_name) results.print() if not results.ok(): exit(1) # Check if the build executable, isn't a busted mess. - results = cli.Results("Smoke test") + results = exec_manager.Results("Smoke test") for bin in bins: - _, bin_name = bin.split('/') + _, bin_name = bin.split("/") help_check(results, bin_name) ldd(results, bin_name) readelf(results, bin_name) @@ -194,4 +311,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/earthly/rust/scripts/std_checks.py b/earthly/rust/scripts/std_checks.py index 700acabaf..468c089ed 100755 --- a/earthly/rust/scripts/std_checks.py +++ b/earthly/rust/scripts/std_checks.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 -# cspell: words depgraph fmtchk fmtfix colordiff stdcfgs rustfmt stdcfgs nextest +# cspell: words stdcfgs -import python.cli as cli +import python.exec_manager as exec_manager import python.vendor_files_check as vendor_files_check import argparse import rich @@ -20,6 +20,7 @@ # This improves visibility into all issues that need to be corrected for `check` # to pass without needing to iterate excessively. + def main(): # Force color output in CI rich.reconfigure(color_system="256") @@ -28,27 +29,72 @@ def main(): description="Rust high level non-compilation checks processing." ) - results = cli.Results("Rust checks") + results = exec_manager.Results("Rust checks") + + # Check config files. + # Looking for 'Cargo.toml' files + for root, _, files in os.walk("./"): + for file_name in files: + if file_name == "Cargo.toml": + cargo_toml_path = f"{root}/{file_name}" + # it should fits one of the template + res1 = vendor_files_check.toml_diff_check( + "/stdcfgs/cargo_manifest/workspace.toml", + cargo_toml_path, + strict=False, + log=False, + ) + res2 = vendor_files_check.toml_diff_check( + "/stdcfgs/cargo_manifest/workspace_inherit.toml", + cargo_toml_path, + strict=False, + log=False, + ) + if not res1.ok() and not res2.ok(): + res1.print(verbose_errors=True) + res2.print(verbose_errors=True) + results.add(res1) + results.add(res2) + + results.add( + vendor_files_check.toml_diff_check( + f"{os.environ.get('CARGO_HOME')}/config.toml", ".cargo/config.toml" + ) + ) + results.add( + vendor_files_check.toml_diff_check( + "/stdcfgs/rust-toolchain.toml", + "rust-toolchain.toml", + strict=False, + ) + ) + results.add( + vendor_files_check.toml_diff_check("/stdcfgs/rustfmt.toml", "rustfmt.toml") + ) + results.add( + vendor_files_check.toml_diff_check( + "/stdcfgs/nextest.toml", ".config/nextest.toml" + ) + ) + results.add( + vendor_files_check.toml_diff_check("/stdcfgs/clippy.toml", "clippy.toml") + ) + results.add(vendor_files_check.toml_diff_check("/stdcfgs/deny.toml", "deny.toml")) # Check if the rust src is properly formatted. - res = cli.run("cargo +nightly fmtchk ", - name="Rust Code Format Check") + res = exec_manager.cli_run("cargo +nightly fmtchk ", name="Rust Code Format Check") results.add(res) if not res.ok(): - print("[yellow]You can locally fix format errors by running: [/yellow] \n [red bold]cargo +nightly fmtfix [/red bold]") - - # Check config files. - results.add(vendor_files_check.colordiff_check(f"{os.environ.get('CARGO_HOME')}/config.toml", ".cargo/config.toml")) - results.add(vendor_files_check.colordiff_check("/stdcfgs/rustfmt.toml", "rustfmt.toml")) - results.add(vendor_files_check.colordiff_check("/stdcfgs/nextest.toml", ".config/nextest.toml")) - results.add(vendor_files_check.colordiff_check("/stdcfgs/clippy.toml", "clippy.toml")) - results.add(vendor_files_check.colordiff_check("/stdcfgs/deny.toml", "deny.toml")) + print( + "[yellow]You can locally fix format errors by running: [/yellow] \n [red bold]cargo +nightly fmtfix [/red bold]" + ) # Check if we have unused dependencies declared in our Cargo.toml files. - results.add(cli.run("cargo machete", name="Unused Dependencies Check")) + results.add(exec_manager.cli_run("cargo machete", name="Unused Dependencies Check")) # Check if we have any supply chain issues with dependencies. - results.add(cli.run("cargo deny check", name="Supply Chain Issues Check")) - + results.add( + exec_manager.cli_run("cargo deny check", name="Supply Chain Issues Check") + ) results.print() if not results.ok(): diff --git a/earthly/rust/stdcfgs/README.md b/earthly/rust/stdcfgs/README.md index f80360071..9e9a9cf59 100644 --- a/earthly/rust/stdcfgs/README.md +++ b/earthly/rust/stdcfgs/README.md @@ -1,6 +1,6 @@ # Rust Standardized Configuration - + We define RUST Global Cargo Configurations here. It is applied globally to all Rust Code built by Project Catalyst. diff --git a/earthly/rust/stdcfgs/cargo_config.toml b/earthly/rust/stdcfgs/cargo_config.toml index 8f2abc5db..02c231407 100644 --- a/earthly/rust/stdcfgs/cargo_config.toml +++ b/earthly/rust/stdcfgs/cargo_config.toml @@ -1,11 +1,8 @@ # Use MOLD linker where possible, but ONLY in CI applicable targets. -# cspell: words rustflags armv gnueabihf msvc nextest idents rustdocflags -# cspell: words rustdoc lintfix lintrestrict testfast testdocs codegen testci testunit -# cspell: words fmtchk fmtfix testcov # Configure how Docker container targets build. -# If you want to customize these targets for a local build, then customize them in you: +# If you want to customize these targets for a local build, then customize them in your: # $CARGO_HOME/config.toml # NOT in the project itself. # These targets are ONLY the targets used by CI and inside docker builds. @@ -28,48 +25,12 @@ rustflags = [ "-C", "target-feature=-crt-static" ] -[target.wasm32-unknown-unknown] -rustflags = ["--cap-lints", "warn"] - [build] - -rustflags = [ - "-D", - "warnings", - "-D", - "missing_docs", - "-D", - "let_underscore_drop", - "-D", - "non_ascii_idents", - "-D", - "single_use_lifetimes", - "-D", - "trivial_casts", - "-D", - "trivial_numeric_casts", -] - +rustflags = [] rustdocflags = [ "--enable-index-page", "-Z", "unstable-options", - "-D", - "warnings", - "-D", - "missing_docs", - "-D", - "rustdoc::broken_intra_doc_links", - "-D", - "rustdoc::invalid_codeblock_attributes", - "-D", - "rustdoc::invalid_html_tags", - "-D", - "rustdoc::invalid_rust_codeblocks", - "-D", - "rustdoc::bare_urls", - "-D", - "rustdoc::unescaped_backticks", ] [profile.dev] @@ -78,7 +39,7 @@ debug = true debug-assertions = true overflow-checks = true lto = false -panic = 'unwind' +panic = "unwind" incremental = true codegen-units = 256 @@ -88,7 +49,7 @@ debug = false debug-assertions = false overflow-checks = false lto = "thin" -panic = 'unwind' +panic = "unwind" incremental = false codegen-units = 16 @@ -110,14 +71,14 @@ incremental = false codegen-units = 16 [alias] -lint = "clippy --all-targets -- -D warnings -D clippy::pedantic -D clippy::unwrap_used -D clippy::expect_used -D clippy::exit -D clippy::get_unwrap -D clippy::index_refutable_slice -D clippy::indexing_slicing -D clippy::match_on_vec_items -D clippy::match_wild_err_arm -D clippy::missing_panics_doc -D clippy::panic -D clippy::string_slice -D clippy::unchecked_duration_subtraction -D clippy::unreachable -D clippy::missing_docs_in_private_items" -lintfix = "clippy --all-targets --fix --allow-dirty -- -D warnings -D clippy::pedantic -D clippy::unwrap_used -D clippy::expect_used -D clippy::exit -D clippy::get_unwrap -D clippy::index_refutable_slice -D clippy::indexing_slicing -D clippy::match_on_vec_items -D clippy::match_wild_err_arm -D clippy::missing_panics_doc -D clippy::panic -D clippy::string_slice -D clippy::unchecked_duration_subtraction -D clippy::unreachable -D clippy::missing_docs_in_private_items" -lint-vscode = "clippy --message-format=json-diagnostic-rendered-ansi --all-targets -- -D warnings -D clippy::pedantic -D clippy::unwrap_used -D clippy::expect_used -D clippy::exit -D clippy::get_unwrap -D clippy::index_refutable_slice -D clippy::indexing_slicing -D clippy::match_on_vec_items -D clippy::match_wild_err_arm -D clippy::missing_panics_doc -D clippy::panic -D clippy::string_slice -D clippy::unchecked_duration_subtraction -D clippy::unreachable -D clippy::missing_docs_in_private_items" +lint = "clippy --all-targets" +lintfix = "clippy --all-targets --fix --allow-dirty" +lint-vscode = "clippy --message-format=json-diagnostic-rendered-ansi --all-targets" docs = "doc --release --no-deps --document-private-items --bins --lib --examples" # nightly docs build broken... when they are'nt we can enable these docs... --unit-graph --timings=html,json -Z unstable-options" -testunit = "nextest run --release --bins --lib -P ci" -testcov = "llvm-cov nextest --release --bins --lib -P ci" +testunit = "nextest run --release --bins --lib --tests --benches --no-fail-fast -P ci" +testcov = "llvm-cov nextest --release --bins --lib --tests --benches --no-fail-fast -P ci" testdocs = "test --doc --release" # Rust formatting, MUST be run with +nightly @@ -127,6 +88,6 @@ fmtfix = "fmt -- -v" [term] quiet = false # whether cargo output is quiet verbose = false # whether cargo provides verbose output -color = 'auto' # whether cargo colorizes output use `CARGO_TERM_COLOR="off"` to disable. -progress.when = 'never' # whether cargo shows progress bar +color = "auto" # whether cargo colorizes output use `CARGO_TERM_COLOR="off"` to disable. +progress.when = "never" # whether cargo shows progress bar progress.width = 80 # width of progress bar diff --git a/earthly/rust/stdcfgs/cargo_manifest/workspace.toml b/earthly/rust/stdcfgs/cargo_manifest/workspace.toml new file mode 100644 index 000000000..22ad79cca --- /dev/null +++ b/earthly/rust/stdcfgs/cargo_manifest/workspace.toml @@ -0,0 +1,36 @@ +[workspace.package] +edition = "2021" + +[workspace.lints.rust] +warnings = "deny" +missing_docs = "deny" +let_underscore_drop = "deny" +non_ascii_idents = "deny" +single_use_lifetimes = "deny" +trivial_casts = "deny" +trivial_numeric_casts = "deny" + +[workspace.lints.rustdoc] +broken_intra_doc_links = "deny" +invalid_codeblock_attributes = "deny" +invalid_html_tags = "deny" +invalid_rust_codeblocks = "deny" +bare_urls = "deny" +unescaped_backticks = "deny" + +[workspace.lints.clippy] +pedantic = "deny" +unwrap_used = "deny" +expect_used = "deny" +exit = "deny" +get_unwrap = "deny" +index_refutable_slice = "deny" +indexing_slicing = "deny" +match_on_vec_items = "deny" +match_wild_err_arm = "deny" +missing_panics_doc = "deny" +panic = "deny" +string_slice = "deny" +unchecked_duration_subtraction = "deny" +unreachable = "deny" +missing_docs_in_private_items = "deny" \ No newline at end of file diff --git a/earthly/rust/stdcfgs/cargo_manifest/workspace_inherit.toml b/earthly/rust/stdcfgs/cargo_manifest/workspace_inherit.toml new file mode 100644 index 000000000..ec85d6363 --- /dev/null +++ b/earthly/rust/stdcfgs/cargo_manifest/workspace_inherit.toml @@ -0,0 +1,5 @@ +[package] +edition.workspace = true + +[lints] +workspace = true \ No newline at end of file diff --git a/earthly/rust/stdcfgs/nextest.toml b/earthly/rust/stdcfgs/nextest.toml index 86c177122..be3673830 100644 --- a/earthly/rust/stdcfgs/nextest.toml +++ b/earthly/rust/stdcfgs/nextest.toml @@ -1,4 +1,4 @@ -# cspell: words nextest scrollability testcase +# cspell: words scrollability testcase [store] # The directory under the workspace root at which nextest-related files are # written. Profile-specific storage is currently written to dir/. diff --git a/earthly/rust/stdcfgs/rust-toolchain.toml b/earthly/rust/stdcfgs/rust-toolchain.toml new file mode 100644 index 000000000..f53c358dc --- /dev/null +++ b/earthly/rust/stdcfgs/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.75.0" +profile = "default" \ No newline at end of file diff --git a/examples/rust/.cargo/config.toml b/examples/rust/.cargo/config.toml index 8f2abc5db..02c231407 100644 --- a/examples/rust/.cargo/config.toml +++ b/examples/rust/.cargo/config.toml @@ -1,11 +1,8 @@ # Use MOLD linker where possible, but ONLY in CI applicable targets. -# cspell: words rustflags armv gnueabihf msvc nextest idents rustdocflags -# cspell: words rustdoc lintfix lintrestrict testfast testdocs codegen testci testunit -# cspell: words fmtchk fmtfix testcov # Configure how Docker container targets build. -# If you want to customize these targets for a local build, then customize them in you: +# If you want to customize these targets for a local build, then customize them in your: # $CARGO_HOME/config.toml # NOT in the project itself. # These targets are ONLY the targets used by CI and inside docker builds. @@ -28,48 +25,12 @@ rustflags = [ "-C", "target-feature=-crt-static" ] -[target.wasm32-unknown-unknown] -rustflags = ["--cap-lints", "warn"] - [build] - -rustflags = [ - "-D", - "warnings", - "-D", - "missing_docs", - "-D", - "let_underscore_drop", - "-D", - "non_ascii_idents", - "-D", - "single_use_lifetimes", - "-D", - "trivial_casts", - "-D", - "trivial_numeric_casts", -] - +rustflags = [] rustdocflags = [ "--enable-index-page", "-Z", "unstable-options", - "-D", - "warnings", - "-D", - "missing_docs", - "-D", - "rustdoc::broken_intra_doc_links", - "-D", - "rustdoc::invalid_codeblock_attributes", - "-D", - "rustdoc::invalid_html_tags", - "-D", - "rustdoc::invalid_rust_codeblocks", - "-D", - "rustdoc::bare_urls", - "-D", - "rustdoc::unescaped_backticks", ] [profile.dev] @@ -78,7 +39,7 @@ debug = true debug-assertions = true overflow-checks = true lto = false -panic = 'unwind' +panic = "unwind" incremental = true codegen-units = 256 @@ -88,7 +49,7 @@ debug = false debug-assertions = false overflow-checks = false lto = "thin" -panic = 'unwind' +panic = "unwind" incremental = false codegen-units = 16 @@ -110,14 +71,14 @@ incremental = false codegen-units = 16 [alias] -lint = "clippy --all-targets -- -D warnings -D clippy::pedantic -D clippy::unwrap_used -D clippy::expect_used -D clippy::exit -D clippy::get_unwrap -D clippy::index_refutable_slice -D clippy::indexing_slicing -D clippy::match_on_vec_items -D clippy::match_wild_err_arm -D clippy::missing_panics_doc -D clippy::panic -D clippy::string_slice -D clippy::unchecked_duration_subtraction -D clippy::unreachable -D clippy::missing_docs_in_private_items" -lintfix = "clippy --all-targets --fix --allow-dirty -- -D warnings -D clippy::pedantic -D clippy::unwrap_used -D clippy::expect_used -D clippy::exit -D clippy::get_unwrap -D clippy::index_refutable_slice -D clippy::indexing_slicing -D clippy::match_on_vec_items -D clippy::match_wild_err_arm -D clippy::missing_panics_doc -D clippy::panic -D clippy::string_slice -D clippy::unchecked_duration_subtraction -D clippy::unreachable -D clippy::missing_docs_in_private_items" -lint-vscode = "clippy --message-format=json-diagnostic-rendered-ansi --all-targets -- -D warnings -D clippy::pedantic -D clippy::unwrap_used -D clippy::expect_used -D clippy::exit -D clippy::get_unwrap -D clippy::index_refutable_slice -D clippy::indexing_slicing -D clippy::match_on_vec_items -D clippy::match_wild_err_arm -D clippy::missing_panics_doc -D clippy::panic -D clippy::string_slice -D clippy::unchecked_duration_subtraction -D clippy::unreachable -D clippy::missing_docs_in_private_items" +lint = "clippy --all-targets" +lintfix = "clippy --all-targets --fix --allow-dirty" +lint-vscode = "clippy --message-format=json-diagnostic-rendered-ansi --all-targets" docs = "doc --release --no-deps --document-private-items --bins --lib --examples" # nightly docs build broken... when they are'nt we can enable these docs... --unit-graph --timings=html,json -Z unstable-options" -testunit = "nextest run --release --bins --lib -P ci" -testcov = "llvm-cov nextest --release --bins --lib -P ci" +testunit = "nextest run --release --bins --lib --tests --benches --no-fail-fast -P ci" +testcov = "llvm-cov nextest --release --bins --lib --tests --benches --no-fail-fast -P ci" testdocs = "test --doc --release" # Rust formatting, MUST be run with +nightly @@ -127,6 +88,6 @@ fmtfix = "fmt -- -v" [term] quiet = false # whether cargo output is quiet verbose = false # whether cargo provides verbose output -color = 'auto' # whether cargo colorizes output use `CARGO_TERM_COLOR="off"` to disable. -progress.when = 'never' # whether cargo shows progress bar +color = "auto" # whether cargo colorizes output use `CARGO_TERM_COLOR="off"` to disable. +progress.when = "never" # whether cargo shows progress bar progress.width = 80 # width of progress bar diff --git a/examples/rust/.config/nextest.toml b/examples/rust/.config/nextest.toml index 86c177122..be3673830 100644 --- a/examples/rust/.config/nextest.toml +++ b/examples/rust/.config/nextest.toml @@ -1,4 +1,4 @@ -# cspell: words nextest scrollability testcase +# cspell: words scrollability testcase [store] # The directory under the workspace root at which nextest-related files are # written. Profile-specific storage is currently written to dir/. diff --git a/examples/rust/Cargo.lock b/examples/rust/Cargo.lock deleted file mode 100644 index 363a4913f..000000000 --- a/examples/rust/Cargo.lock +++ /dev/null @@ -1,743 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - -[[package]] -name = "anes" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" - -[[package]] -name = "anstream" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" - -[[package]] -name = "anstyle-parse" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" -dependencies = [ - "anstyle", - "windows-sys", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bar" -version = "0.0.1" - -[[package]] -name = "bitflags" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" - -[[package]] -name = "bumpalo" -version = "3.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" - -[[package]] -name = "cast" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "ciborium" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" -dependencies = [ - "ciborium-io", - "ciborium-ll", - "serde", -] - -[[package]] -name = "ciborium-io" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" - -[[package]] -name = "ciborium-ll" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" -dependencies = [ - "ciborium-io", - "half", -] - -[[package]] -name = "clap" -version = "4.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" -dependencies = [ - "clap_builder", - "clap_derive", -] - -[[package]] -name = "clap_builder" -version = "4.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" -dependencies = [ - "anstream", - "anstyle", - "clap_lex", - "strsim", -] - -[[package]] -name = "clap_derive" -version = "4.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "clap_lex" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" - -[[package]] -name = "colorchoice" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" - -[[package]] -name = "criterion" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" -dependencies = [ - "anes", - "cast", - "ciborium", - "clap", - "criterion-plot", - "is-terminal", - "itertools", - "num-traits", - "once_cell", - "oorandom", - "plotters", - "rayon", - "regex", - "serde", - "serde_derive", - "serde_json", - "tinytemplate", - "walkdir", -] - -[[package]] -name = "criterion-plot" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" -dependencies = [ - "cast", - "itertools", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" -dependencies = [ - "cfg-if", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" -dependencies = [ - "autocfg", - "cfg-if", - "crossbeam-utils", - "memoffset", - "scopeguard", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "either" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" - -[[package]] -name = "errno" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" -dependencies = [ - "libc", - "windows-sys", -] - -[[package]] -name = "foo" -version = "0.0.1" -dependencies = [ - "clap", - "criterion", -] - -[[package]] -name = "half" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" - -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - -[[package]] -name = "hermit-abi" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" - -[[package]] -name = "is-terminal" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi", - "rustix", - "windows-sys", -] - -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" - -[[package]] -name = "js-sys" -version = "0.3.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "libc" -version = "0.2.149" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" - -[[package]] -name = "linux-raw-sys" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" - -[[package]] -name = "log" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" - -[[package]] -name = "memchr" -version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" - -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] - -[[package]] -name = "num-traits" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" -dependencies = [ - "autocfg", -] - -[[package]] -name = "once_cell" -version = "1.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" - -[[package]] -name = "oorandom" -version = "11.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" - -[[package]] -name = "plotters" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" -dependencies = [ - "num-traits", - "plotters-backend", - "plotters-svg", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "plotters-backend" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" - -[[package]] -name = "plotters-svg" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" -dependencies = [ - "plotters-backend", -] - -[[package]] -name = "proc-macro2" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rayon" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" -dependencies = [ - "crossbeam-deque", - "crossbeam-utils", -] - -[[package]] -name = "regex" -version = "1.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - -[[package]] -name = "rustix" -version = "0.38.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" -dependencies = [ - "bitflags", - "errno", - "libc", - "linux-raw-sys", - "windows-sys", -] - -[[package]] -name = "ryu" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "serde" -version = "1.0.190" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.190" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.107" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - -[[package]] -name = "syn" -version = "2.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "tinytemplate" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" -dependencies = [ - "serde", - "serde_json", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "utf8parse" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" - -[[package]] -name = "walkdir" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" -dependencies = [ - "same-file", - "winapi-util", -] - -[[package]] -name = "wasm-bindgen" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" - -[[package]] -name = "web-sys" -version = "0.3.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" diff --git a/examples/rust/Cargo.toml b/examples/rust/Cargo.toml index e6cfc794c..4937b4b6f 100644 --- a/examples/rust/Cargo.toml +++ b/examples/rust/Cargo.toml @@ -6,6 +6,40 @@ members = [ ] [workspace.package] -edition = "2021" version = "0.0.1" license = "MIT OR Apache-2.0" +edition = "2021" + +[workspace.lints.rust] +warnings = "deny" +missing_docs = "deny" +let_underscore_drop = "deny" +non_ascii_idents = "deny" +single_use_lifetimes = "deny" +trivial_casts = "deny" +trivial_numeric_casts = "deny" + +[workspace.lints.rustdoc] +broken_intra_doc_links = "deny" +invalid_codeblock_attributes = "deny" +invalid_html_tags = "deny" +invalid_rust_codeblocks = "deny" +bare_urls = "deny" +unescaped_backticks = "deny" + +[workspace.lints.clippy] +pedantic = "deny" +unwrap_used = "deny" +expect_used = "deny" +exit = "deny" +get_unwrap = "deny" +index_refutable_slice = "deny" +indexing_slicing = "deny" +match_on_vec_items = "deny" +match_wild_err_arm = "deny" +missing_panics_doc = "deny" +panic = "deny" +string_slice = "deny" +unchecked_duration_subtraction = "deny" +unreachable = "deny" +missing_docs_in_private_items = "deny" diff --git a/examples/rust/Earthfile b/examples/rust/Earthfile index 5de5f553b..a80ae627a 100644 --- a/examples/rust/Earthfile +++ b/examples/rust/Earthfile @@ -1,17 +1,15 @@ VERSION --try --global-cache 0.7 -# cspell: words USERARCH toolsets rustfmt nextest +# cspell: words USERARCH toolsets # Set up our target toolchains, and copy our files. builder: - FROM ./../../earthly/rust+rust-base + DO ./../../earthly/rust+SETUP COPY --dir .cargo .config crates . - COPY Cargo.lock Cargo.toml . + COPY Cargo.toml . COPY clippy.toml deny.toml rustfmt.toml . - DO ./../../earthly/rust+SETUP - ## ----------------------------------------------------------------------------- ## ## Standard CI targets. @@ -36,10 +34,7 @@ build: FROM +builder TRY - RUN /scripts/std_build.py --build_flags="" \ - --with_test \ - --with_bench \ - --cov_report="coverage-report.info" \ + RUN /scripts/std_build.py --cov_report="coverage-report.info" \ --libs="bar" \ --bins="foo/foo" FINALLY diff --git a/examples/rust/crates/bar/Cargo.toml b/examples/rust/crates/bar/Cargo.toml index 69718b06b..375981528 100644 --- a/examples/rust/crates/bar/Cargo.toml +++ b/examples/rust/crates/bar/Cargo.toml @@ -4,6 +4,9 @@ version.workspace = true edition.workspace = true license.workspace = true +[lints] +workspace = true + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] diff --git a/examples/rust/crates/foo/Cargo.toml b/examples/rust/crates/foo/Cargo.toml index a0596fb28..04ee81d2b 100644 --- a/examples/rust/crates/foo/Cargo.toml +++ b/examples/rust/crates/foo/Cargo.toml @@ -4,6 +4,9 @@ version.workspace = true edition.workspace = true license.workspace = true +[lints] +workspace = true + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -12,10 +15,6 @@ clap = {version= "4.4.7", features = ["derive" ] } [dev-dependencies] criterion = { version = "0.5.1", features = ["html_reports"] } -[[test]] -name = "integration_test" -harness = false - [[bench]] name = "benchmark" harness = false diff --git a/examples/rust/crates/foo/benches/benchmark.rs b/examples/rust/crates/foo/benches/benchmark.rs index 71cf6d43a..3afee4104 100644 --- a/examples/rust/crates/foo/benches/benchmark.rs +++ b/examples/rust/crates/foo/benches/benchmark.rs @@ -1,6 +1,11 @@ //! Simple benchmark example use criterion::{black_box, criterion_group, criterion_main, Criterion}; +#[test] +fn test_fibonacci() { + assert_eq!(fibonacci(20), 6765); +} + /// fn fibonacci(n: u64) -> u64 { match n { diff --git a/examples/rust/crates/foo/tests/integration_test.rs b/examples/rust/crates/foo/tests/integration_test.rs index 9a5311499..287c3dddd 100644 --- a/examples/rust/crates/foo/tests/integration_test.rs +++ b/examples/rust/crates/foo/tests/integration_test.rs @@ -3,9 +3,6 @@ #[test] /// Prove we can say hello to Dave on a 99 count. fn test_hello_dave_99() { - let msg = fmt_hello("Dave", 99); + let msg = foo::fmt_hello("Dave", 99); assert_eq!(msg, "Hello # 99 Dave!"); } - -/// Dummy main needed because we are integration testing a binary package. -fn main() {} diff --git a/examples/rust/deny.toml b/examples/rust/deny.toml index 4ac843fb5..926f2ef43 100644 --- a/examples/rust/deny.toml +++ b/examples/rust/deny.toml @@ -279,4 +279,4 @@ allow-git = [ # 1 or more gitlab.com organizations to allow git sources for #gitlab = [""] # 1 or more bitbucket.org organizations to allow git sources for -#bitbucket = [""] +#bitbucket = [""] \ No newline at end of file diff --git a/examples/rust/rust-toolchain.toml b/examples/rust/rust-toolchain.toml index f970caf8a..f53c358dc 100644 --- a/examples/rust/rust-toolchain.toml +++ b/examples/rust/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.73.0" +channel = "1.75.0" profile = "default" \ No newline at end of file diff --git a/utilities/dbviz/.cargo/config.toml b/utilities/dbviz/.cargo/config.toml index 8f2abc5db..02c231407 100644 --- a/utilities/dbviz/.cargo/config.toml +++ b/utilities/dbviz/.cargo/config.toml @@ -1,11 +1,8 @@ # Use MOLD linker where possible, but ONLY in CI applicable targets. -# cspell: words rustflags armv gnueabihf msvc nextest idents rustdocflags -# cspell: words rustdoc lintfix lintrestrict testfast testdocs codegen testci testunit -# cspell: words fmtchk fmtfix testcov # Configure how Docker container targets build. -# If you want to customize these targets for a local build, then customize them in you: +# If you want to customize these targets for a local build, then customize them in your: # $CARGO_HOME/config.toml # NOT in the project itself. # These targets are ONLY the targets used by CI and inside docker builds. @@ -28,48 +25,12 @@ rustflags = [ "-C", "target-feature=-crt-static" ] -[target.wasm32-unknown-unknown] -rustflags = ["--cap-lints", "warn"] - [build] - -rustflags = [ - "-D", - "warnings", - "-D", - "missing_docs", - "-D", - "let_underscore_drop", - "-D", - "non_ascii_idents", - "-D", - "single_use_lifetimes", - "-D", - "trivial_casts", - "-D", - "trivial_numeric_casts", -] - +rustflags = [] rustdocflags = [ "--enable-index-page", "-Z", "unstable-options", - "-D", - "warnings", - "-D", - "missing_docs", - "-D", - "rustdoc::broken_intra_doc_links", - "-D", - "rustdoc::invalid_codeblock_attributes", - "-D", - "rustdoc::invalid_html_tags", - "-D", - "rustdoc::invalid_rust_codeblocks", - "-D", - "rustdoc::bare_urls", - "-D", - "rustdoc::unescaped_backticks", ] [profile.dev] @@ -78,7 +39,7 @@ debug = true debug-assertions = true overflow-checks = true lto = false -panic = 'unwind' +panic = "unwind" incremental = true codegen-units = 256 @@ -88,7 +49,7 @@ debug = false debug-assertions = false overflow-checks = false lto = "thin" -panic = 'unwind' +panic = "unwind" incremental = false codegen-units = 16 @@ -110,14 +71,14 @@ incremental = false codegen-units = 16 [alias] -lint = "clippy --all-targets -- -D warnings -D clippy::pedantic -D clippy::unwrap_used -D clippy::expect_used -D clippy::exit -D clippy::get_unwrap -D clippy::index_refutable_slice -D clippy::indexing_slicing -D clippy::match_on_vec_items -D clippy::match_wild_err_arm -D clippy::missing_panics_doc -D clippy::panic -D clippy::string_slice -D clippy::unchecked_duration_subtraction -D clippy::unreachable -D clippy::missing_docs_in_private_items" -lintfix = "clippy --all-targets --fix --allow-dirty -- -D warnings -D clippy::pedantic -D clippy::unwrap_used -D clippy::expect_used -D clippy::exit -D clippy::get_unwrap -D clippy::index_refutable_slice -D clippy::indexing_slicing -D clippy::match_on_vec_items -D clippy::match_wild_err_arm -D clippy::missing_panics_doc -D clippy::panic -D clippy::string_slice -D clippy::unchecked_duration_subtraction -D clippy::unreachable -D clippy::missing_docs_in_private_items" -lint-vscode = "clippy --message-format=json-diagnostic-rendered-ansi --all-targets -- -D warnings -D clippy::pedantic -D clippy::unwrap_used -D clippy::expect_used -D clippy::exit -D clippy::get_unwrap -D clippy::index_refutable_slice -D clippy::indexing_slicing -D clippy::match_on_vec_items -D clippy::match_wild_err_arm -D clippy::missing_panics_doc -D clippy::panic -D clippy::string_slice -D clippy::unchecked_duration_subtraction -D clippy::unreachable -D clippy::missing_docs_in_private_items" +lint = "clippy --all-targets" +lintfix = "clippy --all-targets --fix --allow-dirty" +lint-vscode = "clippy --message-format=json-diagnostic-rendered-ansi --all-targets" docs = "doc --release --no-deps --document-private-items --bins --lib --examples" # nightly docs build broken... when they are'nt we can enable these docs... --unit-graph --timings=html,json -Z unstable-options" -testunit = "nextest run --release --bins --lib -P ci" -testcov = "llvm-cov nextest --release --bins --lib -P ci" +testunit = "nextest run --release --bins --lib --tests --benches --no-fail-fast -P ci" +testcov = "llvm-cov nextest --release --bins --lib --tests --benches --no-fail-fast -P ci" testdocs = "test --doc --release" # Rust formatting, MUST be run with +nightly @@ -127,6 +88,6 @@ fmtfix = "fmt -- -v" [term] quiet = false # whether cargo output is quiet verbose = false # whether cargo provides verbose output -color = 'auto' # whether cargo colorizes output use `CARGO_TERM_COLOR="off"` to disable. -progress.when = 'never' # whether cargo shows progress bar +color = "auto" # whether cargo colorizes output use `CARGO_TERM_COLOR="off"` to disable. +progress.when = "never" # whether cargo shows progress bar progress.width = 80 # width of progress bar diff --git a/utilities/dbviz/.config/nextest.toml b/utilities/dbviz/.config/nextest.toml index 86c177122..be3673830 100644 --- a/utilities/dbviz/.config/nextest.toml +++ b/utilities/dbviz/.config/nextest.toml @@ -1,4 +1,4 @@ -# cspell: words nextest scrollability testcase +# cspell: words scrollability testcase [store] # The directory under the workspace root at which nextest-related files are # written. Profile-specific storage is currently written to dir/. diff --git a/utilities/dbviz/Cargo.lock b/utilities/dbviz/Cargo.lock deleted file mode 100644 index f2d5ca834..000000000 --- a/utilities/dbviz/Cargo.lock +++ /dev/null @@ -1,1103 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "addr2line" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "anstream" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" - -[[package]] -name = "anstyle-parse" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" -dependencies = [ - "windows-sys 0.52.0", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" -dependencies = [ - "anstyle", - "windows-sys 0.52.0", -] - -[[package]] -name = "anyhow" -version = "1.0.75" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" - -[[package]] -name = "async-trait" -version = "0.1.74" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "backtrace" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - -[[package]] -name = "base64" -version = "0.21.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - -[[package]] -name = "bumpalo" -version = "3.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "bytes" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" - -[[package]] -name = "cc" -version = "1.0.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "clap" -version = "4.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" -dependencies = [ - "clap_builder", - "clap_derive", -] - -[[package]] -name = "clap_builder" -version = "4.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" -dependencies = [ - "anstream", - "anstyle", - "clap_lex", - "strsim", -] - -[[package]] -name = "clap_derive" -version = "4.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "clap_lex" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" - -[[package]] -name = "colorchoice" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" - -[[package]] -name = "cpufeatures" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" -dependencies = [ - "libc", -] - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "dbviz" -version = "1.4.0" -dependencies = [ - "anyhow", - "clap", - "itertools", - "minijinja", - "postgres", - "serde", - "textwrap", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "crypto-common", - "subtle", -] - -[[package]] -name = "either" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" - -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - -[[package]] -name = "finl_unicode" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" - -[[package]] -name = "futures-channel" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" - -[[package]] -name = "futures-macro" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "futures-sink" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" - -[[package]] -name = "futures-task" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" - -[[package]] -name = "futures-util" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" -dependencies = [ - "futures-core", - "futures-macro", - "futures-sink", - "futures-task", - "pin-project-lite", - "pin-utils", - "slab", -] - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "gimli" -version = "0.28.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" - -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "itertools" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0" -dependencies = [ - "either", -] - -[[package]] -name = "js-sys" -version = "0.3.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "libc" -version = "0.2.151" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" - -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" - -[[package]] -name = "md-5" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" -dependencies = [ - "cfg-if", - "digest", -] - -[[package]] -name = "memchr" -version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" - -[[package]] -name = "minijinja" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "208758577ef2c86cf5dd3e85730d161413ec3284e2d73b2ef65d9a24d9971bcb" -dependencies = [ - "serde", -] - -[[package]] -name = "miniz_oxide" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" -dependencies = [ - "adler", -] - -[[package]] -name = "mio" -version = "0.8.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" -dependencies = [ - "libc", - "wasi", - "windows-sys 0.48.0", -] - -[[package]] -name = "object" -version = "0.32.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" -dependencies = [ - "memchr", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets 0.48.5", -] - -[[package]] -name = "percent-encoding" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" - -[[package]] -name = "phf" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" -dependencies = [ - "phf_shared", -] - -[[package]] -name = "phf_shared" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" -dependencies = [ - "siphasher", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "postgres" -version = "0.19.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7915b33ed60abc46040cbcaa25ffa1c7ec240668e0477c4f3070786f5916d451" -dependencies = [ - "bytes", - "fallible-iterator", - "futures-util", - "log", - "tokio", - "tokio-postgres", -] - -[[package]] -name = "postgres-protocol" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b6c5ef183cd3ab4ba005f1ca64c21e8bd97ce4699cfea9e8d9a2c4958ca520" -dependencies = [ - "base64", - "byteorder", - "bytes", - "fallible-iterator", - "hmac", - "md-5", - "memchr", - "rand", - "sha2", - "stringprep", -] - -[[package]] -name = "postgres-types" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d2234cdee9408b523530a9b6d2d6b373d1db34f6a8e51dc03ded1828d7fb67c" -dependencies = [ - "bytes", - "fallible-iterator", - "postgres-protocol", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - -[[package]] -name = "proc-macro2" -version = "1.0.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "serde" -version = "1.0.193" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.193" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "sha2" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] -name = "siphasher" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" - -[[package]] -name = "slab" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] - -[[package]] -name = "smallvec" -version = "1.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" - -[[package]] -name = "smawk" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" - -[[package]] -name = "socket2" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" -dependencies = [ - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "stringprep" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb41d74e231a107a1b4ee36bd1214b11285b77768d2e3824aedafa988fd36ee6" -dependencies = [ - "finl_unicode", - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "2.0.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "textwrap" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" -dependencies = [ - "smawk", - "unicode-linebreak", - "unicode-width", -] - -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - -[[package]] -name = "tokio" -version = "1.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d45b238a16291a4e1584e61820b8ae57d696cc5015c459c229ccc6990cc1c" -dependencies = [ - "backtrace", - "bytes", - "libc", - "mio", - "pin-project-lite", - "socket2", - "windows-sys 0.48.0", -] - -[[package]] -name = "tokio-postgres" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d340244b32d920260ae7448cb72b6e238bddc3d4f7603394e7dd46ed8e48f5b8" -dependencies = [ - "async-trait", - "byteorder", - "bytes", - "fallible-iterator", - "futures-channel", - "futures-util", - "log", - "parking_lot", - "percent-encoding", - "phf", - "pin-project-lite", - "postgres-protocol", - "postgres-types", - "rand", - "socket2", - "tokio", - "tokio-util", - "whoami", -] - -[[package]] -name = "tokio-util" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite", - "tokio", - "tracing", -] - -[[package]] -name = "tracing" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" -dependencies = [ - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", -] - -[[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - -[[package]] -name = "unicode-bidi" -version = "0.3.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unicode-linebreak" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" - -[[package]] -name = "unicode-normalization" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-width" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" - -[[package]] -name = "utf8parse" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasm-bindgen" -version = "0.2.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" - -[[package]] -name = "web-sys" -version = "0.3.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "whoami" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50" -dependencies = [ - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets 0.52.0", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - -[[package]] -name = "windows-targets" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" -dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" diff --git a/utilities/dbviz/Cargo.toml b/utilities/dbviz/Cargo.toml index 548fa0779..3136e562c 100644 --- a/utilities/dbviz/Cargo.toml +++ b/utilities/dbviz/Cargo.toml @@ -1,10 +1,50 @@ +[workspace.package] +edition = "2021" + +[workspace.lints.rust] +warnings = "deny" +missing_docs = "deny" +let_underscore_drop = "deny" +non_ascii_idents = "deny" +single_use_lifetimes = "deny" +trivial_casts = "deny" +trivial_numeric_casts = "deny" + +[workspace.lints.rustdoc] +broken_intra_doc_links = "deny" +invalid_codeblock_attributes = "deny" +invalid_html_tags = "deny" +invalid_rust_codeblocks = "deny" +bare_urls = "deny" +unescaped_backticks = "deny" + +[workspace.lints.clippy] +pedantic = "deny" +unwrap_used = "deny" +expect_used = "deny" +exit = "deny" +get_unwrap = "deny" +index_refutable_slice = "deny" +indexing_slicing = "deny" +match_on_vec_items = "deny" +match_wild_err_arm = "deny" +missing_panics_doc = "deny" +panic = "deny" +string_slice = "deny" +unchecked_duration_subtraction = "deny" +unreachable = "deny" +missing_docs_in_private_items = "deny" + [package] name = "dbviz" version = "1.4.0" authors = ["Steven Johnson"] -edition = "2018" +edition.workspace = true license = "Apache-2.0/MIT" +[lints] +workspace = true + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] diff --git a/utilities/dbviz/Earthfile b/utilities/dbviz/Earthfile index 0e78c1e6a..f2afb19e3 100644 --- a/utilities/dbviz/Earthfile +++ b/utilities/dbviz/Earthfile @@ -1,21 +1,16 @@ # Common Rust UDCs and Builders. VERSION --global-cache 0.7 -# cspell: words rustup rustc automake autotools xutils miri nextest kani -# cspell: words TARGETPLATFORM TARGETOS TARGETVARIANT -# cspell: words USERPLATFORM USEROS USERARCH USERVARIANT -# cspell: words ripgrep colordiff rustfmt stdcfgs toolset toolsets +# cspell: words stdcfgs toolset toolsets # Internal: Set up our target toolchains, and copy our files. builder: - FROM ../../earthly/rust+rust-base + DO ./../../earthly/rust+SETUP COPY --dir .cargo .config src . - COPY Cargo.lock Cargo.toml . + COPY Cargo.toml . COPY clippy.toml deny.toml rustfmt.toml . - DO ./../../earthly/rust+SETUP - ## ----------------------------------------------------------------------------- ## ## Standard CI targets. @@ -39,8 +34,7 @@ all-hosts-check: build: FROM +builder - RUN /scripts/std_build.py --with_test \ - --bins="dbviz/dbviz" + RUN /scripts/std_build.py --bins="dbviz/dbviz" SAVE ARTIFACT target/doc doc SAVE ARTIFACT target/release/dbviz dbviz diff --git a/utilities/dbviz/deny.toml b/utilities/dbviz/deny.toml index 4ac843fb5..926f2ef43 100644 --- a/utilities/dbviz/deny.toml +++ b/utilities/dbviz/deny.toml @@ -279,4 +279,4 @@ allow-git = [ # 1 or more gitlab.com organizations to allow git sources for #gitlab = [""] # 1 or more bitbucket.org organizations to allow git sources for -#bitbucket = [""] +#bitbucket = [""] \ No newline at end of file diff --git a/utilities/dbviz/rust-toolchain.toml b/utilities/dbviz/rust-toolchain.toml index dca770e1b..f53c358dc 100644 --- a/utilities/dbviz/rust-toolchain.toml +++ b/utilities/dbviz/rust-toolchain.toml @@ -1,5 +1,3 @@ [toolchain] -channel = "1.73.0" -profile = "default" -components = [ ] -targets = ["x86_64-unknown-linux-musl", "aarch64-unknown-linux-musl", "aarch64-apple-darwin"] \ No newline at end of file +channel = "1.75.0" +profile = "default" \ No newline at end of file diff --git a/utilities/scripts/python/db_ops.py b/utilities/scripts/python/db_ops.py index d0b054c85..c7034e085 100644 --- a/utilities/scripts/python/db_ops.py +++ b/utilities/scripts/python/db_ops.py @@ -9,7 +9,7 @@ import os import time from typing import Optional -import python.cli as cli +import python.exec_manager as exec_manager import tempfile import threading @@ -85,10 +85,10 @@ def superuser_connection(self) -> str: """ return f"postgres://{self.args.dbsuperuser}:{self.args.dbsuperuserpw}@{self.args.dbhost}:{self.args.dbport}/{self.args.dbnamesuperuser}" - def init_database(self) -> cli.Result: + def init_database(self) -> exec_manager.Result: """ Initializes the database by creating a temporary password file, running the 'initdb' command, - and updating the 'pg_hba.conf' file. The function takes no parameters and returns a 'cli.Result' object. + and updating the 'pg_hba.conf' file. The function takes no parameters and returns a 'exec_manager.Result' object. """ with tempfile.NamedTemporaryFile(delete=False) as pwfile: @@ -96,7 +96,7 @@ def init_database(self) -> cli.Result: pwfile.flush() # Initialize the database - res = cli.run( + res = exec_manager.cli_run( f"initdb -D {self.args.dbpath}" + f" --locale-provider=icu --icu-locale={self.args.dbcollation} --locale={self.args.dbcollation}" + f" -A {self.args.dbauthmethod}" @@ -127,7 +127,7 @@ def __start(self): None """ # print("Starting Database") - cli.run( + exec_manager.cli_run( f'pg_ctl -D "{self.args.dbpath}" start', name="Starting Database", verbose=True, @@ -158,17 +158,17 @@ def start(self) -> None: return - def db_ready(self) -> cli.Result: + def db_ready(self) -> exec_manager.Result: """ Check if the database is ready for use. - :return: A `cli.Result` object containing the result of the `pg_isready` command. + :return: A `exec_manager.Result` object containing the result of the `pg_isready` command. """ - return cli.run( + return exec_manager.cli_run( f"pg_isready -d {self.superuser_connection()}", name="Database Ready" ) - def wait_ready(self, timeout: Optional[int] = None) -> cli.Result: + def wait_ready(self, timeout: Optional[int] = None) -> exec_manager.Result: """ Waits for the database to be ready within the specified timeout period. @@ -176,7 +176,7 @@ def wait_ready(self, timeout: Optional[int] = None) -> cli.Result: timeout (Optional[int]): The maximum number of seconds to wait for the database to be ready. Defaults to None. Returns: - cli.Result: An object representing the result of the database readiness check. + exec_manager.Result: An object representing the result of the database readiness check. """ start_time = time.perf_counter() @@ -190,19 +190,19 @@ def wait_ready(self, timeout: Optional[int] = None) -> cli.Result: return res - def setup(self) -> cli.Result: + def setup(self) -> exec_manager.Result: """ Setup the default User and Database. - + WARNING: Will destroy all data in the DB - + :return: The result of running the setup command. - :rtype: cli.Result + :rtype: exec_manager.Result """ # Setup the default User and Database # WARNING: Will destroy all data in the DB - return cli.run( + return exec_manager.cli_run( f"psql -v ON_ERROR_STOP=on" + f" -d {self.superuser_connection()} " + f" -f {self.args.setupdbsql}" @@ -211,17 +211,17 @@ def setup(self) -> cli.Result: + f' -v dbUser="{self.args.dbuser}"' + f' -v dbUserPw="{self.args.dbuserpw}"', name="Setup Database", - verbose=True + verbose=True, ) - def migrate_schema(self) -> cli.Result: + def migrate_schema(self) -> exec_manager.Result: """ Run schema migrations. - :return: A cli.Result object representing the result of running the migrations. + :return: A exec_manager.Result object representing the result of running the migrations. """ # Run schema migrations - return cli.run( + return exec_manager.cli_run( f"DATABASE_URL={self.user_connection()}" + f" refinery migrate -e DATABASE_URL" + f" -c {self.args.dbrefinerytoml} " diff --git a/utilities/scripts/python/diff.py b/utilities/scripts/python/diff.py new file mode 100644 index 000000000..dd933bcd7 --- /dev/null +++ b/utilities/scripts/python/diff.py @@ -0,0 +1,163 @@ +from dataclasses import dataclass +from typing import Dict + + +@dataclass +class DiffEntry: + """ + A data class representing an entry in a difference collection. + Attributes: + val: any + The value of the entry. + add_or_remove_flag: bool + A flag indicating whether the entry should be removed (False) or added (True). + """ + + val: any + add_or_remove_flag: bool + + +@dataclass +class DiffResult: + """ + Represents the difference between two dictionaries. + """ + + diff: dict + + def has_diff(self) -> bool: + return bool(self.diff) + + def to_ascii_colored_string( + self, + obj_name_to_add: str, + obj_name_to_remove: str, + ) -> str: + """ + Generates an ascii colored string representation of the diff. + + Args: + obj_name_to_add (str): The name of the object to add. + obj_name_to_remove (str): The name of the object to remove. + """ + + def impl( + diff: dict, + obj_name_to_add: str, + obj_name_to_remove: str, + ident: str = "", + path: str = "", + ) -> str: + def add_color(val: str, color: str) -> str: + if color == "red": + return f"\033[91m{val}\033[0m" + if color == "green": + return f"\033[92m{val}\033[0m" + if color == "yellow": + return f"\033[93m{val}\033[0m" + return val + + result = "" + if isinstance(diff, DiffEntry): + color = "green" if diff.add_or_remove_flag else "red" + minus_or_plus = "+" if diff.add_or_remove_flag else "-" + obj_name = ( + obj_name_to_add if diff.add_or_remove_flag else obj_name_to_remove + ) + + result += "\n------\n" + result += add_color(obj_name, "yellow") + result += f"{path}\n" + result += add_color(f"{minus_or_plus}{ident} {diff.val}", color) + + if isinstance(diff, dict): + for key in diff: + result += impl( + diff[key], + obj_name_to_add, + obj_name_to_remove, + ident + " ", + path + "\n" + f"{ident} {key}", + ) + + if isinstance(diff, tuple): + for val in diff: + result += impl( + val, obj_name_to_add, obj_name_to_remove, ident, path + ) + + return result + + return impl(self.diff, obj_name_to_add, obj_name_to_remove) + + +@dataclass +class Diff: + """ + Calculates the difference between two dictionaries. + """ + + a: dict + b: dict + strict: bool + + def get_diff(self) -> DiffResult: + if self.strict: + return self._strict_diff_() + else: + return self._inclusion_diff_() + + def _inclusion_diff_(self, reverse: bool = False) -> DiffResult: + """ + Calculates an inclusion diff between the 'a' and 'b' dicts in a recursive manner. + Checks that 'a' has an inclusion of 'b'. + Args: + reverse (bool): An inclusion diff calculation flag. + If 'True' evaluates that 'a' as an inclusion of 'b'. + If 'False' evaluates that 'b' as an inclusion of 'a'. + """ + + def impl(expected: dict, provided: dict) -> dict: + diff = {} + for key in expected: + if key not in provided: + diff[key] = DiffEntry(expected[key], True) + elif not isinstance(expected[key], dict): + if expected[key] != provided[key]: + diff[key] = ( + DiffEntry(expected[key], True), + DiffEntry(provided[key], False), + ) + else: + res = impl(expected[key], provided[key]) + if res != {}: + diff[key] = res + return diff + + diff = impl(self.a, self.b) if not reverse else impl(self.b, self.a) + return DiffResult(diff) + + def _strict_diff_(self) -> DiffResult: + """ + Calculate the strict diff between the expected and provided inputs. + """ + + def change_flags(diff): + if isinstance(diff, DiffEntry): + diff.add_or_remove_flag = not diff.add_or_remove_flag + if isinstance(diff, list): + for val in diff: + change_flags(val) + if isinstance(diff, dict): + for key in diff: + change_flags(diff[key]) + + # Finds two inclusion diffs and concatenate the results + # Also it is important to update a result from the second inclusion diff result + # Because it's result has a "reverse" add_or_remove_flag meaning + incl_diff_1 = self._inclusion_diff_() + incl_diff_2 = self._inclusion_diff_(True) + change_flags(incl_diff_2.diff) + incl_diff_1.diff.update(incl_diff_2.diff) + + return incl_diff_1 diff --git a/utilities/scripts/python/cli.py b/utilities/scripts/python/exec_manager.py similarity index 86% rename from utilities/scripts/python/cli.py rename to utilities/scripts/python/exec_manager.py index 58d16622b..5d9f94e47 100755 --- a/utilities/scripts/python/cli.py +++ b/utilities/scripts/python/exec_manager.py @@ -13,10 +13,10 @@ def status_for_rc(rc: int) -> str: """ Returns a status emoji based on the given RC (return code) value. - + Parameters: rc (int): The return code to evaluate. - + Returns: str: The corresponding status emoji (":white_check_mark:" for rc == 0, ":x:" otherwise). """ @@ -45,7 +45,8 @@ def format_execution_time(execution_time: float): return f"{execution_time:.4f} {unit}" -def indent(text:str, first: str, rest: str) -> str: + +def indent(text: str, first: str, rest: str) -> str: """ Indent the given text using the specified indentation strings. @@ -57,7 +58,15 @@ def indent(text:str, first: str, rest: str) -> str: Returns: str: The indented text. """ - return first + textwrap.indent(text, rest)[len(first):] + return first + textwrap.indent(text, rest)[len(first) :] + + +@dataclass +class ProcedureResult: + rc: int + cmd: str + out: str + @dataclass class Result: @@ -127,17 +136,38 @@ def print( f"[bold cyan]{self.get_name():<{name_width}}[/bold cyan] : {self.duration()} : {self.status()}" ) if verbose or (self.rc != 0 and verbose_errors): - print(f"[italic bright_red]{indent(self.get_command(), ' $ ', ' . ')}[/italic bright_red]") - print(Text(indent(self.out, ' > ', ' . '))) + print( + f"[italic bright_red]{indent(self.get_command(), ' $ ', ' . ')}[/italic bright_red]" + ) + print(Text(indent(self.out, " > ", " . "))) -def run( +def cli_run( command: str, name: Optional[str] = None, log: bool = True, - input: Optional[str] = None, timeout=None, verbose=False, +) -> Result: + def procedure() -> ProcedureResult: + result = subprocess.run( + command, + shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + timeout=timeout, + ) + return ProcedureResult(result.returncode, command, result.stdout) + + return procedure_run(procedure, name, log, verbose) + + +def procedure_run( + procedure, + name: Optional[str] = None, + log: bool = True, + verbose=False, ) -> Result: """ Execute a command and return the result. @@ -164,19 +194,11 @@ def run( """ start_time = time.perf_counter() - result = subprocess.run( - command, - shell=True, - input=input, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - timeout=timeout, - ) + result = procedure() execution_time = time.perf_counter() - start_time - res = Result(result.returncode, command, result.stdout, execution_time, name) + res = Result(result.rc, result.cmd, result.out, execution_time, name) if log: res.print(verbose_errors=True, verbose=verbose) @@ -188,10 +210,10 @@ class Results: def __init__(self, title: str) -> None: """ Initializes a new instance of the class. - + Args: title (str): The title of the instance. - + Returns: None """ @@ -238,7 +260,7 @@ def print(self): ) print(table) - + def ok(self) -> bool: """ Check if all results in the list are ok. diff --git a/utilities/scripts/python/vendor_files_check.py b/utilities/scripts/python/vendor_files_check.py index 24b086210..791cdb523 100644 --- a/utilities/scripts/python/vendor_files_check.py +++ b/utilities/scripts/python/vendor_files_check.py @@ -1,11 +1,50 @@ - # cspell: words colordiff # Checks if two files that should exist DO, and are equal. # used to enforce consistency between local config files and the expected config locked in CI. -import python.cli as cli +import python.exec_manager as exec_manager +import tomllib +from python.diff import Diff + + +def colordiff_check( + vendor_file_path: str, provided_file_path: str +) -> exec_manager.Result: + return exec_manager.cli_run( + f"colordiff -Nau {provided_file_path} {vendor_file_path}", + name=f"Checking if Provided File {provided_file_path} == Vendored File {vendor_file_path}", + ) + + +def toml_diff_check( + vendor_file_path: str, + provided_file_path: str, + strict: bool = True, + log: bool = True, +) -> exec_manager.Result: + command_name = ( + f"{'' if strict else 'Non '}Strict Checking" + + f"if Provided File {provided_file_path} == Vendored File {vendor_file_path}" + ) + with open(vendor_file_path, "rb") as vendor_file, open( + provided_file_path, "rb" + ) as provided_file: + + def procedure() -> exec_manager.ProcedureResult: + vendor_obj = tomllib.load(vendor_file) + provided_obj = tomllib.load(provided_file) + + diff = Diff(vendor_obj, provided_obj, strict).get_diff() + + return exec_manager.ProcedureResult( + 1 if diff.has_diff() else 0, + command_name, + diff.to_ascii_colored_string(vendor_file_path, provided_file_path), + ) -def colordiff_check(vendor_file_path: str, provided_file_path: str) -> cli.Result: - return cli.run(f"colordiff -Nau {provided_file_path} {vendor_file_path}", - name=f"Checking if Provided File {provided_file_path} == Vendored File {vendor_file_path}") + return exec_manager.procedure_run( + procedure, + command_name, + log=log, + )