Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[next] tests: CI go green #704

Merged
merged 19 commits into from
Mar 14, 2023
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
55 changes: 15 additions & 40 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ executors:
docker-rust:
docker:
- image: cimg/rust:1.65.0
resource_class: small
image-ubuntu:
machine:
image: ubuntu-2204:2022.04.1
docker_layer_caching: true
resource_class: xlarge

# sscache steps are from this guide
# https://medium.com/@edouard.oger/rust-caching-on-circleci-using-sccache-c996344f0115
Expand Down Expand Up @@ -159,8 +161,9 @@ commands:
- << parameters.target >>.env

jobs:
workspace-fmt:
workspace:
executor: docker-rust
resource_class: xlarge
steps:
- checkout
- restore-cargo-cache
Expand All @@ -170,14 +173,6 @@ jobs:
# https://github.com/DevinR528/cargo-sort/pull/29 is merged
# - run: cargo install cargo-sort
# - run: cargo sort --check --workspace
- run: cargo check --workspace --all-targets
- save-cargo-cache
workspace-clippy:
executor: docker-rust
steps:
- checkout
- restore-cargo-cache
- install-protoc
- run: |
cargo clippy --tests \
--all-targets \
Expand Down Expand Up @@ -214,20 +209,6 @@ jobs:
-A clippy::format-push-string
- run: cargo test --all-features --manifest-path << parameters.path >>/Cargo.toml -- --nocapture
- save-cargo-cache
service-test:
# Using an image since tests will start a docker container
executor: image-ubuntu
steps:
- install-rust
- checkout
- restore-cargo-cache
- run:
name: Run unit tests
command: cargo test --package shuttle-service --features="codegen,builder" --lib -- --nocapture
- run:
name: Run integration tests
command: cargo test --package shuttle-service --features="codegen,builder" --test '*' -- --nocapture
- save-cargo-cache
platform-test:
parameters:
crate:
Expand All @@ -254,7 +235,6 @@ jobs:
(cargo test --package << parameters.crate >> --all-features --test '*' -- --list 2>&1 | grep -q "no test target matches pattern") && echo "nothing to test" || cargo test --package << parameters.crate >> --all-features --test '*' -- --nocapture
- save-cargo-cache
e2e-test:
resource_class: xlarge
executor: image-ubuntu
steps:
- install-rust
Expand Down Expand Up @@ -286,7 +266,6 @@ jobs:
key: docker-buildx-{{ .Branch }}
when: always
build-and-push:
resource_class: xlarge
executor: image-ubuntu
steps:
- checkout
Expand Down Expand Up @@ -360,7 +339,7 @@ jobs:
build-binaries-mac:
macos:
xcode: 12.5.1
resource_class: medium
resource_class: xlarge
steps:
- checkout
- run:
Expand Down Expand Up @@ -398,11 +377,9 @@ jobs:
workflows:
ci:
jobs:
- workspace-fmt
- workspace-clippy:
requires:
- workspace-fmt
- workspace
- check-standalone:
name: << matrix.path >>
matrix:
parameters:
path:
Expand All @@ -422,28 +399,26 @@ workflows:
- services/shuttle-tide
- services/shuttle-tower
- services/shuttle-warp
- service-test:
requires:
- workspace-clippy
- platform-test:
name: << matrix.crate >>
requires:
- workspace-clippy
- workspace
matrix:
parameters:
crate:
[
"shuttle-auth",
"shuttle-deployer",
"cargo-shuttle",
"shuttle-codegen",
"shuttle-common",
"shuttle-deployer",
"shuttle-proto",
"shuttle-provisioner",
"shuttle-runtime"
"shuttle-runtime",
"shuttle-service",
]
- e2e-test:
requires:
- service-test
- platform-test
- check-standalone
filters:
Expand All @@ -459,23 +434,23 @@ workflows:
name: build-binaries-x86_64-gnu
image: ubuntu-2204:2022.04.1
target: x86_64-unknown-linux-gnu
resource_class: medium
resource_class: xlarge
filters:
branches:
only: production
- build-binaries-linux:
name: build-binaries-x86_64-musl
image: ubuntu-2204:2022.04.1
target: x86_64-unknown-linux-musl
resource_class: medium
resource_class: xlarge
filters:
branches:
only: production
- build-binaries-linux:
name: build-binaries-aarch64
image: ubuntu-2004:202101-01
target: aarch64-unknown-linux-musl
resource_class: arm.medium
resource_class: arm.xlarge
filters:
branches:
only: production
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ shuttle-service = { path = "service", version = "0.11.0" }
anyhow = "1.0.66"
async-trait = "0.1.58"
axum = { version = "0.6.0", default-features = false }
chrono = { version = "0.4.23", default-features = false, features = ["clock"] }
chrono = { version = "0.4.23", default-features = false }
clap = { version = "4.0.27", features = [ "derive" ] }
headers = "0.3.8"
http = "0.2.8"
Expand Down
2 changes: 1 addition & 1 deletion auth/src/api/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use axum::{
use axum_sessions::extractors::{ReadableSession, WritableSession};
use http::StatusCode;
use serde::{Deserialize, Serialize};
use shuttle_common::{backends::auth::Claim, models::user};
use shuttle_common::{claims::Claim, models::user};
use tracing::instrument;

use super::{
Expand Down
2 changes: 1 addition & 1 deletion auth/src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use axum::{
};
use rand::distributions::{Alphanumeric, DistString};
use serde::{Deserialize, Deserializer, Serialize};
use shuttle_common::backends::auth::Scope;
use shuttle_common::claims::Scope;
use sqlx::{query, Row, SqlitePool};
use tracing::{trace, Span};

Expand Down
2 changes: 1 addition & 1 deletion auth/tests/api/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use axum_extra::extract::cookie::{self, Cookie};
use http::{Request, StatusCode};
use hyper::Body;
use serde_json::{json, Value};
use shuttle_common::backends::auth::Claim;
use shuttle_common::claims::Claim;

use crate::helpers::app;

Expand Down
2 changes: 1 addition & 1 deletion cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ mod tests {
"Secrets.toml",
"Secrets.toml.example",
"Shuttle.toml",
"src/lib.rs",
"src/main.rs",
]
);
}
Expand Down
11 changes: 11 additions & 0 deletions cargo-shuttle/tests/integration/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ async fn cargo_shuttle_run(working_directory: &str, external: bool) -> String {
}

