mirror of
https://github.com/Blah-IM/blahrs.git
synced 2025-05-01 00:31:09 +00:00
build(toolchain),ci: switch to rust 1.82-beta for now
`precise_capturing` has no workaround but we need it in tests. The main crate should still compile under stable rustc, which is enforced by CI.
This commit is contained in:
parent
7160e5adbd
commit
199985c6a2
8 changed files with 88 additions and 34 deletions
15
.github/workflows/ci.yaml
vendored
15
.github/workflows/ci.yaml
vendored
|
@ -20,10 +20,10 @@ jobs:
|
|||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Rust stable
|
||||
- name: Install Rust beta
|
||||
run: |
|
||||
rustup update --no-self-update stable
|
||||
rustup default stable
|
||||
rustup update --no-self-update beta
|
||||
rustup default beta
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
|
@ -40,7 +40,7 @@ jobs:
|
|||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
rust: [stable]
|
||||
rust: [stable, beta]
|
||||
name: Test ${{ matrix.rust }}
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
|
@ -48,11 +48,18 @@ jobs:
|
|||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Disable high-priority rust-toolchain.toml
|
||||
run: rm rust-toolchain.toml
|
||||
|
||||
- name: Install Rust ${{ matrix.rust }}
|
||||
run: |
|
||||
rustup update --no-self-update ${{ matrix.rust }}
|
||||
rustup default ${{ matrix.rust }}
|
||||
|
||||
- name: Disable integration tests on stable rustc
|
||||
if: matrix.rust == 'stable'
|
||||
run: mv ./blahd/tests{,-disabled}
|
||||
|
||||
- name: Cache Dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ members = [
|
|||
default-members = ["blahd"]
|
||||
|
||||
[workspace.lints.clippy]
|
||||
allow_attributes = "warn"
|
||||
allow_attributes_without_reason = "warn"
|
||||
dbg_macro = "warn"
|
||||
print_stderr = "warn"
|
||||
print_stdout = "warn"
|
||||
|
|
|
@ -119,6 +119,10 @@ type RE<T> = R<T, ApiError>;
|
|||
async fn handle_ws(State(st): ArcState, ws: WebSocketUpgrade) -> Response {
|
||||
ws.on_upgrade(move |mut socket| async move {
|
||||
match event::handle_ws(st, &mut socket).await {
|
||||
#[allow(
|
||||
unreachable_patterns,
|
||||
reason = "compatibility before min_exhaustive_patterns"
|
||||
)]
|
||||
Ok(never) => match never {},
|
||||
Err(err) if err.is::<event::StreamEnded>() => {}
|
||||
Err(err) => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#![expect(clippy::unwrap_used, reason = "FIXME: random false positive")]
|
||||
#![expect(clippy::toplevel_ref_arg, reason = "easy to use for fixtures")]
|
||||
use std::fmt;
|
||||
use std::future::IntoFuture;
|
||||
use std::future::{Future, IntoFuture};
|
||||
use std::sync::{Arc, LazyLock};
|
||||
|
||||
use anyhow::Result;
|
||||
|
@ -144,7 +144,7 @@ async fn smoke(server: Server) {
|
|||
assert_eq!(got, exp);
|
||||
}
|
||||
|
||||
fn sign<T: Serialize>(key: &SigningKey, rng: &mut impl RngCore, payload: T) -> WithSig<T> {
|
||||
fn sign<T: Serialize>(key: &SigningKey, rng: &mut dyn RngCore, payload: T) -> WithSig<T> {
|
||||
WithSig::sign(key, get_timestamp(), rng, payload).unwrap()
|
||||
}
|
||||
|
||||
|
@ -152,13 +152,13 @@ fn auth(key: &SigningKey, rng: &mut impl RngCore) -> String {
|
|||
serde_json::to_string(&sign(key, rng, AuthPayload {})).unwrap()
|
||||
}
|
||||
|
||||
async fn create_room(
|
||||
server: &Server,
|
||||
fn create_room<'s>(
|
||||
server: &'s Server,
|
||||
key: &SigningKey,
|
||||
rng: &mut impl RngCore,
|
||||
rng: &mut dyn RngCore,
|
||||
attrs: RoomAttrs,
|
||||
title: impl fmt::Display,
|
||||
) -> Result<Id> {
|
||||
title: &str,
|
||||
) -> impl Future<Output = Result<Id>> + use<'s> {
|
||||
let req = sign(
|
||||
key,
|
||||
rng,
|
||||
|
@ -171,10 +171,12 @@ async fn create_room(
|
|||
title: title.to_string(),
|
||||
},
|
||||
);
|
||||
async move {
|
||||
Ok(server
|
||||
.request(Method::POST, "/room/create", None, Some(&req))
|
||||
.await?
|
||||
.unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
|
@ -202,13 +204,7 @@ async fn room_create_get(server: Server, ref mut rng: impl RngCore, #[case] publ
|
|||
room_meta.rid = rid;
|
||||
|
||||
// Bob has no permission.
|
||||
create_room(
|
||||
&server,
|
||||
&BOB_PRIV,
|
||||
rng,
|
||||
room_meta.attrs,
|
||||
room_meta.title.clone(),
|
||||
)
|
||||
create_room(&server, &BOB_PRIV, rng, room_meta.attrs, &room_meta.title)
|
||||
.await
|
||||
.expect_api_err(StatusCode::FORBIDDEN, "permission_denied");
|
||||
|
||||
|
|
23
flake.lock
generated
23
flake.lock
generated
|
@ -39,7 +39,28 @@
|
|||
"root": {
|
||||
"inputs": {
|
||||
"naersk": "naersk",
|
||||
"nixpkgs": "nixpkgs"
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1725935143,
|
||||
"narHash": "sha256-mVtTVQMlXkydSXVwFClE0ckxHrOQ9nb2DrCjNwW5pUE=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "c3c175c74cd0e8c2c40a0e22bc6e3005c4d28d64",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
28
flake.nix
28
flake.nix
|
@ -7,6 +7,10 @@ rec {
|
|||
url = "github:nix-community/naersk";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
rust-overlay = {
|
||||
url = "github:oxalica/rust-overlay";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
|
@ -14,6 +18,7 @@ rec {
|
|||
self,
|
||||
nixpkgs,
|
||||
naersk,
|
||||
rust-overlay,
|
||||
}:
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
|
@ -26,7 +31,13 @@ rec {
|
|||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
naersk' = pkgs.callPackage naersk { };
|
||||
rustBin = rust-overlay.lib.mkRustBin { } pkgs;
|
||||
toolchain = rustBin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||
naersk' = pkgs.callPackage naersk {
|
||||
cargo = toolchain;
|
||||
rustc = toolchain;
|
||||
};
|
||||
|
||||
mkPkg =
|
||||
{
|
||||
pkg-config,
|
||||
|
@ -75,6 +86,21 @@ rec {
|
|||
}
|
||||
);
|
||||
|
||||
devShells = eachSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
default = pkgs.mkShell {
|
||||
inputsFrom = [ self.packages.${system}.default ];
|
||||
nativeBuildInputs = [ pkgs.buildPackages.sqlite-interactive ];
|
||||
|
||||
env.RUST_LOG = "blahd=debug,blahctl=debug";
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
nixosModules = rec {
|
||||
default = blahd;
|
||||
blahd = import ./contrib/module.nix {
|
||||
|
|
7
rust-toolchain.toml
Normal file
7
rust-toolchain.toml
Normal file
|
@ -0,0 +1,7 @@
|
|||
# WAIT: Rust 1.82 release on 2024-10-17
|
||||
# Used features:
|
||||
# - min_exhaustive_patterns: https://github.com/rust-lang/rust/issues/119612
|
||||
# - precise_capturing: https://github.com/rust-lang/rust/issues/123432
|
||||
[toolchain]
|
||||
channel = "beta-2024-09-10" # 1.82.0-beta.3
|
||||
profile = "default"
|
|
@ -1,7 +0,0 @@
|
|||
with import <nixpkgs> { };
|
||||
mkShell {
|
||||
nativeBuildInputs = [ pkg-config sqlite-interactive ];
|
||||
buildInputs = [ openssl.dev sqlite.dev ];
|
||||
|
||||
env.RUST_LOG = "blahd=debug,blahctl=debug";
|
||||
}
|
Loading…
Add table
Reference in a new issue