From f7caa73b6bd1dd44f9a01ff7d05761aea23629a2 Mon Sep 17 00:00:00 2001 From: iamwacko Date: Fri, 2 Jun 2023 09:06:58 -0700 Subject: [PATCH 01/15] ci: pin 1.70 --- .circleci/config.yml | 23 +++++------------------ Makefile | 2 +- shell.nix | 2 +- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1ecab1ad7..2cb4f947b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ orbs: executors: docker-rust: docker: - - image: cimg/rust:1.68.0 + - image: cimg/rust:1.70.0 resource_class: small image-ubuntu: machine: @@ -172,8 +172,6 @@ jobs: workspace: executor: docker-rust resource_class: xlarge - environment: - CARGO_REGISTRIES_CRATES_IO_PROTOCOL: "sparse" steps: - checkout - restore-cargo-cache @@ -206,8 +204,6 @@ jobs: type: string default: --all-features executor: docker-rust - environment: - CARGO_REGISTRIES_CRATES_IO_PROTOCOL: "sparse" steps: - checkout - restore-cargo-cache @@ -255,8 +251,6 @@ jobs: - save-cargo-cache e2e-test: executor: image-ubuntu - environment: - CARGO_REGISTRIES_CRATES_IO_PROTOCOL: "sparse" steps: - install-rust - checkout @@ -288,8 +282,6 @@ jobs: when: always build-and-push: executor: image-ubuntu - environment: - CARGO_REGISTRIES_CRATES_IO_PROTOCOL: "sparse" parameters: aws-access-key-id: description: "AWS cli access key id" @@ -375,8 +367,6 @@ jobs: machine: image: << parameters.image >> resource_class: << parameters.resource_class >> - environment: - CARGO_REGISTRIES_CRATES_IO_PROTOCOL: "sparse" parameters: target: description: "Linux target to build for" @@ -392,7 +382,7 @@ jobs: - run: sudo apt update && sudo DEBIAN_FRONTEND=noninteractive apt install -y libssl-dev musl-tools clang - run: name: Install Rust - command: curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain 1.68.0 --target << parameters.target >> + command: curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain 1.70.0 --target << parameters.target >> - run: name: Build command: | @@ -409,7 +399,6 @@ jobs: shell: bash.exe environment: CARGO_NET_GIT_FETCH_WITH_CLI: "true" - CARGO_REGISTRIES_CRATES_IO_PROTOCOL: "sparse" steps: - checkout - run: choco install -y strawberryperl @@ -417,7 +406,7 @@ jobs: name: Install Rust command: | wget -OutFile "C:\rustup-init.exe" https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe - C:\rustup-init.exe -y --default-toolchain 1.68.0 --target x86_64-pc-windows-msvc + C:\rustup-init.exe -y --default-toolchain 1.70.0 --target x86_64-pc-windows-msvc shell: powershell.exe - run: name: Build @@ -435,13 +424,11 @@ jobs: macos: xcode: 12.5.1 resource_class: medium - environment: - CARGO_REGISTRIES_CRATES_IO_PROTOCOL: "sparse" steps: - checkout - run: name: Install Rust - command: curl --proto '=https' https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain 1.68.0 --target x86_64-apple-darwin + command: curl --proto '=https' https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain 1.70.0 --target x86_64-apple-darwin - run: name: Build command: | @@ -555,7 +542,7 @@ jobs: name: Install Rust command: | wget -OutFile "C:\rustup-init.exe" https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe - C:\rustup-init.exe -y --default-toolchain 1.68.0 --target x86_64-pc-windows-msvc + C:\rustup-init.exe -y --default-toolchain 1.70.0 --target x86_64-pc-windows-msvc - run: name: "Install Shuttle" command: ..\.cargo\bin\cargo.exe install cargo-shuttle --path ./cargo-shuttle diff --git a/Makefile b/Makefile index 5478c46f0..497236c9f 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ BUILDX_FLAGS=$(BUILDX_OP) $(PLATFORM_FLAGS) $(CACHE_FLAGS) # the rust version used by our containers, and as an override for our deployers # ensuring all user crates are compiled with the same rustc toolchain -RUSTUP_TOOLCHAIN=1.68.0 +RUSTUP_TOOLCHAIN=1.70.0 TAG?=$(shell git describe --tags) BACKEND_TAG?=$(TAG) diff --git a/shell.nix b/shell.nix index 67bb5365b..ad2da2b90 100644 --- a/shell.nix +++ b/shell.nix @@ -11,7 +11,7 @@ in pkg-config ]; buildInputs = with nixpkgs; [ - ((rustChannelOf{ channel = "1.68.0"; }).rust.override { + ((rustChannelOf{ channel = "1.70.0"; }).rust.override { extensions = ["rust-src"]; targets = ["wasm32-wasi"]; }) From 9b550fb720e03003f61382b47c5051eab43b3c12 Mon Sep 17 00:00:00 2001 From: iamwacko Date: Fri, 2 Jun 2023 09:28:54 -0700 Subject: [PATCH 02/15] feat: replace OnceCell with std::sync::OnceCell --- common/src/project.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/project.rs b/common/src/project.rs index 5846de6f8..7bd851ac2 100644 --- a/common/src/project.rs +++ b/common/src/project.rs @@ -1,4 +1,4 @@ -use once_cell::sync::OnceCell; +use std::sync::OnceCell; use rustrict::{Censor, Type}; use serde::de::Error as DeError; use serde::{Deserialize, Deserializer, Serialize}; From b44d2b7eb4c3f78001ec144803dd80601dda07f3 Mon Sep 17 00:00:00 2001 From: iamwacko Date: Fri, 2 Jun 2023 15:05:39 -0700 Subject: [PATCH 03/15] feat: removed once_cell dependency from common (but this commit is actually just to trigger CI) --- common/Cargo.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/Cargo.toml b/common/Cargo.toml index 5a8009352..fd3a1d462 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -20,7 +20,6 @@ http-body = { version = "0.4.5", optional = true } http-serde = { version = "1.1.2", optional = true } hyper = { workspace = true, optional = true } jsonwebtoken = { workspace = true, optional = true } -once_cell = { workspace = true, optional = true } opentelemetry = { workspace = true, optional = true } opentelemetry-http = { workspace = true, optional = true } opentelemetry-otlp = { version = "0.12.0", optional = true } @@ -77,7 +76,7 @@ error = ["prost-types", "thiserror", "uuid"] openapi = ["utoipa/chrono", "utoipa/uuid"] models = ["async-trait", "display", "http", "reqwest", "service"] persist = ["sqlx/sqlite", "rand"] -service = ["chrono/serde", "once_cell", "rustrict", "serde/derive", "uuid"] +service = ["chrono/serde", "rustrict", "serde/derive", "uuid"] tracing = [] wasm = [ "chrono/clock", From 74e7906d3ae7ebb9b7856b1135d871d5f3100c13 Mon Sep 17 00:00:00 2001 From: iamwacko Date: Fri, 2 Jun 2023 15:10:50 -0700 Subject: [PATCH 04/15] fix: cargo fmt --- common/src/project.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/project.rs b/common/src/project.rs index 7bd851ac2..b3ddb3916 100644 --- a/common/src/project.rs +++ b/common/src/project.rs @@ -1,4 +1,3 @@ -use std::sync::OnceCell; use rustrict::{Censor, Type}; use serde::de::Error as DeError; use serde::{Deserialize, Deserializer, Serialize}; @@ -6,6 +5,7 @@ use std::collections::HashSet; use std::error::Error; use std::fmt::{Display, Formatter}; use std::str::FromStr; +use std::sync::OnceCell; /// Project names should conform to valid Host segments (or labels) /// as per [IETF RFC 1123](https://datatracker.ietf.org/doc/html/rfc1123). From 1f93f3143c5f97574427d0168bc66a446eb2e632 Mon Sep 17 00:00:00 2001 From: iamwacko Date: Fri, 2 Jun 2023 15:13:06 -0700 Subject: [PATCH 05/15] fix: typo --- Cargo.lock | 1 - common/src/project.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 29c733920..9bafefa62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5306,7 +5306,6 @@ dependencies = [ "http-serde", "hyper", "jsonwebtoken", - "once_cell", "opentelemetry", "opentelemetry-http", "opentelemetry-otlp", diff --git a/common/src/project.rs b/common/src/project.rs index b3ddb3916..6fd8c08da 100644 --- a/common/src/project.rs +++ b/common/src/project.rs @@ -1,11 +1,11 @@ use rustrict::{Censor, Type}; use serde::de::Error as DeError; use serde::{Deserialize, Deserializer, Serialize}; +use std::cell::OnceCell; use std::collections::HashSet; use std::error::Error; use std::fmt::{Display, Formatter}; use std::str::FromStr; -use std::sync::OnceCell; /// Project names should conform to valid Host segments (or labels) /// as per [IETF RFC 1123](https://datatracker.ietf.org/doc/html/rfc1123). From 3304bb870e1d59a0e2e62ad8f50bd6411aad478a Mon Sep 17 00:00:00 2001 From: iamwacko Date: Fri, 2 Jun 2023 15:43:22 -0700 Subject: [PATCH 06/15] fix: more typos --- common/src/project.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/project.rs b/common/src/project.rs index 6fd8c08da..c665d1018 100644 --- a/common/src/project.rs +++ b/common/src/project.rs @@ -1,11 +1,11 @@ use rustrict::{Censor, Type}; use serde::de::Error as DeError; use serde::{Deserialize, Deserializer, Serialize}; -use std::cell::OnceCell; use std::collections::HashSet; use std::error::Error; use std::fmt::{Display, Formatter}; use std::str::FromStr; +use std::sync::OnceLock; /// Project names should conform to valid Host segments (or labels) /// as per [IETF RFC 1123](https://datatracker.ietf.org/doc/html/rfc1123). @@ -47,7 +47,7 @@ impl ProjectName { } fn is_reserved(hostname: &str) -> bool { - static INSTANCE: OnceCell> = OnceCell::new(); + static INSTANCE: OnceLock> = OnceLock::new(); INSTANCE.get_or_init(|| HashSet::from(["shuttle.rs"])); INSTANCE From 7e625de9065ecaa093625e34938d43965d9dcb18 Mon Sep 17 00:00:00 2001 From: iamwacko Date: Fri, 2 Jun 2023 16:19:24 -0700 Subject: [PATCH 07/15] fix: typo --- deployer/src/deployment/queue.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployer/src/deployment/queue.rs b/deployer/src/deployment/queue.rs index dea422462..4c2fd2a41 100644 --- a/deployer/src/deployment/queue.rs +++ b/deployer/src/deployment/queue.rs @@ -381,7 +381,7 @@ async fn run_pre_deploy_tests( let stdout_reader = BufReader::new(stdout); stdout_reader .lines() - .filter_map(|line| line.ok()) + .map_while(Result::ok) .for_each(|line| { if let Err(error) = write.send(format!("{}\n", line.trim_end_matches('\n'))) { error!("failed to send line to pipe: {error}"); From d25af1a15b0909502baa94520643637ea6be5f41 Mon Sep 17 00:00:00 2001 From: iamwacko Date: Fri, 2 Jun 2023 17:00:52 -0700 Subject: [PATCH 08/15] fix: clippy --- deployer/src/deployment/queue.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployer/src/deployment/queue.rs b/deployer/src/deployment/queue.rs index 4c2fd2a41..ed43962bd 100644 --- a/deployer/src/deployment/queue.rs +++ b/deployer/src/deployment/queue.rs @@ -381,7 +381,7 @@ async fn run_pre_deploy_tests( let stdout_reader = BufReader::new(stdout); stdout_reader .lines() - .map_while(Result::ok) + .map_while(|line| line.ok()) .for_each(|line| { if let Err(error) = write.send(format!("{}\n", line.trim_end_matches('\n'))) { error!("failed to send line to pipe: {error}"); From 2b88da7aa2231c5ebcb5170baefd93d7ce96116f Mon Sep 17 00:00:00 2001 From: iamwacko Date: Fri, 2 Jun 2023 18:49:10 -0700 Subject: [PATCH 09/15] fix: clippy allow --- deployer/src/deployment/queue.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deployer/src/deployment/queue.rs b/deployer/src/deployment/queue.rs index ed43962bd..1be9de7e1 100644 --- a/deployer/src/deployment/queue.rs +++ b/deployer/src/deployment/queue.rs @@ -379,9 +379,10 @@ async fn run_pre_deploy_tests( let stdout = cmd.stdout.take().unwrap(); let stdout_reader = BufReader::new(stdout); + #[allow(clippy::lines_filter_map_ok)] stdout_reader .lines() - .map_while(|line| line.ok()) + .filter_map(|line| line.ok()) .for_each(|line| { if let Err(error) = write.send(format!("{}\n", line.trim_end_matches('\n'))) { error!("failed to send line to pipe: {error}"); From d2e7a2699eec0b383a49dcbb72bb9a6092bac08b Mon Sep 17 00:00:00 2001 From: iamwacko Date: Fri, 2 Jun 2023 19:30:11 -0700 Subject: [PATCH 10/15] fix: change std::sync::OnceLock back to once_cell to check if that is what is causing Rocket to fail --- Cargo.lock | 1 + common/Cargo.toml | 3 ++- common/src/project.rs | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9bafefa62..29c733920 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5306,6 +5306,7 @@ dependencies = [ "http-serde", "hyper", "jsonwebtoken", + "once_cell", "opentelemetry", "opentelemetry-http", "opentelemetry-otlp", diff --git a/common/Cargo.toml b/common/Cargo.toml index fd3a1d462..6af075944 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -35,6 +35,7 @@ strum = { workspace = true, features = ["derive"] } sqlx = { workspace = true, optional = true, features = ["runtime-tokio-native-tls"] } thiserror = { workspace = true, optional = true } tonic = { workspace = true, optional = true } +once_cell = { workspace = true, optional = true } tower = { workspace = true, optional = true } tower-http = { workspace = true, optional = true } tracing = { workspace = true, features = ["std"] } @@ -76,7 +77,7 @@ error = ["prost-types", "thiserror", "uuid"] openapi = ["utoipa/chrono", "utoipa/uuid"] models = ["async-trait", "display", "http", "reqwest", "service"] persist = ["sqlx/sqlite", "rand"] -service = ["chrono/serde", "rustrict", "serde/derive", "uuid"] +service = ["chrono/serde", "once_cell", "rustrict", "serde/derive", "uuid"] tracing = [] wasm = [ "chrono/clock", diff --git a/common/src/project.rs b/common/src/project.rs index c665d1018..ac9121f79 100644 --- a/common/src/project.rs +++ b/common/src/project.rs @@ -5,7 +5,7 @@ use std::collections::HashSet; use std::error::Error; use std::fmt::{Display, Formatter}; use std::str::FromStr; -use std::sync::OnceLock; +use once_cell::sync::OnceCell; /// Project names should conform to valid Host segments (or labels) /// as per [IETF RFC 1123](https://datatracker.ietf.org/doc/html/rfc1123). @@ -47,7 +47,7 @@ impl ProjectName { } fn is_reserved(hostname: &str) -> bool { - static INSTANCE: OnceLock> = OnceLock::new(); + static INSTANCE: OnceCell> = OnceCell::new(); INSTANCE.get_or_init(|| HashSet::from(["shuttle.rs"])); INSTANCE From 26251bfb3ec12ddd7fc9330d50a0ff76fd18dc6c Mon Sep 17 00:00:00 2001 From: iamwacko Date: Fri, 2 Jun 2023 19:31:38 -0700 Subject: [PATCH 11/15] fix: cargo cmt --- common/src/project.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/project.rs b/common/src/project.rs index ac9121f79..5846de6f8 100644 --- a/common/src/project.rs +++ b/common/src/project.rs @@ -1,3 +1,4 @@ +use once_cell::sync::OnceCell; use rustrict::{Censor, Type}; use serde::de::Error as DeError; use serde::{Deserialize, Deserializer, Serialize}; @@ -5,7 +6,6 @@ use std::collections::HashSet; use std::error::Error; use std::fmt::{Display, Formatter}; use std::str::FromStr; -use once_cell::sync::OnceCell; /// Project names should conform to valid Host segments (or labels) /// as per [IETF RFC 1123](https://datatracker.ietf.org/doc/html/rfc1123). From 978c068f2f9e4f118862ae82370118eda4ffee2b Mon Sep 17 00:00:00 2001 From: iamwacko Date: Sat, 3 Jun 2023 16:27:43 -0700 Subject: [PATCH 12/15] fix: add default toolchain option --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2cb4f947b..f5bc48658 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -115,7 +115,7 @@ commands: - run: name: Install Rust command: | - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --target add wasm32-wasi + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.70.o --target add wasm32-wasi sudo apt update && sudo apt install -y libssl1.1 install-protoc: parameters: From 89871923fc2992ae1d05395e4818c3557a2b5055 Mon Sep 17 00:00:00 2001 From: iamwacko Date: Sat, 3 Jun 2023 16:57:04 -0700 Subject: [PATCH 13/15] fix: typo --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f5bc48658..28b52d163 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -115,7 +115,7 @@ commands: - run: name: Install Rust command: | - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.70.o --target add wasm32-wasi + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.70.0 --target add wasm32-wasi sudo apt update && sudo apt install -y libssl1.1 install-protoc: parameters: From 845c8892ccf04056fe63f10818d6c0eff5886669 Mon Sep 17 00:00:00 2001 From: iamwacko Date: Mon, 5 Jun 2023 11:50:09 -0700 Subject: [PATCH 14/15] fix: refactor BufReader writing to not ignore clippy warning --- deployer/src/deployment/queue.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/deployer/src/deployment/queue.rs b/deployer/src/deployment/queue.rs index 1be9de7e1..2ec46ff83 100644 --- a/deployer/src/deployment/queue.rs +++ b/deployer/src/deployment/queue.rs @@ -379,15 +379,13 @@ async fn run_pre_deploy_tests( let stdout = cmd.stdout.take().unwrap(); let stdout_reader = BufReader::new(stdout); - #[allow(clippy::lines_filter_map_ok)] - stdout_reader - .lines() - .filter_map(|line| line.ok()) - .for_each(|line| { + for line in stdout_reader.lines() { + if let Ok(line) = line { if let Err(error) = write.send(format!("{}\n", line.trim_end_matches('\n'))) { - error!("failed to send line to pipe: {error}"); + error!("failed to send to pipe: {error}"); } - }); + } + } if cmd.wait().map_err(TestError::Run)?.success() { Ok(()) From a0603f63536d68d2a9148ec52da84750f421c91d Mon Sep 17 00:00:00 2001 From: iamwacko Date: Tue, 6 Jun 2023 09:17:19 -0700 Subject: [PATCH 15/15] fix: unecessary if...let --- deployer/src/deployment/queue.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/deployer/src/deployment/queue.rs b/deployer/src/deployment/queue.rs index 2ec46ff83..4a0d0d08a 100644 --- a/deployer/src/deployment/queue.rs +++ b/deployer/src/deployment/queue.rs @@ -379,11 +379,9 @@ async fn run_pre_deploy_tests( let stdout = cmd.stdout.take().unwrap(); let stdout_reader = BufReader::new(stdout); - for line in stdout_reader.lines() { - if let Ok(line) = line { - if let Err(error) = write.send(format!("{}\n", line.trim_end_matches('\n'))) { - error!("failed to send to pipe: {error}"); - } + for line in stdout_reader.lines().flatten() { + if let Err(error) = write.send(format!("{}\n", line.trim_end_matches('\n'))) { + error!("failed to send to pipe: {error}"); } }