Skip to content

Commit

Permalink
Merge pull request #2 from spacedriveapp/configure-ci
Browse files Browse the repository at this point in the history
Configure CI
  • Loading branch information
HeavenVolkoff committed Aug 20, 2024
2 parents 3b4bb7b + 33b66d8 commit 31d3f1c
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 122 deletions.
74 changes: 15 additions & 59 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
77 changes: 77 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -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
22 changes: 11 additions & 11 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -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
use_small_heuristics = "Default"
use_try_shorthand = false
11 changes: 11 additions & 0 deletions .taplo.toml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"redhat.vscode-yaml",
"codezombiech.gitignore",
"rust-lang.rust-analyzer",
"editorconfig.editorconfig",
"tamasfe.even-better-toml"
]
}
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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
}
106 changes: 54 additions & 52 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,77 +1,79 @@
[package]
name = "sd-cloud-schema"
name = "sd-cloud-schema"
version = "0.1.0"
authors = ["Ericson Soares <[email protected]>"]
edition = "2021"
license = "AGPL-3.0-only"
repository = "https://github.com/spacedriveapp/cloud-services-schema"

authors = ["Ericson Soares <[email protected]>"]
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"] }
Loading

0 comments on commit 31d3f1c

Please sign in to comment.