From c544b85bd37ae6732c9ef1e0c2df20da89155ebc Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Mon, 22 Jul 2024 16:19:45 -0400 Subject: [PATCH] Move to cargo workspace --- .github/workflows/build.yaml | 2 +- Cargo.lock | 2 +- Cargo.toml | 36 ++----------------- orbit-server/Cargo.toml | 33 +++++++++++++++++ Dockerfile => orbit-server/Dockerfile | 0 build.rs => orbit-server/build.rs | 0 .../orbit.example.toml | 0 {src => orbit-server/src}/config.rs | 8 +++++ {src => orbit-server/src}/main.rs | 2 +- {src => orbit-server/src}/misc.rs | 0 {src => orbit-server/src}/routes/docs.rs | 0 {src => orbit-server/src}/routes/mod.rs | 0 {src => orbit-server/src}/routes/sites.rs | 0 {src => orbit-server/src}/routes/system.rs | 0 {src => orbit-server/src}/server.rs | 0 {src => orbit-server/src}/site.rs | 0 16 files changed, 47 insertions(+), 36 deletions(-) create mode 100644 orbit-server/Cargo.toml rename Dockerfile => orbit-server/Dockerfile (100%) rename build.rs => orbit-server/build.rs (100%) rename orbit.example.toml => orbit-server/orbit.example.toml (100%) rename {src => orbit-server/src}/config.rs (86%) rename {src => orbit-server/src}/main.rs (89%) rename {src => orbit-server/src}/misc.rs (100%) rename {src => orbit-server/src}/routes/docs.rs (100%) rename {src => orbit-server/src}/routes/mod.rs (100%) rename {src => orbit-server/src}/routes/sites.rs (100%) rename {src => orbit-server/src}/routes/system.rs (100%) rename {src => orbit-server/src}/server.rs (100%) rename {src => orbit-server/src}/site.rs (100%) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index fe2cc89..b5d4c8c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -42,8 +42,8 @@ jobs: with: push: true context: . - file: ./Dockerfile cache-from: type=gha cache-to: type=gha,mode=max + file: ./orbit-server/Dockerfile tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/Cargo.lock b/Cargo.lock index 5a496a4..48830c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1098,7 +1098,7 @@ dependencies = [ ] [[package]] -name = "orbit" +name = "orbit-server" version = "0.1.0" dependencies = [ "aide", diff --git a/Cargo.toml b/Cargo.toml index 45ea09b..f72ad63 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,33 +1,3 @@ -[package] -name = "orbit" -license = "MIT" -edition = "2021" -version = "0.1.0" -authors = ["Miguel Piedrafita "] - -[dependencies] -axum = "0.7.5" -http = "1.1.0" -tar = "0.4.41" -slug = "0.1.5" -toml = "0.8.15" -anyhow = "1.0.71" -serde = "1.0.165" -flate2 = "1.0.30" -indexmap = "2.2.6" -dotenvy = "0.15.7" -tracing = "0.1.37" -reqwest = "0.12.5" -schemars = "0.8.12" -thiserror = "1.0.63" -serde_json = "1.0.99" -futures-util = "0.3.30" -async-fn-stream = "0.2.2" -uuid = { version = "1.10.0", features = ["v7"] } -tokio = { version = "1.29.1", features = ["full"] } -aide = { version = "0.13.4", features = ["axum", "scalar"] } -axum-jsonschema = { version = "0.8.0", features = ["aide"] } -tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } - -[build-dependencies] -chrono = "0.4.26" +[workspace] +resolver = "2" +members = ["orbit-server"] diff --git a/orbit-server/Cargo.toml b/orbit-server/Cargo.toml new file mode 100644 index 0000000..430e136 --- /dev/null +++ b/orbit-server/Cargo.toml @@ -0,0 +1,33 @@ +[package] +license = "MIT" +edition = "2021" +version = "0.1.0" +name = "orbit-server" +authors = ["Miguel Piedrafita "] + +[dependencies] +axum = "0.7.5" +http = "1.1.0" +tar = "0.4.41" +slug = "0.1.5" +toml = "0.8.15" +anyhow = "1.0.71" +serde = "1.0.165" +flate2 = "1.0.30" +indexmap = "2.2.6" +dotenvy = "0.15.7" +tracing = "0.1.37" +reqwest = "0.12.5" +schemars = "0.8.12" +thiserror = "1.0.63" +serde_json = "1.0.99" +futures-util = "0.3.30" +async-fn-stream = "0.2.2" +uuid = { version = "1.10.0", features = ["v7"] } +tokio = { version = "1.29.1", features = ["full"] } +aide = { version = "0.13.4", features = ["axum", "scalar"] } +axum-jsonschema = { version = "0.8.0", features = ["aide"] } +tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } + +[build-dependencies] +chrono = "0.4.26" diff --git a/Dockerfile b/orbit-server/Dockerfile similarity index 100% rename from Dockerfile rename to orbit-server/Dockerfile diff --git a/build.rs b/orbit-server/build.rs similarity index 100% rename from build.rs rename to orbit-server/build.rs diff --git a/orbit.example.toml b/orbit-server/orbit.example.toml similarity index 100% rename from orbit.example.toml rename to orbit-server/orbit.example.toml diff --git a/src/config.rs b/orbit-server/src/config.rs similarity index 86% rename from src/config.rs rename to orbit-server/src/config.rs index e052791..75acb9f 100644 --- a/src/config.rs +++ b/orbit-server/src/config.rs @@ -32,6 +32,14 @@ impl Config { Ok(config) } + pub fn ensure_vars(self) -> Result { + if std::env::var("GITHUB_TOKEN").is_err() { + return Err(anyhow::anyhow!("GITHUB_TOKEN is not set")); + } + + Ok(self) + } + pub fn extension(self) -> Extension { Extension(Arc::new(self.sites)) } diff --git a/src/main.rs b/orbit-server/src/main.rs similarity index 89% rename from src/main.rs rename to orbit-server/src/main.rs index 4d0ebd6..a8abcc1 100644 --- a/src/main.rs +++ b/orbit-server/src/main.rs @@ -27,6 +27,6 @@ async fn main() -> Result<()> { ) .init(); - let config = Config::load(env::var("ORBIT_CONFIG")?)?; + let config = Config::load(env::var("ORBIT_CONFIG")?)?.ensure_vars()?; server::start(config).await } diff --git a/src/misc.rs b/orbit-server/src/misc.rs similarity index 100% rename from src/misc.rs rename to orbit-server/src/misc.rs diff --git a/src/routes/docs.rs b/orbit-server/src/routes/docs.rs similarity index 100% rename from src/routes/docs.rs rename to orbit-server/src/routes/docs.rs diff --git a/src/routes/mod.rs b/orbit-server/src/routes/mod.rs similarity index 100% rename from src/routes/mod.rs rename to orbit-server/src/routes/mod.rs diff --git a/src/routes/sites.rs b/orbit-server/src/routes/sites.rs similarity index 100% rename from src/routes/sites.rs rename to orbit-server/src/routes/sites.rs diff --git a/src/routes/system.rs b/orbit-server/src/routes/system.rs similarity index 100% rename from src/routes/system.rs rename to orbit-server/src/routes/system.rs diff --git a/src/server.rs b/orbit-server/src/server.rs similarity index 100% rename from src/server.rs rename to orbit-server/src/server.rs diff --git a/src/site.rs b/orbit-server/src/site.rs similarity index 100% rename from src/site.rs rename to orbit-server/src/site.rs