Caching?
This commit is contained in:
parent
3a89f4ccbe
commit
685b9228be
|
@ -7,31 +7,74 @@ jobs:
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: alejandra -c .
|
- name: alejandra -c .
|
||||||
run: 'nix develop -c alejandra -c .'
|
run: 'nix develop -c alejandra -c .'
|
||||||
|
|
||||||
build:
|
build:
|
||||||
runs-on: beefcake
|
runs-on: beefcake
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Cache
|
||||||
|
id: cache-build
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: target
|
||||||
|
key: ${{ runner.os }}-build
|
||||||
|
|
||||||
- name: cargo build
|
- name: cargo build
|
||||||
run: 'nix develop -c cargo build'
|
run: 'nix develop -c cargo build'
|
||||||
|
|
||||||
test:
|
test:
|
||||||
runs-on: beefcake
|
runs-on: beefcake
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Cache
|
||||||
|
id: cache-test
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: target
|
||||||
|
key: ${{ runner.os }}-test
|
||||||
|
|
||||||
|
- name: Cache
|
||||||
|
id: cache-test
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: prime-numbers
|
||||||
|
key: ${{ runner.os }}-build
|
||||||
|
|
||||||
- name: cargo test
|
- name: cargo test
|
||||||
run: 'nix develop -c cargo test'
|
run: 'nix develop -c cargo test'
|
||||||
|
|
||||||
formatting-rust:
|
formatting-rust:
|
||||||
runs-on: beefcake
|
runs-on: beefcake
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Cache
|
||||||
|
id: cache-formatting
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: target
|
||||||
|
key: ${{ runner.os }}-formatting
|
||||||
|
|
||||||
- name: cargo fmt --check
|
- name: cargo fmt --check
|
||||||
run: 'nix develop -c cargo fmt --check'
|
run: 'nix develop -c cargo fmt --check'
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
runs-on: beefcake
|
runs-on: beefcake
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Cache
|
||||||
|
id: cache-lint
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: target
|
||||||
|
key: ${{ runner.os }}-lint
|
||||||
|
|
||||||
- name: cargo clippy
|
- name: cargo clippy
|
||||||
run: 'nix develop -c cargo clippy'
|
run: 'nix develop -c cargo clippy'
|
||||||
|
|
16
Cargo.toml
16
Cargo.toml
|
@ -3,11 +3,23 @@ resolver = "2"
|
||||||
members = ["apps/yourcloud"]
|
members = ["apps/yourcloud"]
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread"] }
|
|
||||||
http_client = { path = "libs/http_client" }
|
http_client = { path = "libs/http_client" }
|
||||||
discord_bot = { path = "libs/discord_bot" }
|
discord_bot = { path = "libs/discord_bot" }
|
||||||
|
|
||||||
|
tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread"] }
|
||||||
thiserror = "1.0.63"
|
thiserror = "1.0.63"
|
||||||
tracing = "0.1.40"
|
tracing = "0.1.40"
|
||||||
|
|
||||||
[profile.dev.package.backtrace]
|
[profile.dev]
|
||||||
|
opt-level = 1
|
||||||
|
|
||||||
|
[profile.dev.package."*"]
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
strip = true
|
||||||
|
opt-level = "z"
|
||||||
|
lto = true
|
||||||
|
codegen-units = 1
|
||||||
|
panic = "abort"
|
||||||
|
|
2916
apps/yourcloud/Cargo.lock
generated
2916
apps/yourcloud/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -21,16 +21,3 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||||
urlencoding = "2.1.3"
|
urlencoding = "2.1.3"
|
||||||
http_client = { workspace = true }
|
http_client = { workspace = true }
|
||||||
discord_bot = { workspace = true }
|
discord_bot = { workspace = true }
|
||||||
|
|
||||||
[profile.dev]
|
|
||||||
opt-level = 1
|
|
||||||
|
|
||||||
[profile.dev.package."*"]
|
|
||||||
opt-level = 3
|
|
||||||
|
|
||||||
[profile.release]
|
|
||||||
strip = true
|
|
||||||
opt-level = "z"
|
|
||||||
lto = true
|
|
||||||
codegen-units = 1
|
|
||||||
panic = "abort"
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ mod prelude;
|
||||||
mod webserver;
|
mod webserver;
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
use tokio::task::JoinSet;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
|
@ -20,20 +21,12 @@ async fn main() -> Result<()> {
|
||||||
};
|
};
|
||||||
debug!("Configuration: {conf:?}");
|
debug!("Configuration: {conf:?}");
|
||||||
|
|
||||||
let mut set = tokio::task::JoinSet::new();
|
let mut joinset: JoinSet<Result<()>> = JoinSet::new();
|
||||||
|
|
||||||
set.spawn(webserver::start(conf.clone()));
|
joinset.spawn(webserver::start());
|
||||||
|
maybe_start_discord_bot(conf.clone(), &mut joinset);
|
||||||
|
|
||||||
if let Some(bot_token) = conf
|
let result = joinset.join_next().await;
|
||||||
.clone()
|
|
||||||
.discord
|
|
||||||
.clone()
|
|
||||||
.map(|d| d.bot_token.expose_secret().clone())
|
|
||||||
{
|
|
||||||
set.spawn(async move { discord_bot::start(&bot_token).await.map_err(|e| e.into()) });
|
|
||||||
}
|
|
||||||
|
|
||||||
let result = set.join_next().await;
|
|
||||||
match result {
|
match result {
|
||||||
Some(Err(err)) => {
|
Some(Err(err)) => {
|
||||||
error!("One of the JoinSet tasks encountered a JoinError: {err}");
|
error!("One of the JoinSet tasks encountered a JoinError: {err}");
|
||||||
|
@ -48,3 +41,14 @@ async fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn maybe_start_discord_bot(conf: Arc<Config>, joinset: &mut JoinSet<Result<()>>) {
|
||||||
|
if let Some(bot_token) = conf
|
||||||
|
.clone()
|
||||||
|
.discord
|
||||||
|
.clone()
|
||||||
|
.map(|d| d.bot_token.expose_secret().clone())
|
||||||
|
{
|
||||||
|
joinset.spawn(async move { discord_bot::start(&bot_token).await.map_err(|e| e.into()) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ use crate::{minecraft_server_status::MinecraftServerStatus, prelude::*};
|
||||||
struct WebserverError(Report);
|
struct WebserverError(Report);
|
||||||
type WebserverResult<T> = std::result::Result<T, WebserverError>;
|
type WebserverResult<T> = std::result::Result<T, WebserverError>;
|
||||||
|
|
||||||
pub async fn start(_conf: Arc<Config>) -> Result<()> {
|
pub async fn start() -> Result<()> {
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.route("/", get(hello_world))
|
.route("/", get(hello_world))
|
||||||
.route("/health", get(health))
|
.route("/health", get(health))
|
||||||
|
|
Loading…
Reference in a new issue