Skip to content

Commit a0f5266

Browse files
committed
feat: Improve CI
Add most of the same checks as for ruma.
1 parent 56bddc9 commit a0f5266

File tree

7 files changed

+229
-44
lines changed

7 files changed

+229
-44
lines changed

.deny.toml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# https://embarkstudios.github.io/cargo-deny/checks/cfg.html
2+
3+
[graph]
4+
all-features = true
5+
exclude = [
6+
# dev only dependency
7+
"criterion"
8+
]
9+
10+
[advisories]
11+
version = 2
12+
13+
[licenses]
14+
version = 2
15+
allow = [
16+
"Apache-2.0",
17+
"BSD-3-Clause",
18+
"MIT",
19+
"MPL-2.0",
20+
"Unicode-3.0",
21+
"Zlib",
22+
]
23+
private = { ignore = true }
24+
25+
[bans]
26+
multiple-versions = "warn"
27+
wildcards = "deny"
28+
29+
[[bans.features]]
30+
name = "serde_json"
31+
# These features all don't make sense to activate from a library as they apply
32+
# globally to all users of serde_json. Make sure we don't enable them somehow.
33+
deny = [
34+
"arbitrary_precision",
35+
"float_roundtrip",
36+
"preserve_order",
37+
"unbounded_depth",
38+
]
39+
40+
[sources]
41+
unknown-registry = "deny"
42+
unknown-git = "deny"

.github/workflows/ci.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: CI
2+
3+
env:
4+
CARGO_TERM_COLOR: always
5+
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
6+
NIGHTLY: nightly-2025-03-03
7+
8+
on:
9+
push:
10+
branches: [main]
11+
pull_request:
12+
branches: [main]
13+
14+
jobs:
15+
style:
16+
name: Style
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout repo
20+
uses: actions/checkout@v4
21+
22+
- name: Install rust nightly toolchain
23+
uses: dtolnay/rust-toolchain@master
24+
with:
25+
toolchain: ${{ env.NIGHTLY }}
26+
27+
- uses: Swatinem/rust-cache@v2
28+
29+
- name: Check spelling
30+
uses: crate-ci/[email protected]
31+
32+
- name: Install cargo-sort
33+
uses: taiki-e/cache-cargo-install-action@v2
34+
with:
35+
tool: cargo-sort
36+
37+
msrv:
38+
name: Minimum Supported Rust Version / Check All Features
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout repo
42+
uses: actions/checkout@v4
43+
44+
- name: Install MSRV toolchain
45+
uses: dtolnay/rust-toolchain@master
46+
with:
47+
toolchain: "1.81"
48+
49+
- uses: Swatinem/rust-cache@v2
50+
with:
51+
# A stable compiler update should automatically not reuse old caches.
52+
# Add the MSRV as a stable cache key too so bumping it also gets us a
53+
# fresh cache.
54+
shared-key: msrv1.81
55+
56+
- name: Run checks
57+
run: cargo check --all-features
58+
59+
stable:
60+
name: Rust Stable / ${{ matrix.name }}
61+
runs-on: ubuntu-latest
62+
strategy:
63+
matrix:
64+
include:
65+
- name: Check All Features
66+
cmd: check --all-features
67+
68+
- name: Run Tests
69+
cmd: test --all-features
70+
71+
steps:
72+
- name: Checkout repo
73+
uses: actions/checkout@v4
74+
75+
- name: Install rust stable toolchain
76+
uses: dtolnay/rust-toolchain@stable
77+
78+
- uses: Swatinem/rust-cache@v2
79+
80+
- name: Run checks
81+
run: cargo ${{ matrix.cmd }}
82+
83+
nightly:
84+
name: Rust Nightly / ${{ matrix.name }}
85+
runs-on: ubuntu-latest
86+
strategy:
87+
matrix:
88+
include:
89+
- name: Check Formatting
90+
cmd: fmt --check
91+
components: rustfmt
92+
93+
- name: All Features
94+
cmd: check --all-features
95+
96+
- name: Clippy Default Features
97+
cmd: clippy --all-features --all-targets -- -D warnings
98+
components: clippy
99+
100+
steps:
101+
- name: Checkout repo
102+
uses: actions/checkout@v4
103+
104+
- name: Install rust nightly toolchain
105+
uses: dtolnay/rust-toolchain@master
106+
with:
107+
toolchain: ${{ env.NIGHTLY }}
108+
components: ${{ matrix.components }}
109+
110+
- uses: Swatinem/rust-cache@v2
111+
112+
- name: Run checks
113+
run: cargo ${{ matrix.cmd }}

