From 1662348a237acae28e26d290dfcd9a13e02da94d Mon Sep 17 00:00:00 2001 From: LucasFA <23667494+LucasFA@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:12:25 +0100 Subject: [PATCH 1/5] Prepare for new CI Reorder features (by number of dependencies) Create CI profile, set MSRV Switch CI cache to Swatinem, reorder CI steps Swatinem is for starters just simpler to use and keys very sensitively. It also eliminates unnecessary files from `./target/`, which might be a good idea to cache with the now quite large number of jobs. I reordered the features also somewhat in user importance (increasing). The CI profile is primarily intended to reduce the size of the `./target/` folder. Reorder execution for speed/latency - clippy is fast. --- .github/workflows/ci.yml | 20 ++++++-------------- Cargo.toml | 9 +++++++++ lyric_finder/Cargo.toml | 1 + spotify_player/Cargo.toml | 8 ++++++-- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b4d1932..eca14bdf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,25 +40,17 @@ jobs: toolchain: ${{ matrix.toolchain }} components: clippy, rustfmt - - name: Cache cargo deps - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: ${{ runner.os }}-rustc-${{ steps.install_toolchain.outputs.cachekey }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: ${{ runner.os }}-rustc-${{ steps.install_toolchain.outputs.cachekey }} + - uses: Swatinem/rust-cache@v2 - name: Cargo format run: cargo fmt --all -- --check - - name: Cargo test - run: cargo test --no-default-features --features ${{ env.RUST_FEATURES }} + - name: Cargo clippy without features + run: cargo clippy --no-default-features --profile ci -- -D warnings - name: Cargo clippy with all features - run: cargo clippy --no-default-features --features ${{ env.RUST_FEATURES }} -- -D warnings + run: cargo clippy --no-default-features --profile ci --features ${{ env.RUST_FEATURES }} -- -D warnings - - name: Cargo clippy without features - run: cargo clippy --no-default-features -- -D warnings + - name: Cargo test + run: cargo test --no-default-features --profile ci --features ${{ env.RUST_FEATURES }} diff --git a/Cargo.toml b/Cargo.toml index 5cb61c97..13ccff77 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,5 +2,14 @@ members = ["spotify_player", "lyric_finder"] resolver = "2" +[workspace.package] +rust-version = "1.74" + +[profile.ci] +inherits = "dev" +debug = 0 +strip = true +incremental = false + [profile.release] debug = 1 diff --git a/lyric_finder/Cargo.toml b/lyric_finder/Cargo.toml index 42ebe526..05284fff 100644 --- a/lyric_finder/Cargo.toml +++ b/lyric_finder/Cargo.toml @@ -2,6 +2,7 @@ name = "lyric_finder" version = "0.1.5" edition = "2021" +rust-version.workspace = true license = "MIT" description = "A lyric finder library" authors = ["Thang Pham "] diff --git a/spotify_player/Cargo.toml b/spotify_player/Cargo.toml index 0b7f0c53..6e503e11 100644 --- a/spotify_player/Cargo.toml +++ b/spotify_player/Cargo.toml @@ -3,6 +3,7 @@ name = "spotify_player" version = "0.16.3" authors = ["Thang Pham "] edition = "2021" +rust-version.workspace = true license = "MIT" description = "A Spotify player in the terminal with full feature parity" repository = "https://github.com/aome510/spotify-player" @@ -71,14 +72,17 @@ jackaudio-backend = ["streaming", "librespot-playback/jackaudio-backend"] rodiojack-backend = ["streaming", "librespot-playback/rodiojack-backend"] sdl-backend = ["streaming", "librespot-playback/sdl-backend"] gstreamer-backend = ["streaming", "librespot-playback/gstreamer-backend"] + streaming = ["librespot-playback", "librespot-connect"] -lyric-finder = ["lyric_finder"] media-control = ["souvlaki", "winit", "windows"] + image = ["viuer", "dep:image"] sixel = ["image", "viuer/sixel"] +daemon = ["daemonize", "streaming"] + +lyric-finder = ["lyric_finder"] notify = ["notify-rust"] clipboard = ["copypasta"] -daemon = ["daemonize", "streaming"] default = ["rodio-backend", "media-control", "clipboard"] From 046d720da2aaec7461d245a0d1288324aef1f385 Mon Sep 17 00:00:00 2001 From: LucasFA <23667494+LucasFA@users.noreply.github.com> Date: Sat, 2 Mar 2024 14:59:01 +0100 Subject: [PATCH 2/5] Add MSRV CI job --- .github/workflows/ci.yml | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eca14bdf..ff0c8882 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,33 @@ env: RUST_FEATURES: "rodio-backend,lyric-finder,media-control,image,notify,clipboard" jobs: - rust-ci: + msrv: + if: github.event.pull_request.draft != true + strategy: + fail-fast: false + matrix: + os: [macOS-latest, windows-latest, ubuntu-latest] + include: + - os: ubuntu-latest + OS_SPECIFIC_FEATURES: ",daemon, sixel" + - os: macOS-latest + OS_SPECIFIC_FEATURES: ",sixel" + + runs-on: ${{ matrix.os }} + steps: + - run: sudo apt-get update && sudo apt-get install libssl-dev libasound2-dev libdbus-1-dev libxcb-shape0-dev libxcb-xfixes0-dev + if: ${{ runner.os == 'Linux'}} + - uses: actions/checkout@v4 + + - uses: taiki-e/install-action@v2 + with: + tool: cargo-hack + + - uses: Swatinem/rust-cache@v2 + + - run: cargo hack check --rust-version --package spotify_player --all-targets --profile ci --features "${{ env.RUST_FEATURES }} ${{ matrix.OS_SPECIFIC_FEATURES }}" + + rust-ci: if: github.event.pull_request.draft != true strategy: From 6a37d308c7a719d578d4c0e7e22012368187b950 Mon Sep 17 00:00:00 2001 From: LucasFA <23667494+LucasFA@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:37:50 +0100 Subject: [PATCH 3/5] Add OS_SPECIFIC_FEATURES to rust-ci job --- .github/workflows/ci.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff0c8882..f918ffcf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,6 +48,11 @@ jobs: include: - os: ubuntu-latest toolchain: beta + OS_SPECIFIC_FEATURES: ",daemon, sixel" + - os: ubuntu-latest + OS_SPECIFIC_FEATURES: ",daemon, sixel" + - os: macOS-latest + OS_SPECIFIC_FEATURES: ",sixel" runs-on: ${{ matrix.os }} @@ -75,8 +80,8 @@ jobs: run: cargo clippy --no-default-features --profile ci -- -D warnings - name: Cargo clippy with all features - run: cargo clippy --no-default-features --profile ci --features ${{ env.RUST_FEATURES }} -- -D warnings + run: cargo clippy --no-default-features --profile ci --features "${{ env.RUST_FEATURES }} ${{ matrix.OS_SPECIFIC_FEATURES }}" -- -D warnings - name: Cargo test - run: cargo test --no-default-features --profile ci --features ${{ env.RUST_FEATURES }} + run: cargo test --no-default-features --profile ci --features "${{ env.RUST_FEATURES }} ${{ matrix.OS_SPECIFIC_FEATURES }}" From b605e175f161a7cb921eef9de0f4eb2cc1c89aaf Mon Sep 17 00:00:00 2001 From: LucasFA <23667494+LucasFA@users.noreply.github.com> Date: Sun, 3 Mar 2024 21:41:19 +0100 Subject: [PATCH 4/5] Use spaces instead of commas as feature separator Co-authored-by: Thang Pham --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f918ffcf..280b43da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,11 +48,11 @@ jobs: include: - os: ubuntu-latest toolchain: beta - OS_SPECIFIC_FEATURES: ",daemon, sixel" + OS_SPECIFIC_FEATURES: "daemon sixel" - os: ubuntu-latest - OS_SPECIFIC_FEATURES: ",daemon, sixel" + OS_SPECIFIC_FEATURES: "daemon sixel" - os: macOS-latest - OS_SPECIFIC_FEATURES: ",sixel" + OS_SPECIFIC_FEATURES: "sixel" runs-on: ${{ matrix.os }} From 72a4946d2d9eed6a462411131f2126b3c0ba047f Mon Sep 17 00:00:00 2001 From: LucasFA <23667494+LucasFA@users.noreply.github.com> Date: Sun, 3 Mar 2024 23:24:19 +0100 Subject: [PATCH 5/5] Factor out Linux packages --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 280b43da..20c7c73d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,7 @@ env: CARGO_TERM_COLOR: always RUST_BACKTRACE: 1 RUST_FEATURES: "rodio-backend,lyric-finder,media-control,image,notify,clipboard" + LINUX_PACKAGES: "libssl-dev libasound2-dev libdbus-1-dev libxcb-shape0-dev libxcb-xfixes0-dev" jobs: msrv: @@ -26,7 +27,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - - run: sudo apt-get update && sudo apt-get install libssl-dev libasound2-dev libdbus-1-dev libxcb-shape0-dev libxcb-xfixes0-dev + - run: sudo apt-get update && sudo apt-get install ${{ env.LINUX_PACKAGES }} if: ${{ runner.os == 'Linux'}} - uses: actions/checkout@v4 @@ -58,7 +59,7 @@ jobs: steps: - name: Install dependencies - run: sudo apt-get update && sudo apt-get install libssl-dev libasound2-dev libdbus-1-dev libxcb-shape0-dev libxcb-xfixes0-dev + run: sudo apt-get update && sudo apt-get install ${{ env.LINUX_PACKAGES }} if: ${{ runner.os == 'Linux' }} - name: Checkout source