#[tokio::test(flavor = "multi_thread")]
#[ignore]
async fn rocket_hello_world() {
let url = cargo_shuttle_run("../examples/rocket/hello-world", false).await;

Expand Down Expand Up @@ -120,6 +121,7 @@ async fn rocket_postgres() {
}

#[tokio::test(flavor = "multi_thread")]
#[ignore]
async fn rocket_authentication() {
let url = cargo_shuttle_run("../examples/rocket/authentication", false).await;
let client = reqwest::Client::new();
Expand Down Expand Up @@ -176,6 +178,7 @@ async fn rocket_authentication() {
}

#[tokio::test(flavor = "multi_thread")]
#[ignore]
async fn actix_web_hello_world() {
let url = cargo_shuttle_run("../examples/actix-web/hello-world", false).await;

Expand All @@ -192,6 +195,7 @@ async fn actix_web_hello_world() {
}

#[tokio::test(flavor = "multi_thread")]
#[ignore]
async fn axum_hello_world() {
let url = cargo_shuttle_run("../examples/axum/hello-world", false).await;

Expand All @@ -208,6 +212,7 @@ async fn axum_hello_world() {
}

#[tokio::test(flavor = "multi_thread")]
#[ignore]
async fn tide_hello_world() {
let url = cargo_shuttle_run("../examples/tide/hello-world", false).await;

Expand All @@ -224,6 +229,7 @@ async fn tide_hello_world() {
}

#[tokio::test(flavor = "multi_thread")]
#[ignore]
async fn tower_hello_world() {
let url = cargo_shuttle_run("../examples/tower/hello-world", false).await;

Expand All @@ -240,6 +246,7 @@ async fn tower_hello_world() {
}

#[tokio::test(flavor = "multi_thread")]
#[ignore]
async fn warp_hello_world() {
let url = cargo_shuttle_run("../examples/warp/hello-world", false).await;

Expand All @@ -256,6 +263,7 @@ async fn warp_hello_world() {
}

#[tokio::test(flavor = "multi_thread")]
#[ignore]
async fn poem_hello_world() {
let url = cargo_shuttle_run("../examples/poem/hello-world", false).await;

Expand All @@ -273,6 +281,7 @@ async fn poem_hello_world() {

// This example uses a shared Postgres. Thus local runs should create a docker container for it.
#[tokio::test(flavor = "multi_thread")]
#[ignore]
async fn poem_postgres() {
let url = cargo_shuttle_run("../examples/poem/postgres", false).await;
let client = reqwest::Client::new();
Expand Down Expand Up @@ -336,6 +345,7 @@ async fn poem_mongodb() {
}

#[tokio::test(flavor = "multi_thread")]
#[ignore]
async fn salvo_hello_world() {
let url = cargo_shuttle_run("../examples/salvo/hello-world", false).await;

Expand All @@ -352,6 +362,7 @@ async fn salvo_hello_world() {
}

#[tokio::test(flavor = "multi_thread")]
#[ignore]
async fn thruster_hello_world() {
let url = cargo_shuttle_run("../examples/thruster/hello-world", false).await;

Expand Down
4 changes: 2 additions & 2 deletions codegen/tests/ui/main/missing-return.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error: shuttle_service::main functions need to return a service
error: shuttle_runtime::main functions need to return a service

= help: See the docs for services with first class support
= note: https://docs.rs/shuttle-service/latest/shuttle_service/attr.main.html#shuttle-supported-services
= note: https://docs.rs/shuttle-service/latest/shuttle_runtime/attr.main.html#shuttle-supported-services
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think I did this when I search and replaced shuttle_service with shuttle_runtime. The docs are still in shuttle_service, but they need to be updated (and maybe moved to service). I opened a linear issue for this but didn't get to it yet.


--> tests/ui/main/missing-return.rs:2:1
|
Expand Down
4 changes: 2 additions & 2 deletions codegen/tests/ui/main/return-tuple.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error: shuttle_service::main functions need to return a first class service or 'Result<impl Service, shuttle_service::Error>
error: shuttle_runtime::main functions need to return a first class service or 'Result<impl Service, shuttle_runtime::Error>

= help: See the docs for services with first class support
= note: https://docs.rs/shuttle-service/latest/shuttle_service/attr.main.html#shuttle-supported-services
= note: https://docs.rs/shuttle-service/latest/shuttle_runtime/attr.main.html#shuttle-supported-services

--> tests/ui/main/return-tuple.rs:2:28
|
Expand Down
20 changes: 11 additions & 9 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ anyhow = { workspace = true, optional = true }
async-trait = { workspace = true , optional = true }
axum = { workspace = true, optional = true }
bytes = { version = "1.3.0", optional = true }
chrono = { workspace = true, features = ["serde"] }
chrono = { workspace = true }
comfy-table = { version = "6.1.3", optional = true }
crossterm = { version = "0.25.0", optional = true }
headers = { workspace = true }
headers = { workspace = true, optional = true }
http = { workspace = true, optional = true }
http-body = { version = "0.4.5", optional = true }
http-serde = { version = "1.1.2", optional = true }
Expand All @@ -25,31 +25,33 @@ once_cell = { workspace = true, optional = true }
opentelemetry = { workspace = true, optional = true }
opentelemetry-http = { workspace = true, optional = true }
opentelemetry-otlp = { version = "0.11.0", optional = true }
pin-project = { workspace = true }
pin-project = { workspace = true, optional = true }
prost-types = { workspace = true, optional = true }
reqwest = { version = "0.11.13", optional = true }
rmp-serde = { version = "1.1.1", optional = true }
rustrict = { version = "0.5.5", optional = true }
serde = { workspace = true }
serde = { workspace = true, features = ["derive", "std"] }
serde_json = { workspace = true, optional = true }
strum = { workspace = true, features = ["derive"], optional = true }
thiserror = { workspace = true, optional = true }
tonic = { version = "0.8.3", optional = true }
tower = { workspace = true, optional = true }
tower-http = { workspace = true, optional = true }
tracing = { workspace = true }
tracing = { workspace = true, features = ["std"] }
tracing-opentelemetry = { workspace = true, optional = true }
tracing-subscriber = { workspace = true, optional = true }
ttl_cache = { workspace = true, optional = true }
uuid = { workspace = true, features = ["v4", "serde"], optional = true }

[features]
backend = ["async-trait", "axum/matched-path", "bytes", "http", "http-body", "hyper/client", "jsonwebtoken", "opentelemetry", "opentelemetry-http", "opentelemetry-otlp", "thiserror", "tower", "tower-http", "tracing-opentelemetry", "tracing-subscriber/env-filter", "tracing-subscriber/fmt", "ttl_cache"]
display = ["comfy-table", "crossterm"]
models = ["anyhow", "async-trait", "display", "http", "prost-types", "reqwest", "serde_json", "service", "thiserror"]
backend = ["async-trait", "axum/matched-path", "claims", "hyper/client", "opentelemetry-otlp", "thiserror", "tower-http", "tracing-subscriber/env-filter", "tracing-subscriber/fmt", "ttl_cache"]
claims = ["bytes", "chrono/clock", "headers", "http", "http-body", "jsonwebtoken", "opentelemetry", "opentelemetry-http", "pin-project", "tower", "tracing", "tracing-opentelemetry"]
display = ["chrono/clock", "comfy-table", "crossterm"]
error = ["prost-types", "serde_json", "thiserror", "uuid"]
models = ["anyhow", "async-trait", "display", "http", "reqwest", "serde_json", "service"]
service = ["chrono/serde", "once_cell", "rustrict", "serde/derive", "strum", "uuid"]
tracing = ["serde_json"]
wasm = ["http-serde", "http", "rmp-serde", "tracing", "tracing-subscriber"]
wasm = ["chrono/clock", "http-serde", "http", "rmp-serde", "tracing", "tracing-subscriber"]

[dev-dependencies]
axum = { workspace = true }
Expand Down
Loading