ci: add 'ci' feature flag to backend-rs

This commit is contained in:
naskya 2024-05-04 16:14:23 +09:00
parent bc39badf51
commit 0f4c05a64f
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C
5 changed files with 23 additions and 13 deletions

1
Cargo.lock generated
View file

@ -202,6 +202,7 @@ dependencies = [
"argon2",
"basen",
"bcrypt",
"cfg-if",
"chrono",
"cuid2",
"emojis",

View file

@ -12,6 +12,7 @@ napi-build = "2.1.3"
argon2 = "0.5.3"
basen = "0.1.0"
bcrypt = "0.15.1"
cfg-if = "1.0.0"
chrono = "0.4.38"
convert_case = "0.6.0"
cuid2 = "0.1.2"

View file

@ -7,6 +7,7 @@ rust-version = "1.74"
[features]
default = []
napi = ["dep:napi", "dep:napi-derive"]
ci = []
[lib]
crate-type = ["cdylib", "lib"]
@ -46,6 +47,7 @@ url = { workspace = true }
urlencoding = { workspace = true }
[dev-dependencies]
cfg-if = { workspace = true }
pretty_assertions = { workspace = true }
[build-dependencies]

View file

@ -123,17 +123,20 @@ mod unit_test {
let gif_url = "https://firefish.dev/firefish/firefish/-/raw/b9c3dfbd3d473cb2cee20c467eeae780bc401271/packages/backend/test/resources/anime.gif";
let mp3_url = "https://firefish.dev/firefish/firefish/-/blob/5891a90f71a8b9d5ea99c683ade7e485c685d642/packages/backend/assets/sounds/aisha/1.mp3";
// Delete caches in case you run this test multiple times
// (should be disabled in CI tasks)
cache::delete_one(cache::Category::FetchUrl, png_url_1).unwrap();
cache::delete_one(cache::Category::FetchUrl, png_url_2).unwrap();
cache::delete_one(cache::Category::FetchUrl, png_url_3).unwrap();
cache::delete_one(cache::Category::FetchUrl, rotated_jpeg_url).unwrap();
cache::delete_one(cache::Category::FetchUrl, webp_url_1).unwrap();
cache::delete_one(cache::Category::FetchUrl, webp_url_2).unwrap();
cache::delete_one(cache::Category::FetchUrl, ico_url).unwrap();
cache::delete_one(cache::Category::FetchUrl, gif_url).unwrap();
cache::delete_one(cache::Category::FetchUrl, mp3_url).unwrap();
cfg_if::cfg_if! {
if #[cfg(not(feature = "ci"))] {
// Delete caches in case you run this test multiple times
cache::delete_one(cache::Category::FetchUrl, png_url_1).unwrap();
cache::delete_one(cache::Category::FetchUrl, png_url_2).unwrap();
cache::delete_one(cache::Category::FetchUrl, png_url_3).unwrap();
cache::delete_one(cache::Category::FetchUrl, rotated_jpeg_url).unwrap();
cache::delete_one(cache::Category::FetchUrl, webp_url_1).unwrap();
cache::delete_one(cache::Category::FetchUrl, webp_url_2).unwrap();
cache::delete_one(cache::Category::FetchUrl, ico_url).unwrap();
cache::delete_one(cache::Category::FetchUrl, gif_url).unwrap();
cache::delete_one(cache::Category::FetchUrl, mp3_url).unwrap();
}
}
let png_size_1 = ImageSize {
width: 1024,

View file

@ -79,8 +79,11 @@ mod unit_test {
#[tokio::test]
async fn check_version() {
// TODO: don't need to do this in CI tasks
cache::delete_one(cache::Category::FetchUrl, UPSTREAM_PACKAGE_JSON_URL).unwrap();
cfg_if::cfg_if! {
if #[cfg(not(feature = "ci"))] {
cache::delete_one(cache::Category::FetchUrl, UPSTREAM_PACKAGE_JSON_URL).unwrap();
}
}
// fetch from firefish.dev
validate_version(latest_version().await.unwrap());