Skip to content

Commit

Permalink
feat: update rust configs and ci set-up (#6)
Browse files Browse the repository at this point in the history
* feat: update rust configs

* chore: update rust configs and ci

* chore: update deny.toml and Earthfile

* chore: clean up

* Update clippy.toml
  • Loading branch information
minikin authored Aug 26, 2024
1 parent 987aade commit 546e77d
Show file tree
Hide file tree
Showing 11 changed files with 406 additions and 101 deletions.
93 changes: 93 additions & 0 deletions rust/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Use MOLD linker where possible, but ONLY in CI applicable targets.

# Configure how Docker container targets build.

# 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.

# DO NOT remove `"-C", "target-feature=+crt-static"` from the rustflags for these targets.

# Should be the default to have fully static rust programs in CI
[target.x86_64-unknown-linux-musl]
linker = "clang"
rustflags = [
"-C", "link-arg=-fuse-ld=/usr/bin/mold",
"-C", "target-feature=-crt-static"
]

# Should be the default to have fully static rust programs in CI
[target.aarch64-unknown-linux-musl]
linker = "clang"
rustflags = [
"-C", "link-arg=-fuse-ld=/usr/bin/mold",
"-C", "target-feature=-crt-static"
]

[build]
rustflags = []
rustdocflags = [
"--enable-index-page",
"-Z",
"unstable-options",
]

[profile.dev]
opt-level = 1
debug = true
debug-assertions = true
overflow-checks = true
lto = false
panic = "unwind"
incremental = true
codegen-units = 256

[profile.release]
opt-level = 3
debug = false
debug-assertions = false
overflow-checks = false
lto = "thin"
panic = "unwind"
incremental = false
codegen-units = 16

[profile.test]
opt-level = 3
debug = true
lto = false
debug-assertions = true
incremental = true
codegen-units = 256

[profile.bench]
opt-level = 3
debug = false
debug-assertions = false
overflow-checks = false
lto = "thin"
incremental = false
codegen-units = 16

[alias]
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 --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
fmtchk = "fmt -- --check -v --color=always"
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
progress.width = 80 # width of progress bar
49 changes: 49 additions & 0 deletions rust/.config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 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/<profile-name>.
# dir = "target/nextest"

[profile.default]
# Print out output for failing tests as soon as they fail, and also at the end
# of the run (for easy scrollability).
failure-output = "immediate-final"

# Do not cancel the test run on the first failure.
fail-fast = true

status-level = "all"
final-status-level = "all"

[profile.ci]
# Print out output for failing tests as soon as they fail, and also at the end
# of the run (for easy scrollability).
failure-output = "immediate-final"
# Do not cancel the test run on the first failure.
fail-fast = false

status-level = "all"
final-status-level = "all"


[profile.ci.junit]
# Output a JUnit report into the given file inside 'store.dir/<profile-name>'.
# If unspecified, JUnit is not written out.

path = "junit.xml"

# The name of the top-level "report" element in JUnit report. If aggregating
# reports across different test runs, it may be useful to provide separate names
# for each report.
report-name = "nextest"

# Whether standard output and standard error for passing tests should be stored in the JUnit report.
# Output is stored in the <system-out> and <system-err> elements of the <testcase> element.
store-success-output = true

# Whether standard output and standard error for failing tests should be stored in the JUnit report.
# Output is stored in the <system-out> and <system-err> elements of the <testcase> element.
#
# Note that if a description can be extracted from the output, it is always stored in the
# <description> element.
store-failure-output = true
104 changes: 104 additions & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
[workspace]
resolver = "2"
members = ["c509-certificate", "cardano-chain-follower", "hermes-ipfs"]

[workspace.package]
edition = "2021"
version = "0.0.1"
authors = ["Steven Johnson <[email protected]>"]
homepage = "https://github.com/input-output-hk/catalyst-libs"
repository = "https://github.com/input-output-hk/catalyst-libs"
license = "MIT OR Apache-2.0"

[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 = { level = "deny", priority = -1 }
unwrap_used = "deny"
expect_used = "deny"
todo = "deny"
unimplemented = "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"

[workspace.dependencies]
pallas = { git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "709acb19c52c6b789279ecc4bc8793b5d8b5abe9", version = "0.25.0" }
pallas-hardano = { git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "709acb19c52c6b789279ecc4bc8793b5d8b5abe9", version = "0.25.0" }

wasmtime = "20.0.2"
rusty_ulid = "2.0.0"
anyhow = "1.0.71"
hex-literal = "0.4.1"
thiserror = "1.0.56"
hex = "0.4.3"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
criterion = "0.5.1"
libtest-mimic = "0.7.0"
crossbeam-queue = "0.3.11"
bip39 = "2.0.0"
iana-time-zone = "0.1.60"
rand = "0.8.5"
bip32 = "0.5.1"
ed25519-bip32 = "0.4.1"
dashmap = "6.0.1"
once_cell = "1.19.0"
clap = "4.5.3"
build-info = "0.0.37"
build-info-build = "0.0.37"
derive_more = "0.99.17"
chrono = "0.4.35"
chrono-tz = "0.9.0"
saffron = "0.1.0"
tokio = "1.36.0"
libsqlite3-sys = "0.29.0"
stringzilla = "3.8.4"
serial_test = { version = "3.1.1", features = ["file_locks"] }
temp-dir = "0.1.13"
hdf5 = { git = "https://github.com/aldanor/hdf5-rust.git", rev = "694e900972fbf5ffbdd1a2294f57a2cc3a91c994", version = "0.8.1", features = [
"static",
"blosc",
] }
blosc-src = { version = "0.3.0", features = ["lz4", "zlib", "zstd"] }
num_cpus = "1.16.0"
console = "0.15.8"
serde = "1.0"
serde_json = "1.0"
jsonschema = "0.18.0"
hmac = "0.12.1"
pbkdf2 = "0.12.2"
blake2b_simd = "1.0.2"
sha2 = "0.10"
ed25519-dalek = "2.1.1"
x509-cert = "0.2.5"
coset = "0.3.7"
libipld = "0.16.0"
rust-ipfs = "0.11.21"
rustyline-async = "0.4.2"
dirs = "5.0.1"
lipsum = "0.9.1"
39 changes: 17 additions & 22 deletions rust/Earthfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,33 @@
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.1.24 AS rust-ci
# Use when debugging cat-ci locally.
# IMPORT ../../catalyst-ci/earthly/rust AS rust-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.1.21 AS rust-ci

# builder : Set up our target toolchains, and copy our files.
builder:
DO rust-ci+SETUP
# COPY --dir .cargo .config crates bin .
# COPY Cargo.toml .
# COPY clippy.toml deny.toml rustfmt.toml .

## -----------------------------------------------------------------------------
##
## Standard CI targets.
##
## These targets are discovered and executed automatically by CI.

# check : Run check using the most efficient host tooling
# CI Automated Entry point.

COPY Cargo.toml clippy.toml deny.toml rustfmt.toml .
COPY --dir .cargo .config c509-certificate cardano-chain-follower cbork hermes-ipfs .

# check : Run basic check.
check:
FROM +builder

DO rust-ci+EXECUTE --cmd="/scripts/std_checks.py"

# all-hosts-check : Test which runs check with all supported host tooling.
# Needs qemu or rosetta to run.
# Only used to validate tooling is working across host toolsets.
all-hosts-check:
BUILD --platform=linux/amd64 --platform=linux/arm64 +check
# build : Build crates.
build:
FROM +builder

## -----------------------------------------------------------------------------
DO rust-ci+EXECUTE \
--cmd="/scripts/std_build.py" \
--args1="--libs=c509-certificate" \
--args2="--libs=cardano-chain-follower" \
--args3="--libs=cbork" \
--args4="--libs=hermes-ipfs" \
--docs="true"

# local-ci-run: This step simulates the full CI run for local purposes only.
local-ci-run:
BUILD +check
BUILD +build
BUILD +build
41 changes: 2 additions & 39 deletions rust/c509-certificate/deny.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[graph]
# cargo-deny is really only ever intended to run on the "normal" tier-1 targets
targets = [
"x86_64-unknown-linux-gnu",
"aarch64-unknown-linux-gnu",
Expand All @@ -23,20 +22,11 @@ ignore = [
multiple-versions = "warn"
wildcards = 'deny'
deny = [
# { crate = "git2", use-instead = "gix" },
{ crate = "openssl", use-instead = "rustls" },
{ crate = "openssl-sys", use-instead = "rustls" },
"libssh2-sys",
# { crate = "cmake", use-instead = "cc" },
# { crate = "windows", reason = "bloated and unnecessary", use-instead = "ideally inline bindings, practically, windows-sys" },
]
skip = [
# { crate = "[email protected]", reason = "https://github.com/seanmonstar/reqwest/pull/2130 should be in the next version" },
# { crate = "[email protected]", reason = "gix 0.59 was yanked, see https://github.com/Byron/gitoxide/issues/1309" },
# { crate = "[email protected]", reason = "strum_macros uses this old version" },
# { crate = "[email protected]", reason = "gix-transport pulls in this old version, as well as a newer version via reqwest" },
# { crate = "[email protected]", reason = "gix-transport pulls in this old version, as well as a newer version via reqwest" },
]
skip = []
skip-tree = [
{ crate = "[email protected]", reason = "a foundational crate for many that bumps far too frequently to ever have a shared version" },
]
Expand All @@ -55,9 +45,7 @@ allow-git = [

[licenses]
version = 2
# Don't warn if a listed license isn't found
unused-allowed-license = "allow"
# We want really high confidence when inferring licenses from text
confidence-threshold = 0.93
allow = [
"MIT",
Expand All @@ -72,11 +60,7 @@ allow = [
"Unicode-3.0",
"MPL-2.0",
]
exceptions = [
#{ allow = ["Zlib"], crate = "tinyvec" },
#{ allow = ["Unicode-DFS-2016"], crate = "unicode-ident" },
#{ allow = ["OpenSSL"], crate = "ring" },
]
exceptions = []

[[licenses.clarify]]
crate = "byte-array-literals"
Expand All @@ -92,24 +76,3 @@ license-files = [{ path = "../LICENSE-MIT", hash = 0x001c7e6c }]
crate = "ring"
expression = "MIT"
license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }]

# SPDX considers OpenSSL to encompass both the OpenSSL and SSLeay licenses
# https://spdx.org/licenses/OpenSSL.html
# ISC - Both BoringSSL and ring use this for their new files
# MIT - "Files in third_party/ have their own licenses, as described therein. The MIT
# license, for third_party/fiat, which, unlike other third_party directories, is
# compiled into non-test libraries, is included below."
# OpenSSL - Obviously
#expression = "ISC AND MIT AND OpenSSL"
#license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }]

#[[licenses.clarify]]
#crate = "webpki"
#expression = "ISC"
#license-files = [{ path = "LICENSE", hash = 0x001c7e6c }]

# Actually "ISC-style"
#[[licenses.clarify]]
#crate = "rustls-webpki"
#expression = "ISC"
#license-files = [{ path = "LICENSE", hash = 0x001c7e6c }]
2 changes: 1 addition & 1 deletion rust/cbork/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ build:

# Test which runs check with all supported host tooling. Needs qemu or rosetta to run.
# Only used to validate tooling is working across host toolsets.
build-all-hosts:
build-all-hosts:
BUILD --platform=linux/amd64 --platform=linux/arm64 +build-hosted
Loading

0 comments on commit 546e77d

Please sign in to comment.