Skip to content

Commit

Permalink
chore: prepare workspace (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
CBenoit authored Dec 5, 2024
1 parent fdf0c52 commit 4ce02f2
Show file tree
Hide file tree
Showing 43 changed files with 2,247 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
xtask = "run --package xtask --"
363 changes: 363 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# File auto-generated and managed by Devops
/.github/ @devolutions/devops
/.github/ @devolutions/devops @devolutions/architecture-maintainers
/.github/dependabot.yml @devolutions/security-managers
26 changes: 26 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"
assignees:
- "CBenoit"
open-pull-requests-limit: 3
groups:
crypto:
patterns:
- "md-5"
- "md5"
- "sha1"
- "pkcs1"
- "x509-cert"
- "der"
- "*tls*"
- "*rand*"
patch:
dependency-type: "production"
update-types:
- "patch"
dev:
dependency-type: "development"
146 changes: 146 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: CI

on:
push:
branches:
- master
pull_request:
types: [ opened, synchronize, reopened ]
workflow_dispatch:

env:
# Disable incremental compilation. CI builds are often closer to from-scratch builds, as changes
# are typically bigger than from a local edit-compile cycle.
# Incremental compilation also significantly increases the amount of IO and the size of ./target
# folder, which makes caching less effective.
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
RUST_BACKTRACE: short
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
# Cache should never takes more than a few seconds to get downloaded.
# If it does, let’s just rebuild from scratch instead of hanging "forever".
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
# Disabling debug info so compilation is faster and ./target folder is smaller.
CARGO_PROFILE_DEV_DEBUG: 0

jobs:
formatting:
name: Check formatting
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Check formatting (Rust)
run: cargo xtask rust fmt -v

- name: Check formatting (.NET)
run: cargo xtask dotnet fmt -v

typos:
name: Check typos
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Binary cache
uses: actions/cache@v4
with:
path: ./.cargo/local_root/bin
key: ${{ runner.os }}-bin-${{ github.job }}-${{ hashFiles('xtask/src/bin_version.rs') }}

- name: typos (prepare)
run: cargo xtask check install -v

- name: typos (check)
run: cargo xtask check typos -v

rust-checks:
name: Rust checks [${{ matrix.os }}]
runs-on: ${{ matrix.runner }}
needs: formatting
strategy:
fail-fast: false
matrix:
os: [ windows, linux, macos ]
include:
- os: windows
runner: windows-latest
- os: linux
runner: ubuntu-latest
- os: macos
runner: macos-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Rust cache
uses: Swatinem/[email protected]

- name: Binary cache
uses: actions/cache@v4
with:
path: ./.cargo/local_root/bin
key: ${{ runner.os }}-bin-${{ github.job }}-${{ hashFiles('xtask/src/bin_version.rs') }}

# Compilation is separated from execution so we know exactly the time for each step.
- name: Tests (compile)
run: cargo xtask rust tests --no-run -v
- name: Tests (run)
run: cargo xtask rust tests -v

- name: Lints
run: cargo xtask rust lints -v

- name: Lock files
run: cargo xtask check locks -v

dotnet-checks:
name: .NET checks [${{ matrix.os }}]
runs-on: ${{ matrix.runner }}
needs: formatting
strategy:
fail-fast: false
matrix:
os: [ windows, linux, macos ]
include:
- os: windows
runner: windows-latest
- os: linux
runner: ubuntu-latest
- os: macos
runner: macos-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Tests
run: cargo xtask dotnet tests -v

- name: Lints
run: cargo xtask dotnet build -v

- name: Lock files
run: cargo xtask check locks -v

success:
name: Success
runs-on: ubuntu-latest
if: ${{ always() }}
needs:
- formatting
- typos
- rust-checks
- dotnet-checks

steps:
- name: Check success
shell: pwsh
run: |
$results = '${{ toJSON(needs.*.result) }}' | ConvertFrom-Json
$succeeded = $($results | Where { $_ -Ne "success" }).Count -Eq 0
exit $(if ($succeeded) { 0 } else { 1 })
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Build artifacts
/target

# Local cargo root
/.cargo/local_root

# Editor/IDE files
*~
/tags
.idea
.vscode
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sw?
51 changes: 51 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

106 changes: 106 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
[workspace]
resolver = "2"
members = [
"crates/*",
"xtask",
]

[workspace.package]
edition = "2021"
license = "MIT/Apache-2.0"
homepage = "https://github.com/Devolutions/now-proto"
repository = "https://github.com/Devolutions/now-proto"
authors = ["Devolutions Inc. <[email protected]>"]
keywords = ["rdp", "remote-desktop", "network", "client", "protocol"]
categories = ["network-programming"]

[workspace.dependencies]
now-proto-pdu = { version = "0.1", path = "crates/now-proto-pdu" }
now-proto-fuzzing = { version = "0.1", path = "crates/now-proto-fuzzing" }

[profile.test.package.proptest]
opt-level = 3

[profile.test.package.rand_chacha]
opt-level = 3

[workspace.lints.rust]
# == Safer unsafe == #
unsafe_op_in_unsafe_fn = "warn"
invalid_reference_casting = "warn"

# == Style, readability == #
elided_lifetimes_in_paths = "warn" # https://quinedot.github.io/rust-learning/dont-hide.html
absolute_paths_not_starting_with_crate = "warn"
single_use_lifetimes = "warn"
unreachable_pub = "warn"
unused_lifetimes = "warn"
unused_qualifications = "warn"
keyword_idents = "warn"
noop_method_call = "warn"

# == Compile-time / optimization == #
unused_crate_dependencies = "warn"
unused_macro_rules = "warn"

[workspace.lints.clippy]
# == Safer unsafe == #
undocumented_unsafe_blocks = "warn"
multiple_unsafe_ops_per_block = "warn"
transmute_ptr_to_ptr = "warn"
as_ptr_cast_mut = "warn"
cast_ptr_alignment = "warn"
fn_to_numeric_cast_any = "warn"
ptr_cast_constness = "warn"

# == Correctness == #
cast_lossless = "warn"
cast_possible_truncation = "warn"
cast_possible_wrap = "warn"
cast_sign_loss = "warn"
float_cmp = "warn"
as_underscore = "warn"
unwrap_used = "warn" # Let’s either handle `None`, `Err` or use `expect` to give a reason.
large_stack_frames = "warn"

# == Style, readability == #
semicolon_outside_block = "warn" # With semicolon-outside-block-ignore-multiline = true
clone_on_ref_ptr = "warn"
cloned_instead_of_copied = "warn"
trait_duplication_in_bounds = "warn"
type_repetition_in_bounds = "warn"
checked_conversions = "warn"
get_unwrap = "warn"
similar_names = "warn" # Reduce risk of confusing similar names together, and protects against typos when variable shadowing was intended.
str_to_string = "warn"
string_to_string = "warn"
std_instead_of_core = "warn"
separated_literal_suffix = "warn"
unused_self = "warn"
useless_let_if_seq = "warn"
string_add = "warn"
range_plus_one = "warn"
self_named_module_files = "warn"
partial_pub_fields = "warn"

# == Compile-time / optimization == #
inline_always = "warn"
or_fun_call = "warn"
unnecessary_box_returns = "warn"

# == Extra-pedantic clippy == #
collection_is_never_read = "warn"
copy_iterator = "warn"
expl_impl_clone_on_copy = "warn"
implicit_clone = "warn"
large_types_passed_by_value = "warn"
redundant_clone = "warn"
alloc_instead_of_core = "warn"
empty_drop = "warn"
return_self_not_must_use = "warn"
wildcard_dependencies = "warn"

# == Let’s not merge unintended eprint!/print! statements in libraries == #
print_stderr = "warn"
print_stdout = "warn"
dbg_macro = "warn"
Loading

0 comments on commit 4ce02f2

Please sign in to comment.