.github/workflows/deps.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Dependencies
2+
3+
env:
4+
CARGO_TERM_COLOR: always
5+
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
6+
7+
on:
8+
schedule:
9+
# every monday at 4AM (UTC?)
10+
- cron: '0 4 * * 1'
11+
push:
12+
branches: [main]
13+
pull_request:
14+
branches: [main]
15+
16+
jobs:
17+
bans-licenses-sources:
18+
name: Bans, Licenses, Sources
19+
runs-on: ubuntu-latest
20+
if: github.event.name != 'schedule'
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: EmbarkStudios/cargo-deny-action@v2
25+
with:
26+
command: check bans licenses sources
27+
28+
advisories:
29+
name: Advisories
30+
runs-on: ubuntu-latest
31+
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: EmbarkStudios/cargo-deny-action@v2
35+
with:
36+
command: check advisories

.github/workflows/nightly.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/stable.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

.rustfmt.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
comment_width = 100
2+
format_code_in_doc_comments = true
23
imports_granularity = "Crate"
4+
group_imports = "StdExternalCrate"
35
newline_style = "Unix"
6+
use_field_init_shorthand = true
47
use_small_heuristics = "Max"
58
wrap_comments = true

Cargo.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ keywords = ["matrix", "chat", "messaging", "ruma"]
88
license = "MIT"
99
repository = "https://github.com/ruma/synapse-admin-api"
1010
edition = "2018"
11+
rust-version = "1.81"
1112

1213
[features]
1314
client = []
@@ -26,6 +27,40 @@ sha1 = { version = "0.10.1", optional = true }
2627
serde_json = "1.0.61"
2728

2829
[lints.rust]
30+
rust_2018_idioms = { level = "warn", priority = -1 }
31+
semicolon_in_expressions_from_macros = "warn"
2932
unexpected_cfgs = { level = "warn", check-cfg = [
3033
'cfg(ruma_unstable_exhaustive_types)', # set all types as exhaustive
3134
] }
35+
unreachable_pub = "warn"
36+
unused_import_braces = "warn"
37+
unused_qualifications = "warn"
38+
39+
[lints.clippy]
40+
branches_sharing_code = "warn"
41+
cloned_instead_of_copied = "warn"
42+
dbg_macro = "warn"
43+
disallowed_types = "warn"
44+
empty_line_after_outer_attr = "warn"
45+
# exhaustive_enums = "warn"
46+
# exhaustive_structs = "warn"
47+
inefficient_to_string = "warn"
48+
macro_use_imports = "warn"
49+
map_flatten = "warn"
50+
missing_enforced_import_renames = "warn"
51+
mod_module_files = "warn"
52+
mut_mut = "warn"
53+
nonstandard_macro_braces = "warn"
54+
semicolon_if_nothing_returned = "warn"
55+
str_to_string = "warn"
56+
todo = "warn"
57+
unreadable_literal = "warn"
58+
unseparated_literal_suffix = "warn"
59+
wildcard_imports = "warn"
60+
61+
# Not that good of a lint
62+
new_without_default = "allow"
63+
# Disabled temporarily because it triggers false positives for types with generics.
64+
arc_with_non_send_sync = "allow"
65+
# Currently buggy
66+
literal_string_with_formatting_args = "allow"

0 commit comments

Comments
 (0)