@@ -9,14 +9,14 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Important for git describe --tags
|
fetch-depth: 0 # Important for git describe --tags
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.95
|
toolchain: 1.96.1
|
||||||
components: cargo
|
components: cargo
|
||||||
|
|
||||||
- name: Extract Version from Cargo.toml
|
- name: Extract Version from Cargo.toml
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
@@ -25,12 +29,12 @@ jobs:
|
|||||||
--health-retries 5
|
--health-retries 5
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Install Rust 1.95
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.95
|
toolchain: 1.96.1
|
||||||
components: clippy, rustfmt
|
components: clippy, rustfmt
|
||||||
override: true
|
override: true
|
||||||
|
|
||||||
@@ -38,7 +42,9 @@ jobs:
|
|||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
|
|
||||||
- name: Install libpq
|
- name: Install libpq
|
||||||
run: sudo apt-get install -y libpq-dev
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libpq-dev postgresql-client
|
||||||
|
|
||||||
- name: Setup test database
|
- name: Setup test database
|
||||||
env:
|
env:
|
||||||
@@ -50,7 +56,6 @@ jobs:
|
|||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|
||||||
# Run database migrations (if you use sqlx migrations)
|
|
||||||
cargo install sqlx-cli --no-default-features --features native-tls,postgres
|
cargo install sqlx-cli --no-default-features --features native-tls,postgres
|
||||||
sqlx migrate run --database-url $DATABASE_URL
|
sqlx migrate run --database-url $DATABASE_URL
|
||||||
|
|
||||||
@@ -59,7 +64,7 @@ jobs:
|
|||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitea_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitea_deploy_key
|
||||||
chmod 600 ~/.ssh/gitea_deploy_key
|
chmod 600 ~/.ssh/gitea_deploy_key
|
||||||
ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts
|
ssh-keyscan ${{ secrets.MYHOST }} >> ~/.ssh/known_hosts
|
||||||
eval $(ssh-agent -s)
|
eval $(ssh-agent -s)
|
||||||
ssh-add -v ~/.ssh/gitea_deploy_key
|
ssh-add -v ~/.ssh/gitea_deploy_key
|
||||||
cargo build --verbose --release
|
cargo build --verbose --release
|
||||||
|
|||||||
Generated
+300
-497
File diff suppressed because it is too large
Load Diff
+10
-11
@@ -1,33 +1,32 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "icarus"
|
name = "icarus"
|
||||||
version = "0.5.0"
|
version = "0.5.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.95"
|
rust-version = "1.95"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
axum = { version = "0.8.9", features = ["multipart"] }
|
axum = { version = "0.8.9", features = ["multipart"] }
|
||||||
axum-extra = { version = "0.12.6", features = ["cookie"] }
|
axum-extra = { version = "0.12.6", features = ["cookie"] }
|
||||||
|
openssl = { version = "0.10.81", features = ["vendored"] }
|
||||||
serde = { version = "1.0.228", features = ["derive"] }
|
serde = { version = "1.0.228", features = ["derive"] }
|
||||||
serde_json = { version = "1.0.149" }
|
serde_json = { version = "1.0.150" }
|
||||||
tokio = { version = "1.52.3", features = ["full"] }
|
tokio = { version = "1.52.3", features = ["full"] }
|
||||||
tokio-util = { version = "0.7.18", features = ["io"] }
|
tokio-util = { version = "0.7.18", features = ["io"] }
|
||||||
tower = { version = "0.5.3", features = ["full"] }
|
tower = { version = "0.5.3", features = ["full"] }
|
||||||
tower-http = { version = "0.6.10", features = ["cors", "timeout"] }
|
tower-http = { version = "0.7.0", features = ["cors", "timeout"] }
|
||||||
tracing-subscriber = "0.3.23"
|
tracing-subscriber = "0.3.23"
|
||||||
futures = { version = "0.3.32" }
|
futures = { version = "0.3.32" }
|
||||||
mime_guess = { version = "2.0.5" }
|
mime_guess = { version = "2.0.5" }
|
||||||
uuid = { version = "1.23.1", features = ["v4", "serde"] }
|
uuid = { version = "1.23.4", features = ["v4", "serde"] }
|
||||||
sqlx = { version = "0.8.6", features = ["postgres", "runtime-tokio-native-tls", "time", "uuid"] }
|
sqlx = { version = "0.9.0", features = ["postgres", "runtime-tokio", "tls-native-tls", "time", "uuid"] }
|
||||||
time = { version = "0.3.47", features = ["formatting", "macros", "parsing", "serde"] }
|
time = { version = "0.3.53", features = ["formatting", "macros", "parsing", "serde"] }
|
||||||
thiserror = "2.0.18"
|
|
||||||
base64 = "0.22.1"
|
|
||||||
jsonwebtoken = { version = "10.3.0", features = ["rust_crypto"] }
|
jsonwebtoken = { version = "10.3.0", features = ["rust_crypto"] }
|
||||||
josekit = { version = "0.10.3" }
|
josekit = { version = "0.10.3" }
|
||||||
utoipa = { version = "5.5.0", features = ["axum_extras"] }
|
utoipa = { version = "5.5.0", features = ["axum_extras"] }
|
||||||
utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] }
|
utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] }
|
||||||
icarus_meta = { git = "ssh://git@git.kundeng.us/phoenix/icarus_meta.git", tag = "v0.6.0" }
|
icarus_meta = { git = "ssh://git@git.kundeng.us/phoenix/icarus_meta.git", tag = "v0.6.1" }
|
||||||
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.11.1" }
|
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.11.3" }
|
||||||
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.7.0" }
|
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.8.0" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
common-multipart-rfc7578 = { version = "0.7.0" }
|
common-multipart-rfc7578 = { version = "0.7.0" }
|
||||||
|
|||||||
+1
-1
@@ -36,7 +36,7 @@ pub async fn auth<B>(
|
|||||||
(StatusCode::UNAUTHORIZED, Json(json_error))
|
(StatusCode::UNAUTHORIZED, Json(json_error))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let secret_key = icarus_envy::environment::get_secret_main_key().await.value;
|
let secret_key = icarus_envy::environment::get_secret_main_key().value;
|
||||||
|
|
||||||
let mut validation = Validation::new(jsonwebtoken::Algorithm::HS256);
|
let mut validation = Validation::new(jsonwebtoken::Algorithm::HS256);
|
||||||
validation.set_audience(&["icarus"]); // Must match exactly what's in the token
|
validation.set_audience(&["icarus"]); // Must match exactly what's in the token
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ pub mod endpoint {
|
|||||||
let song_id = payload.song_id;
|
let song_id = payload.song_id;
|
||||||
match crate::repo::song::get_song(&pool, &song_id).await {
|
match crate::repo::song::get_song(&pool, &song_id).await {
|
||||||
Ok(song) => {
|
Ok(song) => {
|
||||||
let directory = icarus_envy::environment::get_root_directory().await.value;
|
let directory = icarus_envy::environment::get_root_directory().value;
|
||||||
let file_type =
|
let file_type =
|
||||||
icarus_meta::detection::coverart::file_type_from_data(&data).unwrap();
|
icarus_meta::detection::coverart::file_type_from_data(&data).unwrap();
|
||||||
let coverart_type = if file_type.file_type
|
let coverart_type = if file_type.file_type
|
||||||
|
|||||||
+1
-1
@@ -139,7 +139,7 @@ pub mod endpoint {
|
|||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
song.directory = icarus_envy::environment::get_root_directory().await.value;
|
song.directory = icarus_envy::environment::get_root_directory().value;
|
||||||
|
|
||||||
match repo_queue::song::get_data(&pool, &payload.song_queue_id).await {
|
match repo_queue::song::get_data(&pool, &payload.song_queue_id).await {
|
||||||
Ok(data) => {
|
Ok(data) => {
|
||||||
|
|||||||
+3
-1
@@ -40,7 +40,7 @@ mod cors {
|
|||||||
match std::env::var(icarus_envy::keys::APP_ENV).as_deref() {
|
match std::env::var(icarus_envy::keys::APP_ENV).as_deref() {
|
||||||
Ok("production") => {
|
Ok("production") => {
|
||||||
// In production, allow only your specific, trusted origins
|
// In production, allow only your specific, trusted origins
|
||||||
let allowed_origins_env = icarus_envy::environment::get_allowed_origins().await;
|
let allowed_origins_env = icarus_envy::environment::get_allowed_origins();
|
||||||
match icarus_envy::utility::delimitize(&allowed_origins_env) {
|
match icarus_envy::utility::delimitize(&allowed_origins_env) {
|
||||||
Ok(alwd) => {
|
Ok(alwd) => {
|
||||||
let allowed_origins: Vec<axum::http::HeaderValue> = alwd
|
let allowed_origins: Vec<axum::http::HeaderValue> = alwd
|
||||||
@@ -60,6 +60,8 @@ mod cors {
|
|||||||
cors.allow_origin(vec![
|
cors.allow_origin(vec![
|
||||||
"http://localhost:8000".parse().unwrap(),
|
"http://localhost:8000".parse().unwrap(),
|
||||||
"http://127.0.0.1:8000".parse().unwrap(),
|
"http://127.0.0.1:8000".parse().unwrap(),
|
||||||
|
"http://localhost:8001".parse().unwrap(),
|
||||||
|
"http://127.0.0.1:8001".parse().unwrap(),
|
||||||
"http://localhost:4200".parse().unwrap(),
|
"http://localhost:4200".parse().unwrap(),
|
||||||
"http://127.0.0.1:4200".parse().unwrap(),
|
"http://127.0.0.1:4200".parse().unwrap(),
|
||||||
])
|
])
|
||||||
|
|||||||
+1
-3
@@ -5,7 +5,7 @@ pub mod connection_settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_pool() -> Result<sqlx::PgPool, sqlx::Error> {
|
pub async fn create_pool() -> Result<sqlx::PgPool, sqlx::Error> {
|
||||||
let database_url = icarus_envy::environment::get_db_url().await.value;
|
let database_url = icarus_envy::environment::get_db_url().value;
|
||||||
println!("Database url: {database_url}");
|
println!("Database url: {database_url}");
|
||||||
|
|
||||||
PgPoolOptions::new()
|
PgPoolOptions::new()
|
||||||
@@ -15,8 +15,6 @@ pub async fn create_pool() -> Result<sqlx::PgPool, sqlx::Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn migrations(pool: &sqlx::PgPool) {
|
pub async fn migrations(pool: &sqlx::PgPool) {
|
||||||
// Run migrations using the sqlx::migrate! macro
|
|
||||||
// Assumes your migrations are in a ./migrations folder relative to Cargo.toml
|
|
||||||
sqlx::migrate!("./migrations")
|
sqlx::migrate!("./migrations")
|
||||||
.run(pool)
|
.run(pool)
|
||||||
.await
|
.await
|
||||||
|
|||||||
+4
-4
@@ -38,7 +38,7 @@ mod tests {
|
|||||||
pub const LIMIT: usize = 6;
|
pub const LIMIT: usize = 6;
|
||||||
|
|
||||||
pub async fn get_pool() -> Result<sqlx::PgPool, sqlx::Error> {
|
pub async fn get_pool() -> Result<sqlx::PgPool, sqlx::Error> {
|
||||||
let tm_db_url = icarus_envy::environment::get_db_url().await.value;
|
let tm_db_url = icarus_envy::environment::get_db_url().value;
|
||||||
let tm_options = sqlx::postgres::PgConnectOptions::from_str(&tm_db_url).unwrap();
|
let tm_options = sqlx::postgres::PgConnectOptions::from_str(&tm_db_url).unwrap();
|
||||||
sqlx::PgPool::connect_with(tm_options).await
|
sqlx::PgPool::connect_with(tm_options).await
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn connect_to_db(db_name: &str) -> Result<sqlx::PgPool, sqlx::Error> {
|
pub async fn connect_to_db(db_name: &str) -> Result<sqlx::PgPool, sqlx::Error> {
|
||||||
let db_url = icarus_envy::environment::get_db_url().await.value;
|
let db_url = icarus_envy::environment::get_db_url().value;
|
||||||
let options = sqlx::postgres::PgConnectOptions::from_str(&db_url)?.database(db_name);
|
let options = sqlx::postgres::PgConnectOptions::from_str(&db_url)?.database(db_name);
|
||||||
sqlx::PgPool::connect_with(options).await
|
sqlx::PgPool::connect_with(options).await
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_database_name() -> Result<String, Box<dyn std::error::Error>> {
|
pub async fn get_database_name() -> Result<String, Box<dyn std::error::Error>> {
|
||||||
let database_url = icarus_envy::environment::get_db_url().await.value;
|
let database_url = icarus_envy::environment::get_db_url().value;
|
||||||
let parsed_url = url::Url::parse(&database_url)?;
|
let parsed_url = url::Url::parse(&database_url)?;
|
||||||
|
|
||||||
if parsed_url.scheme() == "postgres" || parsed_url.scheme() == "postgresql" {
|
if parsed_url.scheme() == "postgres" || parsed_url.scheme() == "postgresql" {
|
||||||
@@ -149,7 +149,7 @@ mod tests {
|
|||||||
pub const TEST_USER_ID: uuid::Uuid = uuid::uuid!("cc938368-615a-4694-b2ca-6e122fa31c52");
|
pub const TEST_USER_ID: uuid::Uuid = uuid::uuid!("cc938368-615a-4694-b2ca-6e122fa31c52");
|
||||||
|
|
||||||
pub async fn test_token() -> Result<String, josekit::JoseError> {
|
pub async fn test_token() -> Result<String, josekit::JoseError> {
|
||||||
let key: String = icarus_envy::environment::get_secret_main_key().await.value;
|
let key: String = icarus_envy::environment::get_secret_main_key().value;
|
||||||
let (message, issuer, audience) = token_fields();
|
let (message, issuer, audience) = token_fields();
|
||||||
|
|
||||||
let token_resource = icarus_models::token::TokenResource {
|
let token_resource = icarus_models::token::TokenResource {
|
||||||
|
|||||||
Reference in New Issue
Block a user