Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .deny.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# https://embarkstudios.github.io/cargo-deny/checks/cfg.html

[graph]
all-features = true
exclude = [
# dev only dependency
"criterion"
]

[advisories]
version = 2

[licenses]
version = 2
allow = [
"Apache-2.0",
"BSD-3-Clause",
"MIT",
"MPL-2.0",
"Unicode-3.0",
"Zlib",
]
private = { ignore = true }

[bans]
multiple-versions = "warn"
wildcards = "deny"

[[bans.features]]
name = "serde_json"
# These features all don't make sense to activate from a library as they apply
# globally to all users of serde_json. Make sure we don't enable them somehow.
deny = [
"arbitrary_precision",
"float_roundtrip",
"preserve_order",
"unbounded_depth",
]

[sources]
unknown-registry = "deny"
unknown-git = "deny"
118 changes: 118 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: CI

env:
CARGO_TERM_COLOR: always
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
NIGHTLY: nightly-2025-03-03

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
style:
name: Style
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Install rust nightly toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.NIGHTLY }}

- uses: Swatinem/rust-cache@v2

- name: Check spelling
uses: crate-ci/[email protected]

- name: Install cargo-sort
uses: taiki-e/cache-cargo-install-action@v2
with:
tool: cargo-sort

- name: Run cargo-sort
run: |
cargo sort --workspace --grouped --check \
--order package,lib,features,dependencies,target,dev-dependencies,build-dependencies

msrv:
name: Minimum Supported Rust Version / Check All Features
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Install MSRV toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.81"

- uses: Swatinem/rust-cache@v2
with:
# A stable compiler update should automatically not reuse old caches.
# Add the MSRV as a stable cache key too so bumping it also gets us a
# fresh cache.
shared-key: msrv1.81

- name: Run checks
run: cargo check --all-features

stable:
name: Rust Stable / ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: Check All Features
cmd: check --all-features

- name: Run Tests
cmd: test --all-features

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

- name: Install rust stable toolchain
uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2

- name: Run checks
run: cargo ${{ matrix.cmd }}

nightly:
name: Rust Nightly / ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: Check Formatting
cmd: fmt --check
components: rustfmt

- name: All Features
cmd: check --all-features

- name: Clippy Default Features
cmd: clippy --all-features --all-targets -- -D warnings
components: clippy

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

- name: Install rust nightly toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.NIGHTLY }}
components: ${{ matrix.components }}

- uses: Swatinem/rust-cache@v2

- name: Run checks
run: cargo ${{ matrix.cmd }}
36 changes: 36 additions & 0 deletions .github/workflows/deps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Dependencies

env:
CARGO_TERM_COLOR: always
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse

on:
schedule:
# every monday at 4AM (UTC?)
- cron: '0 4 * * 1'
push:
branches: [main]
pull_request:
branches: [main]

jobs:
bans-licenses-sources:
name: Bans, Licenses, Sources
runs-on: ubuntu-latest
if: github.event.name != 'schedule'

steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v2
with:
command: check bans licenses sources

advisories:
name: Advisories
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v2
with:
command: check advisories
24 changes: 0 additions & 24 deletions .github/workflows/nightly.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/stable.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
comment_width = 100
format_code_in_doc_comments = true
imports_granularity = "Crate"
group_imports = "StdExternalCrate"
newline_style = "Unix"
use_field_init_shorthand = true
use_small_heuristics = "Max"
wrap_comments = true
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ Breaking changes:

* The list_room response changes the fields `version`, `join_rules`, `guest_access` and `history_visibility` to be an option
* The list_room response changes the `join_rules` field to be `Option<SpaceRoomJoinRule>`
* `background_update::run::v1::JobName` is now non-exhaustive.
* `RoomSortOrder` and `RoomDirection` in `rooms::list_rooms::v1` are now non-
exhaustive. Their `PartialOrd` and `Ord` implementations now use their string
representation instead of the order in which they are defined in the enum.
* `UserDetails`, `ExternalId`, `CurrentUpdate`, `ExperimentalFeatures`,
`RoomDetails` and `UserMinorDetails` are now non-exhaustive. To keep using
them as if they were exhaustive, use the `ruma_unstable_exhaustive_types`
compile-time `cfg` setting.

Improvement:

Expand Down
35 changes: 35 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ keywords = ["matrix", "chat", "messaging", "ruma"]
license = "MIT"
repository = "https://github.com/ruma/synapse-admin-api"
edition = "2018"
rust-version = "1.81"

[features]
client = []
Expand All @@ -26,6 +27,40 @@ sha1 = { version = "0.10.1", optional = true }
serde_json = "1.0.61"

[lints.rust]
rust_2018_idioms = { level = "warn", priority = -1 }
semicolon_in_expressions_from_macros = "warn"
unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(ruma_unstable_exhaustive_types)', # set all types as exhaustive
] }
unreachable_pub = "warn"
unused_import_braces = "warn"
unused_qualifications = "warn"

[lints.clippy]
branches_sharing_code = "warn"
cloned_instead_of_copied = "warn"
dbg_macro = "warn"
disallowed_types = "warn"
empty_line_after_outer_attr = "warn"
exhaustive_enums = "warn"
exhaustive_structs = "warn"
inefficient_to_string = "warn"
macro_use_imports = "warn"
map_flatten = "warn"
missing_enforced_import_renames = "warn"
mod_module_files = "warn"
mut_mut = "warn"
nonstandard_macro_braces = "warn"
semicolon_if_nothing_returned = "warn"
str_to_string = "warn"
todo = "warn"
unreadable_literal = "warn"
unseparated_literal_suffix = "warn"
wildcard_imports = "warn"

# Not that good of a lint
new_without_default = "allow"
# Disabled temporarily because it triggers false positives for types with generics.
arc_with_non_send_sync = "allow"
# Currently buggy
literal_string_with_formatting_args = "allow"
5 changes: 3 additions & 2 deletions src/background_updates/run/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use ruma::{
api::{request, response, Metadata},
metadata,
serde::StringEnum,
serde::{PartialEqAsRefStr, StringEnum},
};

const METADATA: Metadata = metadata! {
Expand Down Expand Up @@ -39,8 +39,9 @@ impl Response {
}
}

#[derive(Clone, PartialEq, StringEnum)]
#[derive(Clone, PartialEqAsRefStr, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")]
#[non_exhaustive]
pub enum JobName {
/// Recalculate the stats for all rooms.
PopulateStatsProcessRooms,
Expand Down
Loading