Add CI to repository (#80)
All checks were successful
Cargo CI / Pipeline (push) Successful in 1m3s
Cargo CI / Pipeline (pull_request) Successful in 1m7s

Closes #77

Reviewed-on: #80
This commit is contained in:
Wojciech Kozlowski 2024-01-06 11:14:30 +01:00
parent 74f7da20e6
commit b1cf5d621d
8 changed files with 116 additions and 89 deletions

6
.gitea/images/Dockerfile Normal file
View File

@ -0,0 +1,6 @@
FROM docker.io/library/rust:1.75
RUN rustup component add clippy rustfmt
RUN apt-get update && apt-get install -y \
nodejs

View File

@ -0,0 +1,21 @@
name: Cargo CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
jobs:
pipeline:
name: Pipeline
container: docker.io/drrobot/musichoard-ci:rust-1.75
steps:
- uses: actions/checkout@v3
- run: cargo build --verbose --all-features --all-targets
- run: cargo test --verbose --all-features --lib --bins --no-fail-fast
- run: cargo clippy --verbose --all-features --all-targets -- -D warnings
- run: cargo fmt --verbose -- --check

View File

@ -76,7 +76,7 @@ mod tests {
}
}
fn vec_to_urls<U: IUrl>(vec: &Vec<U>) -> String {
fn vec_to_urls<U: IUrl>(vec: &[U]) -> String {
let mut urls: Vec<String> = vec![];
for item in vec.iter() {
urls.push(format!("\"{}\"", item.url()));

View File

@ -651,19 +651,19 @@ mod tests {
assert_eq!(url, mb.url());
assert_eq!(uuid, mb.mbid());
let url = format!("not a url at all");
let url = "not a url at all".to_string();
let expected_error: Error = url::ParseError::RelativeUrlWithoutBase.into();
let actual_error = MusicBrainz::new(&url).unwrap_err();
let actual_error = MusicBrainz::new(url).unwrap_err();
assert_eq!(actual_error, expected_error);
assert_eq!(actual_error.to_string(), expected_error.to_string());
let url = format!("https://musicbrainz.org/artist/i-am-not-a-uuid");
let url = "https://musicbrainz.org/artist/i-am-not-a-uuid".to_string();
let expected_error: Error = Uuid::try_parse("i-am-not-a-uuid").unwrap_err().into();
let actual_error = MusicBrainz::new(&url).unwrap_err();
let actual_error = MusicBrainz::new(url).unwrap_err();
assert_eq!(actual_error, expected_error);
assert_eq!(actual_error.to_string(), expected_error.to_string());
let url = format!("https://musicbrainz.org/artist");
let url = "https://musicbrainz.org/artist".to_string();
let expected_error: Error = InvalidUrlError {
url_type: UrlType::MusicBrainz,
url: url.clone(),
@ -681,32 +681,32 @@ mod tests {
let bandcamp = "https://thelasthangmen.bandcamp.com/";
let qobuz = "https://www.qobuz.com/nl-nl/interpreter/the-last-hangmen/1244413";
assert!(MusicBrainz::new(&musicbrainz).is_ok());
assert!(MusicBrainz::new(&musicbutler).is_err());
assert!(MusicBrainz::new(&bandcamp).is_err());
assert!(MusicBrainz::new(&qobuz).is_err());
assert!(MusicBrainz::new(musicbrainz).is_ok());
assert!(MusicBrainz::new(musicbutler).is_err());
assert!(MusicBrainz::new(bandcamp).is_err());
assert!(MusicBrainz::new(qobuz).is_err());
assert!(MusicButler::new(&musicbrainz).is_err());
assert!(MusicButler::new(&musicbutler).is_ok());
assert!(MusicButler::new(&bandcamp).is_err());
assert!(MusicButler::new(&qobuz).is_err());
assert!(MusicButler::new(musicbrainz).is_err());
assert!(MusicButler::new(musicbutler).is_ok());
assert!(MusicButler::new(bandcamp).is_err());
assert!(MusicButler::new(qobuz).is_err());
assert!(Bandcamp::new(&musicbrainz).is_err());
assert!(Bandcamp::new(&musicbutler).is_err());
assert!(Bandcamp::new(&bandcamp).is_ok());
assert!(Bandcamp::new(&qobuz).is_err());
assert!(Bandcamp::new(musicbrainz).is_err());
assert!(Bandcamp::new(musicbutler).is_err());
assert!(Bandcamp::new(bandcamp).is_ok());
assert!(Bandcamp::new(qobuz).is_err());
assert!(Qobuz::new(&musicbrainz).is_err());
assert!(Qobuz::new(&musicbutler).is_err());
assert!(Qobuz::new(&bandcamp).is_err());
assert!(Qobuz::new(&qobuz).is_ok());
assert!(Qobuz::new(musicbrainz).is_err());
assert!(Qobuz::new(musicbutler).is_err());
assert!(Qobuz::new(bandcamp).is_err());
assert!(Qobuz::new(qobuz).is_ok());
}
#[test]
fn merge_track() {
let left = Track {
id: TrackId {
number: 04,
number: 4,
title: String::from("a title"),
},
artist: vec![String::from("left artist")],

View File

@ -199,7 +199,7 @@ mod tests {
listener.expect_spawn().return_once(|| {
thread::spawn(|| {
thread::park();
return EventError::Io(io::Error::new(io::ErrorKind::Interrupted, "unparked"));
EventError::Io(io::Error::new(io::ErrorKind::Interrupted, "unparked"))
})
});
listener

View File

@ -760,7 +760,7 @@ mod tests {
let empty = TrackSelection::initialise(None);
assert_eq!(empty.state.selected(), None);
let empty = TrackSelection::initialise(Some(&vec![]));
let empty = TrackSelection::initialise(Some(&[]));
assert_eq!(empty.state.selected(), None);
let mut sel = TrackSelection::initialise(Some(tracks));
@ -784,7 +784,7 @@ mod tests {
sel.state.select(Some(std::usize::MAX));
assert_eq!(sel.state.selected(), Some(std::usize::MAX));
sel.increment(&vec![]);
sel.increment(&[]);
assert_eq!(sel.state.selected(), Some(std::usize::MAX));
}
@ -796,7 +796,7 @@ mod tests {
let empty = AlbumSelection::initialise(None);
assert_eq!(empty.state.selected(), None);
let empty = AlbumSelection::initialise(Some(&vec![]));
let empty = AlbumSelection::initialise(Some(&[]));
assert_eq!(empty.state.selected(), None);
let mut sel = AlbumSelection::initialise(Some(albums));
@ -841,7 +841,7 @@ mod tests {
assert_eq!(sel.state.selected(), Some(std::usize::MAX));
assert_eq!(sel.track.state.selected(), Some(1));
sel.increment(&vec![]);
sel.increment(&[]);
assert_eq!(sel.state.selected(), Some(std::usize::MAX));
assert_eq!(sel.track.state.selected(), Some(1));
}
@ -854,7 +854,7 @@ mod tests {
let empty = ArtistSelection::initialise(None);
assert_eq!(empty.state.selected(), None);
let empty = ArtistSelection::initialise(Some(&vec![]));
let empty = ArtistSelection::initialise(Some(&[]));
assert_eq!(empty.state.selected(), None);
let mut sel = ArtistSelection::initialise(Some(artists));
@ -899,7 +899,7 @@ mod tests {
assert_eq!(sel.state.selected(), Some(std::usize::MAX));
assert_eq!(sel.album.state.selected(), Some(1));
sel.increment(&vec![]);
sel.increment(&[]);
assert_eq!(sel.state.selected(), Some(std::usize::MAX));
assert_eq!(sel.album.state.selected(), Some(1));
}

View File

@ -117,7 +117,7 @@ fn test_album_title_query() {
let beets = &mut beets_arc.lock().unwrap();
let output = beets
.list(&Query::new().include(Field::AlbumTitle(String::from("Slovo"))))
.list(Query::new().include(Field::AlbumTitle(String::from("Slovo"))))
.unwrap();
let expected: Vec<Item> = artists_to_items(&COLLECTION[4..5]);
@ -130,7 +130,7 @@ fn test_exclude_query() {
let beets = &mut beets_arc.lock().unwrap();
let output = beets
.list(&Query::new().exclude(Field::AlbumArtist(String::from("Аркона"))))
.list(Query::new().exclude(Field::AlbumArtist(String::from("Аркона"))))
.unwrap();
let expected: Vec<Item> = artists_to_items(&COLLECTION[..4]);

View File

@ -31,7 +31,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
tracks: vec![
Track {
id: TrackId {
number: 01,
number: 1,
title: String::from("Verja Urit an Bitus"),
},
artist: vec![String::from("Eluveitie")],
@ -42,7 +42,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 02,
number: 2,
title: String::from("Uis Elveti"),
},
artist: vec![String::from("Eluveitie")],
@ -53,7 +53,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 03,
number: 3,
title: String::from("Ôrô"),
},
artist: vec![String::from("Eluveitie")],
@ -64,7 +64,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 04,
number: 4,
title: String::from("Lament"),
},
artist: vec![String::from("Eluveitie")],
@ -75,7 +75,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 05,
number: 5,
title: String::from("Druid"),
},
artist: vec![String::from("Eluveitie")],
@ -86,7 +86,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 06,
number: 6,
title: String::from("Jêzaïg"),
},
artist: vec![String::from("Eluveitie")],
@ -105,7 +105,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
tracks: vec![
Track {
id: TrackId {
number: 01,
number: 1,
title: String::from("Samon"),
},
artist: vec![String::from("Eluveitie")],
@ -116,7 +116,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 02,
number: 2,
title: String::from("Primordial Breath"),
},
artist: vec![String::from("Eluveitie")],
@ -127,7 +127,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 03,
number: 3,
title: String::from("Inis Mona"),
},
artist: vec![String::from("Eluveitie")],
@ -138,7 +138,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 04,
number: 4,
title: String::from("Gray Sublime Archon"),
},
artist: vec![String::from("Eluveitie")],
@ -149,7 +149,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 05,
number: 5,
title: String::from("Anagantios"),
},
artist: vec![String::from("Eluveitie")],
@ -160,7 +160,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 06,
number: 6,
title: String::from("Bloodstained Ground"),
},
artist: vec![String::from("Eluveitie")],
@ -171,7 +171,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 07,
number: 7,
title: String::from("The Somber Lay"),
},
artist: vec![String::from("Eluveitie")],
@ -182,7 +182,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 08,
number: 8,
title: String::from("Slanias Song"),
},
artist: vec![String::from("Eluveitie")],
@ -193,7 +193,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 09,
number: 9,
title: String::from("Giamonios"),
},
artist: vec![String::from("Eluveitie")],
@ -263,7 +263,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
tracks: vec![
Track {
id: TrackId {
number: 01,
number: 1,
title: String::from("Intro = Chaos"),
},
artist: vec![String::from("Frontside")],
@ -274,7 +274,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 02,
number: 2,
title: String::from("Modlitwa"),
},
artist: vec![String::from("Frontside")],
@ -285,7 +285,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 03,
number: 3,
title: String::from("Długa droga z piekła"),
},
artist: vec![String::from("Frontside")],
@ -296,7 +296,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 04,
number: 4,
title: String::from("Synowie ognia"),
},
artist: vec![String::from("Frontside")],
@ -307,7 +307,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 05,
number: 5,
title: String::from("1902"),
},
artist: vec![String::from("Frontside")],
@ -318,7 +318,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 06,
number: 6,
title: String::from("Krew za krew"),
},
artist: vec![String::from("Frontside")],
@ -329,7 +329,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 07,
number: 7,
title: String::from("Kulminacja"),
},
artist: vec![String::from("Frontside")],
@ -340,7 +340,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 08,
number: 8,
title: String::from("Judasz"),
},
artist: vec![String::from("Frontside")],
@ -351,7 +351,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 09,
number: 9,
title: String::from("Więzy"),
},
artist: vec![String::from("Frontside")],
@ -409,7 +409,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
tracks: vec![
Track {
id: TrackId {
number: 01,
number: 1,
title: String::from("Unbreakable"),
},
artist: vec![String::from("Heavens Basement")],
@ -420,7 +420,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 02,
number: 2,
title: String::from("Guilt Trips and Sins"),
},
artist: vec![String::from("Heavens Basement")],
@ -431,7 +431,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 03,
number: 3,
title: String::from("The Long Goodbye"),
},
artist: vec![String::from("Heavens Basement")],
@ -442,7 +442,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 04,
number: 4,
title: String::from("Close Encounters"),
},
artist: vec![String::from("Heavens Basement")],
@ -453,7 +453,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 05,
number: 5,
title: String::from("Paranoia"),
},
artist: vec![String::from("Heavens Basement")],
@ -464,7 +464,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 06,
number: 6,
title: String::from("Let Me Out of Here"),
},
artist: vec![String::from("Heavens Basement")],
@ -475,7 +475,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 07,
number: 7,
title: String::from("Leeches"),
},
artist: vec![String::from("Heavens Basement")],
@ -512,7 +512,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
tracks: vec![
Track {
id: TrackId {
number: 01,
number: 1,
title: String::from("Fight Fire with Fire"),
},
artist: vec![String::from("Metallica")],
@ -523,7 +523,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 02,
number: 2,
title: String::from("Ride the Lightning"),
},
artist: vec![String::from("Metallica")],
@ -534,7 +534,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 03,
number: 3,
title: String::from("For Whom the Bell Tolls"),
},
artist: vec![String::from("Metallica")],
@ -545,7 +545,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 04,
number: 4,
title: String::from("Fade to Black"),
},
artist: vec![String::from("Metallica")],
@ -556,7 +556,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 05,
number: 5,
title: String::from("Trapped under Ice"),
},
artist: vec![String::from("Metallica")],
@ -567,7 +567,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 06,
number: 6,
title: String::from("Escape"),
},
artist: vec![String::from("Metallica")],
@ -578,7 +578,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 07,
number: 7,
title: String::from("Creeping Death"),
},
artist: vec![String::from("Metallica")],
@ -589,7 +589,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 08,
number: 8,
title: String::from("The Call of Ktulu"),
},
artist: vec![String::from("Metallica")],
@ -608,7 +608,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
tracks: vec![
Track {
id: TrackId {
number: 01,
number: 1,
title: String::from("The Ecstasy of Gold"),
},
artist: vec![String::from("Metallica")],
@ -619,7 +619,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 02,
number: 2,
title: String::from("The Call of Ktulu"),
},
artist: vec![String::from("Metallica")],
@ -630,7 +630,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 03,
number: 3,
title: String::from("Master of Puppets"),
},
artist: vec![String::from("Metallica")],
@ -641,7 +641,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 04,
number: 4,
title: String::from("Of Wolf and Man"),
},
artist: vec![String::from("Metallica")],
@ -652,7 +652,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 05,
number: 5,
title: String::from("The Thing That Should Not Be"),
},
artist: vec![String::from("Metallica")],
@ -663,7 +663,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 06,
number: 6,
title: String::from("Fuel"),
},
artist: vec![String::from("Metallica")],
@ -674,7 +674,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 07,
number: 7,
title: String::from("The Memory Remains"),
},
artist: vec![String::from("Metallica")],
@ -685,7 +685,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 08,
number: 8,
title: String::from("No Leaf Clover"),
},
artist: vec![String::from("Metallica")],
@ -696,7 +696,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 09,
number: 9,
title: String::from("Hero of the Day"),
},
artist: vec![String::from("Metallica")],
@ -867,7 +867,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
tracks: vec![
Track {
id: TrackId {
number: 01,
number: 1,
title: String::from("Az"),
},
artist: vec![String::from("Аркона")],
@ -878,7 +878,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 02,
number: 2,
title: String::from("Arkaim"),
},
artist: vec![String::from("Аркона")],
@ -889,7 +889,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 03,
number: 3,
title: String::from("Bolno mne"),
},
artist: vec![String::from("Аркона")],
@ -900,7 +900,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 04,
number: 4,
title: String::from("Leshiy"),
},
artist: vec![String::from("Аркона")],
@ -911,7 +911,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 05,
number: 5,
title: String::from("Zakliatie"),
},
artist: vec![String::from("Аркона")],
@ -922,7 +922,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 06,
number: 6,
title: String::from("Predok"),
},
artist: vec![String::from("Аркона")],
@ -933,7 +933,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 07,
number: 7,
title: String::from("Nikogda"),
},
artist: vec![String::from("Аркона")],
@ -944,7 +944,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 08,
number: 8,
title: String::from("Tam za tumanami"),
},
artist: vec![String::from("Аркона")],
@ -955,7 +955,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
},
Track {
id: TrackId {
number: 09,
number: 9,
title: String::from("Potomok"),
},
artist: vec![String::from("Аркона")],