diff --git a/.editorconfig b/.editorconfig index d1a2691..ee5adc3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,83 +8,39 @@ root = true # defaults [*] charset = utf-8 -indent_size = 2 end_of_line = lf -indent_style = tab insert_final_newline = true trim_trailing_whitespace = true -# BATS: https://github.com/bats-core/bats-core -# https://github.com/bats-core/bats-core/master/.editorconfig -[*.bats] +# Just +# https://github.com/casey/just/master/justfile +[{justfile,Justfile}] insert_final_newline = true -max_line_length = 80 -trim_trailing_whitespace = true - -# CSS -# https://google.github.io/styleguide/htmlcssguide.xml#General_Formatting_Rules -# http://cssguidelin.es/#syntax-and-formatting -[*.css] -trim_trailing_whitespace = true - -# HTML -# https://google.github.io/styleguide/htmlcssguide.xml#General_Formatting_Rules -[*.{htm,html}] -trim_trailing_whitespace = true - -# JavaScript, JSON, JSX, JavaScript Modules, TypeScript -# https://github.com/feross/standard -# https://prettier.io -[*.{cjs,js,json,jsx,mjs,ts,tsx}] -indent_size = 4 - -# Kotlin -# https://android.github.io/kotlin-guides/style.html#indentation -[*.{kt,kts}] -indent_size = 4 - -# Python -# https://www.python.org/dev/peps/pep-0008/#code-lay-out -[*.py] -indent_size = 4 +indent_style = space +indent_size = 2 # Rust # https://github.com/rust-lang/rust/blob/master/src/doc/style/style/whitespace.md [*.rs] indent_size = 4 +indent_style = tab insert_final_newline = false trim_trailing_whitespace = true -# SQL -# https://www.sqlstyle.guide/ -[*.sql] -indent_size = 4 +# Shell +# https://google.github.io/styleguide/shell.xml#Indentation +[*.{bash,sh,zsh}] +indent_size = 2 indent_style = space -# Prisma -# https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-schema/data-model#formatting -[*.prisma] +# TOML +# https://github.com/toml-lang/toml/tree/master/examples +[*.toml] indent_size = 2 -indent_style = space +indent_style = tab # YAML # http://yaml.org/spec/1.2/2009-07-21/spec.html#id2576668 [*.{yaml,yml}] +indent_size = 2 indent_style = space - -# Shell -# https://google.github.io/styleguide/shell.xml#Indentation -[*.{bash,sh,zsh}] -indent_style = space - -# PowerShell -# https://poshcode.gitbook.io/powershell-practice-and-style/style-guide/code-layout-and-formatting -[*.{ps1,psd1,psm1}] -indent_size = 4 -indent_style = space - -# Swift -# https://github.com/apple/swift-format/blob/main/Documentation/Configuration.md#example -[*.swift] -indent_size = 4 -indent_style = space \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..f05c107 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,77 @@ +name: CI + +on: [pull_request, merge_group] + +env: + # From: https://github.com/rust-lang/rust-analyzer/blob/master/.github/workflows/ci.yaml + CARGO_INCREMENTAL: 0 + CARGO_NET_RETRY: 10 + RUST_BACKTRACE: short + RUSTUP_MAX_RETRIES: 10 + +# Cancel previous runs of the same workflow on the same branch. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + cargo-deny: + runs-on: ubuntu-22.04 + timeout-minutes: 3 + strategy: + matrix: + checks: + - advisories + - licenses sources + + # Prevent sudden announcement of a new advisory from failing ci: + continue-on-error: ${{ matrix.checks == 'advisories' }} + + steps: + - uses: actions/checkout@v4 + - uses: EmbarkStudios/cargo-deny-action@v2 + with: + command: check ${{ matrix.checks }} + + rustfmt: + name: Rust Formatting + runs-on: ubuntu-22.04 + timeout-minutes: 10 + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Check if files have changed + uses: dorny/paths-filter@v3 + continue-on-error: true + id: filter + with: + filters: | + changes: + - 'src/**' + - 'Cargo.toml' + - 'Cargo.lock' + - '.rustfmt.toml' + - '.github/workflows/ci.yml' + + - name: Install Rust + id: toolchain + uses: IronCoreLabs/rust-toolchain@v1 + with: + components: clippy, rustfmt + + - name: Run rustfmt + if: steps.filter.outcome != 'success' || steps.filter.outputs.changes == 'true' + run: cargo fmt --all -- --check + + - name: Run Clippy + if: steps.filter.outcome != 'success' || steps.filter.outputs.changes == 'true' + uses: giraffate/clippy-action@v1 + with: + reporter: github-pr-review + filter_mode: diff_context + github_token: ${{ secrets.GITHUB_TOKEN }} + clippy_flags: --workspace --all-features --locked + fail_on_error: true diff --git a/.rustfmt.toml b/.rustfmt.toml index 9c4c730..cd5cd84 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,12 +1,12 @@ -max_width = 100 -hard_tabs = true -newline_style = "Unix" -use_small_heuristics = "Default" -reorder_imports = true -reorder_modules = true -remove_nested_parens = true -edition = "2021" -merge_derives = true -use_try_shorthand = false +edition = "2021" +force_explicit_abi = true +hard_tabs = true +max_width = 100 +merge_derives = true +newline_style = "Unix" +remove_nested_parens = true +reorder_imports = true +reorder_modules = true use_field_init_shorthand = false -force_explicit_abi = true \ No newline at end of file +use_small_heuristics = "Default" +use_try_shorthand = false diff --git a/.taplo.toml b/.taplo.toml new file mode 100644 index 0000000..59a0f5b --- /dev/null +++ b/.taplo.toml @@ -0,0 +1,11 @@ +[formatting] +align_comments = true +align_entries = true +array_auto_collapse = true +array_trailing_comma = false +column_width = 100 +crlf = false +indent_string = ' ' +reorder_arrays = true +reorder_keys = true +trailing_newline = true diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..e30963b --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,9 @@ +{ + "recommendations": [ + "redhat.vscode-yaml", + "codezombiech.gitignore", + "rust-lang.rust-analyzer", + "editorconfig.editorconfig", + "tamasfe.even-better-toml" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3a292c2 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,16 @@ +{ + "[rust]": { + "editor.defaultFormatter": "rust-lang.rust-analyzer" + }, + "search.exclude": { + "target": true + }, + "explorer.fileNesting.enabled": true, + "explorer.fileNesting.patterns": { + ".env": ".env.example", + "README.md": "CONTRIBUTING.md, CODE_OF_CONDUCT.md, SECURITY.md", + "Cargo.toml": "Cargo.lock" + }, + "rust-analyzer.procMacro.enable": true, + "rust-analyzer.diagnostics.experimental.enable": false +} diff --git a/Cargo.toml b/Cargo.toml index 74e7d3c..008beac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,77 +1,79 @@ [package] -name = "sd-cloud-schema" +name = "sd-cloud-schema" version = "0.1.0" -authors = ["Ericson Soares "] -edition = "2021" -license = "AGPL-3.0-only" -repository = "https://github.com/spacedriveapp/cloud-services-schema" + +authors = ["Ericson Soares "] +autoexamples = false # TODO: Fix example +edition = "2021" +license = "AGPL-3.0-only" +repository = "https://github.com/spacedriveapp/cloud-services-schema" +resolver = "2" rust-version = "1.79.0" -resolver = "2" [lints.rust] # Warns -unused_qualifications = "warn" -rust_2018_idioms = { level = "warn", priority = -1 } -trivial_casts = "warn" +deprecated = "warn" +rust_2018_idioms = { level = "warn", priority = -1 } +trivial_casts = "warn" trivial_numeric_casts = "warn" -unused_allocation = "warn" -deprecated = "warn" +unused_allocation = "warn" +unused_qualifications = "warn" # Forbids deprecated_in_future = "forbid" [lints.clippy] # Warns -all = { level = "warn", priority = -1 } -pedantic = { level = "warn", priority = -1 } -correctness = { level = "warn", priority = -1 } -perf = { level = "warn", priority = -1 } -style = { level = "warn", priority = -1 } -suspicious = { level = "warn", priority = -1 } -complexity = { level = "warn", priority = -1 } -nursery = { level = "warn", priority = -1 } -unwrap_used = "warn" -unnecessary_cast = "warn" -cast_lossless = "warn" +all = { level = "warn", priority = -1 } +cast_lossless = "warn" cast_possible_truncation = "warn" -cast_possible_wrap = "warn" -cast_precision_loss = "warn" -cast_sign_loss = "warn" -dbg_macro = "warn" -deprecated_cfg_attr = "warn" +cast_possible_wrap = "warn" +cast_precision_loss = "warn" +cast_sign_loss = "warn" +complexity = { level = "warn", priority = -1 } +correctness = { level = "warn", priority = -1 } +dbg_macro = "warn" +deprecated_cfg_attr = "warn" +nursery = { level = "warn", priority = -1 } +pedantic = { level = "warn", priority = -1 } +perf = { level = "warn", priority = -1 } separated_literal_suffix = "warn" +style = { level = "warn", priority = -1 } +suspicious = { level = "warn", priority = -1 } +unnecessary_cast = "warn" +unwrap_used = "warn" # Allows -missing_errors_doc = "allow" +missing_errors_doc = "allow" module_name_repetitions = "allow" - [dependencies] -argon2 = "0.5.3" +argon2 = "0.5.3" async-stream = "0.3.5" -chrono = { version = "0.4.38", default-features = false, features = ["serde"] } -# Some deps still use this beta version, get rid of it when they update -derive_more = { version = "1.0.0-beta.7", default-features = false, features = ["display"] } -eyre = "0.6.12" +chrono = { version = "0.4.38", default-features = false, features = ["serde"] } +# Update blocked due to iroh-base +derive_more = { version = "1.0.0-beta.7", default-features = false, features = ["display"] } +eyre = "0.6.12" futures-lite = { version = "2.3.0", default-features = false, features = ["alloc"] } -iroh-base = { version = "0.23.0", features = ["key"] } -opaque-ke = { version = "3.0.0-pre.4", features = ["argon2"] } -paste = "1.0.15" -quic-rpc = { version = "0.12.0", features = ["macros"] } -serde = { version = "1.0.208", features = ["derive"] } -thiserror = "1.0.63" -tracing = "0.1.40" -url = { version = "2.5.2", features = ["serde"] } -uuid = { version = "1.10.0", features = ["serde"] } -zeroize = { version = "1.8.1", features = ["serde", "derive"] } +iroh-base = { version = "0.23.0", features = ["key"] } +opaque-ke = { version = "3.0.0-pre.4", features = ["argon2"] } +paste = "1.0.15" +quic-rpc = { version = "0.12.0", features = ["macros"] } +serde = { version = "1.0.208", features = ["derive"] } +thiserror = "1.0.63" +tracing = "0.1.40" +url = { version = "2.5.2", features = ["serde"] } +uuid = { version = "1.10.0", features = ["serde"] } +zeroize = { version = "1.8.1", features = ["derive", "serde"] } -# The same rspc and specta versions used by Spacedrive's Core -rspc = { git = "https://github.com/spacedriveapp/rspc.git", rev = "0018e80231", features = [ - "uuid", - "chrono", - "tracing", - "alpha", - "unstable", -] } +# The same versions used by Spacedrive's Core +# https://github.com/spacedriveapp/spacedrive/blob/0.4.2/Cargo.toml#L52 specta = { version = "=2.0.0-rc.20", features = ["chrono", "uuid"] } +# The same versions used by Spacedrive's Core +# https://github.com/spacedriveapp/spacedrive/blob/0.4.2/Cargo.toml#L85-L87 +[dependencies.rspc] +features = ["alpha", "chrono", "tracing", "unstable", "uuid"] +git = "https://github.com/spacedriveapp/rspc.git" +rev = "0018e80231" + [dev-dependencies] tokio = { version = "1.39.3", features = ["full"] } diff --git a/deny.toml b/deny.toml new file mode 100644 index 0000000..d0a6943 --- /dev/null +++ b/deny.toml @@ -0,0 +1,27 @@ +[graph] +all-features = true +exclude-dev = true + +[licenses] +# https://www.gnu.org/licenses/license-list.html +allow = [ + "Apache-2.0", + "BSD-2-Clause", + "BSD-3-Clause", + "MIT", # Also know as Expat + "Unicode-DFS-2016", + "Unlicense", + "Zlib" +] +confidence-threshold = 0.93 +exceptions = [ + # We own sd-cloud-schema + { allow = ["AGPL-3.0"], crate = "sd-cloud-schema" } +] + +[sources] +unknown-git = "deny" +unknown-registry = "deny" + +[sources.allow-org] +github = ["spacedriveapp"] diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..3b2243a --- /dev/null +++ b/renovate.json @@ -0,0 +1,29 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:recommended", + + ":label(type/renovate)", + + ":disableRateLimiting", + ":ignoreUnstable", + ":separateMajorReleases", + ":automergePr", + ":automergeRequireAllStatusChecks", + ":automergeAll", + ":semanticCommits", + + ":enableVulnerabilityAlerts", + ":enableVulnerabilityAlertsWithLabel(security)" + ], + + "rebaseWhen": "conflicted", + "platformAutomerge": true, + "rebaseLabel": "renovate/rebase", + "stopUpdatingLabel": "renovate/stop-updating", + + "major": { "labels": ["bump/major"] }, + "minor": { "labels": ["bump/minor"] }, + "patch": { "labels": ["bump/patch"] }, + "digest": { "labels": ["bump/digest"] } +}