Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
adb518fa0d | ||
|
|
f91216dd3c |
+14
-10
@@ -26,16 +26,19 @@ variables:
|
|||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- cargohome
|
- cargohome
|
||||||
- target/
|
key: "build_cache--$TARGET--$CI_COMMIT_BRANCH"
|
||||||
key: "build_cache--$TARGET--$CI_COMMIT_BRANCH--release"
|
|
||||||
variables:
|
variables:
|
||||||
CARGO_PROFILE_RELEASE_LTO: "true"
|
CARGO_PROFILE_RELEASE_LTO: "true"
|
||||||
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "1"
|
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "1"
|
||||||
|
CARGO_INCREMENTAL: "false" # https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
|
||||||
|
CARGO_HOME: $CI_PROJECT_DIR/cargohome
|
||||||
before_script:
|
before_script:
|
||||||
- 'echo "Building for target $TARGET"'
|
- 'echo "Building for target $TARGET"'
|
||||||
- 'mkdir -p cargohome && CARGOHOME="cargohome"'
|
- "mkdir -p $CARGO_HOME"
|
||||||
- "rustc --version && cargo --version && rustup show" # Print version info for debugging
|
- "rustc --version && cargo --version && rustup show" # Print version info for debugging
|
||||||
- "rustup target add $TARGET"
|
- "rustup target add $TARGET"
|
||||||
|
# If provided, bring in caching through sccache, which uses an external S3 endpoint to store compilation results:
|
||||||
|
- if [ -n "${SCCACHE_BIN_URL}" ]; then curl $SCCACHE_BIN_URL --output /sccache && chmod +x /sccache && export RUSTC_WRAPPER=/sccache; fi
|
||||||
script:
|
script:
|
||||||
- time cargo build --target $TARGET --release
|
- time cargo build --target $TARGET --release
|
||||||
- 'cp "target/$TARGET/release/conduit" "conduit-$TARGET"'
|
- 'cp "target/$TARGET/release/conduit" "conduit-$TARGET"'
|
||||||
@@ -216,20 +219,21 @@ test:cargo:
|
|||||||
image: "rust:latest"
|
image: "rust:latest"
|
||||||
tags: ["docker"]
|
tags: ["docker"]
|
||||||
variables:
|
variables:
|
||||||
CARGO_HOME: "cargohome"
|
CARGO_HOME: "$CI_PROJECT_DIR/cargohome"
|
||||||
|
CARGO_INCREMENTAL: "false" # https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- target
|
|
||||||
- cargohome
|
- cargohome
|
||||||
key: test_cache
|
key: "test_cache--$CI_COMMIT_BRANCH"
|
||||||
interruptible: true
|
interruptible: true
|
||||||
before_script:
|
before_script:
|
||||||
- mkdir -p $CARGO_HOME && echo "using $CARGO_HOME to cache cargo deps"
|
- mkdir -p $CARGO_HOME
|
||||||
- apt-get update -yqq
|
- apt-get update -yqq
|
||||||
- apt-get install -yqq --no-install-recommends build-essential libssl-dev pkg-config wget
|
- apt-get install -yqq --no-install-recommends build-essential libssl-dev pkg-config
|
||||||
- rustup component add clippy rustfmt
|
- rustup component add clippy rustfmt
|
||||||
- wget "https://faulty-storage.de/gitlab-report"
|
- curl "https://faulty-storage.de/gitlab-report" --output ./gitlab-report && chmod +x ./gitlab-report
|
||||||
- chmod +x ./gitlab-report
|
# If provided, bring in caching through sccache, which uses an external S3 endpoint to store compilation results:
|
||||||
|
- if [ -n "${SCCACHE_BIN_URL}" ]; then curl $SCCACHE_BIN_URL --output /sccache && chmod +x /sccache && export RUSTC_WRAPPER=/sccache; fi
|
||||||
script:
|
script:
|
||||||
- rustc --version && cargo --version # Print version info for debugging
|
- rustc --version && cargo --version # Print version info for debugging
|
||||||
- cargo fmt --all -- --check
|
- cargo fmt --all -- --check
|
||||||
|
|||||||
@@ -82,9 +82,6 @@ thread_local = "1.1.3"
|
|||||||
# used for TURN server authentication
|
# used for TURN server authentication
|
||||||
hmac = "0.11.0"
|
hmac = "0.11.0"
|
||||||
sha-1 = "0.9.8"
|
sha-1 = "0.9.8"
|
||||||
# used to embed Element Web into Conduit
|
|
||||||
rust-embed="6.3.0"
|
|
||||||
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["conduit_bin", "backend_sqlite"]
|
default = ["conduit_bin", "backend_sqlite"]
|
||||||
|
|||||||
+1
-38
@@ -17,15 +17,11 @@ mod pdu;
|
|||||||
mod ruma_wrapper;
|
mod ruma_wrapper;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
use std::ffi::OsStr;
|
|
||||||
use std::io::Cursor;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use database::Config;
|
use database::Config;
|
||||||
pub use database::Database;
|
pub use database::Database;
|
||||||
pub use error::{Error, Result};
|
pub use error::{Error, Result};
|
||||||
use http::StatusCode;
|
|
||||||
use opentelemetry::trace::{FutureExt, Tracer};
|
use opentelemetry::trace::{FutureExt, Tracer};
|
||||||
pub use pdu::PduEvent;
|
pub use pdu::PduEvent;
|
||||||
pub use rocket::State;
|
pub use rocket::State;
|
||||||
@@ -38,12 +34,8 @@ use rocket::{
|
|||||||
providers::{Env, Format, Toml},
|
providers::{Env, Format, Toml},
|
||||||
Figment,
|
Figment,
|
||||||
},
|
},
|
||||||
get,
|
routes, Request,
|
||||||
http::{ContentType, Status},
|
|
||||||
response, routes, Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use rust_embed::RustEmbed;
|
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
use tracing_subscriber::{prelude::*, EnvFilter};
|
use tracing_subscriber::{prelude::*, EnvFilter};
|
||||||
|
|
||||||
@@ -184,7 +176,6 @@ fn setup_rocket(config: Figment, data: Arc<RwLock<Database>>) -> rocket::Rocket<
|
|||||||
server_server::claim_keys_route,
|
server_server::claim_keys_route,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.mount("/", routes![dist])
|
|
||||||
.register(
|
.register(
|
||||||
"/",
|
"/",
|
||||||
catchers![
|
catchers![
|
||||||
@@ -285,34 +276,6 @@ async fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustEmbed)]
|
|
||||||
#[folder = "element_web"]
|
|
||||||
struct ElementWebAsset;
|
|
||||||
|
|
||||||
#[get("/<file..>")]
|
|
||||||
fn dist<'r>(file: PathBuf) -> response::Result<'r> {
|
|
||||||
let filename = file.display().to_string();
|
|
||||||
|
|
||||||
ElementWebAsset::get(&filename).map_or_else(
|
|
||||||
|| Err(Status::NotFound),
|
|
||||||
|embedded_file| {
|
|
||||||
let ext = file
|
|
||||||
.as_path()
|
|
||||||
.extension()
|
|
||||||
.and_then(OsStr::to_str)
|
|
||||||
.ok_or_else(|| Status::new(400))?;
|
|
||||||
|
|
||||||
let content_type = ContentType::from_extension(ext).ok_or_else(|| Status::new(400))?;
|
|
||||||
|
|
||||||
let response: Result<response::Response<'r>, Status> = response::Response::build()
|
|
||||||
.header(content_type)
|
|
||||||
.sized_body(embedded_file.data.len(), Cursor::new(embedded_file.data))
|
|
||||||
.ok();
|
|
||||||
return response;
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[catch(404)]
|
#[catch(404)]
|
||||||
fn not_found_catcher(_: &Request<'_>) -> String {
|
fn not_found_catcher(_: &Request<'_>) -> String {
|
||||||
"404 Not Found".to_owned()
|
"404 Not Found".to_owned()
|
||||||
|
|||||||
Reference in New Issue
Block a user