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:
oxalica 2024-09-10 06:22:56 -04:00
parent 7160e5adbd
commit 199985c6a2
8 changed files with 88 additions and 34 deletions

View file

@ -20,10 +20,10 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install Rust stable - name: Install Rust beta
run: | run: |
rustup update --no-self-update stable rustup update --no-self-update beta
rustup default stable rustup default beta
- name: Cache dependencies - name: Cache dependencies
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
@ -40,7 +40,7 @@ jobs:
test: test:
strategy: strategy:
matrix: matrix:
rust: [stable] rust: [stable, beta]
name: Test ${{ matrix.rust }} name: Test ${{ matrix.rust }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 15 timeout-minutes: 15
@ -48,11 +48,18 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Disable high-priority rust-toolchain.toml
run: rm rust-toolchain.toml
- name: Install Rust ${{ matrix.rust }} - name: Install Rust ${{ matrix.rust }}
run: | run: |
rustup update --no-self-update ${{ matrix.rust }} rustup update --no-self-update ${{ matrix.rust }}
rustup default ${{ 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 - name: Cache Dependencies
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2

View file

@ -8,7 +8,7 @@ members = [
default-members = ["blahd"] default-members = ["blahd"]
[workspace.lints.clippy] [workspace.lints.clippy]
allow_attributes = "warn" allow_attributes_without_reason = "warn"
dbg_macro = "warn" dbg_macro = "warn"
print_stderr = "warn" print_stderr = "warn"
print_stdout = "warn" print_stdout = "warn"

View file

@ -119,6 +119,10 @@ type RE<T> = R<T, ApiError>;
async fn handle_ws(State(st): ArcState, ws: WebSocketUpgrade) -> Response { async fn handle_ws(State(st): ArcState, ws: WebSocketUpgrade) -> Response {
ws.on_upgrade(move |mut socket| async move { ws.on_upgrade(move |mut socket| async move {
match event::handle_ws(st, &mut socket).await { match event::handle_ws(st, &mut socket).await {
#[allow(
unreachable_patterns,
reason = "compatibility before min_exhaustive_patterns"
)]
Ok(never) => match never {}, Ok(never) => match never {},
Err(err) if err.is::<event::StreamEnded>() => {} Err(err) if err.is::<event::StreamEnded>() => {}
Err(err) => { Err(err) => {

View file

@ -1,7 +1,7 @@
#![expect(clippy::unwrap_used, reason = "FIXME: random false positive")] #![expect(clippy::unwrap_used, reason = "FIXME: random false positive")]
#![expect(clippy::toplevel_ref_arg, reason = "easy to use for fixtures")] #![expect(clippy::toplevel_ref_arg, reason = "easy to use for fixtures")]
use std::fmt; use std::fmt;
use std::future::IntoFuture; use std::future::{Future, IntoFuture};
use std::sync::{Arc, LazyLock}; use std::sync::{Arc, LazyLock};
use anyhow::Result; use anyhow::Result;
@ -144,7 +144,7 @@ async fn smoke(server: Server) {
assert_eq!(got, exp); 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() 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() serde_json::to_string(&sign(key, rng, AuthPayload {})).unwrap()
} }
async fn create_room( fn create_room<'s>(
server: &Server, server: &'s Server,
key: &SigningKey, key: &SigningKey,
rng: &mut impl RngCore, rng: &mut dyn RngCore,
attrs: RoomAttrs, attrs: RoomAttrs,
title: impl fmt::Display, title: &str,
) -> Result<Id> { ) -> impl Future<Output = Result<Id>> + use<'s> {
let req = sign( let req = sign(
key, key,
rng, rng,
@ -171,10 +171,12 @@ async fn create_room(
title: title.to_string(), title: title.to_string(),
}, },
); );
async move {
Ok(server Ok(server
.request(Method::POST, "/room/create", None, Some(&req)) .request(Method::POST, "/room/create", None, Some(&req))
.await? .await?
.unwrap()) .unwrap())
}
} }
#[rstest] #[rstest]
@ -202,13 +204,7 @@ async fn room_create_get(server: Server, ref mut rng: impl RngCore, #[case] publ
room_meta.rid = rid; room_meta.rid = rid;
// Bob has no permission. // Bob has no permission.
create_room( create_room(&server, &BOB_PRIV, rng, room_meta.attrs, &room_meta.title)
&server,
&BOB_PRIV,
rng,
room_meta.attrs,
room_meta.title.clone(),
)
.await .await
.expect_api_err(StatusCode::FORBIDDEN, "permission_denied"); .expect_api_err(StatusCode::FORBIDDEN, "permission_denied");

23
flake.lock generated
View file

@ -39,7 +39,28 @@
"root": { "root": {
"inputs": { "inputs": {
"naersk": "naersk", "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"
} }
} }
}, },

View file

@ -7,6 +7,10 @@ rec {
url = "github:nix-community/naersk"; url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
outputs = outputs =
@ -14,6 +18,7 @@ rec {
self, self,
nixpkgs, nixpkgs,
naersk, naersk,
rust-overlay,
}: }:
let let
inherit (nixpkgs) lib; inherit (nixpkgs) lib;
@ -26,7 +31,13 @@ rec {
system: system:
let let
pkgs = nixpkgs.legacyPackages.${system}; 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 = mkPkg =
{ {
pkg-config, 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 { nixosModules = rec {
default = blahd; default = blahd;
blahd = import ./contrib/module.nix { blahd = import ./contrib/module.nix {

7
rust-toolchain.toml Normal file
View 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"

View file

@ -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";
}