From 7f4d3e562c467a57f99f0df44b843735c04d4437 Mon Sep 17 00:00:00 2001 From: Mario Ortiz Manero Date: Fri, 2 Jul 2021 11:58:47 +0200 Subject: [PATCH 1/8] Removed cross-compilation --- .github/workflows/ci.yml | 41 +--------------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 68b528c5..66862580 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,46 +27,7 @@ jobs: command: fmt args: --all -- --check - # Cross compilation is only needed for the main client and not the entire - # workspace. - cross-compile: - name: Cross Compile - runs-on: ubuntu-latest - env: - CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc - CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc - CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc - strategy: - matrix: - target: - - aarch64-unknown-linux-gnu - - arm-unknown-linux-gnueabihf - - armv7-unknown-linux-gnueabihf - client: - - rspotify/cli,rspotify/env-file,rspotify/client-ureq,rspotify/ureq-rustls-tls,rspotify-http/client-ureq,rspotify-http/ureq-rustls-tls - - rspotify/cli,rspotify/env-file,rspotify/client-reqwest,rspotify/reqwest-rustls-tls,rspotify-http/client-reqwest,rspotify-http/reqwest-rustls-tls - steps: - - name: Checkout sources - uses: actions/checkout@v2 - - - name: Install gcc for armhf - run: sudo apt-get update && sudo apt-get install gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu - - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - target: ${{ matrix.target }} - - - name: Run cargo build - uses: actions-rs/cargo@v1 - with: - command: build - args: -p rspotify -p rspotify-http -p rspotify-model -p rspotify-macros --no-default-features --features=${{ matrix.client }} --target ${{ matrix.target }} - - test-client: + test: name: Test and Lint for each Client runs-on: ubuntu-latest strategy: From ffeec4a7dfbf1f9dc7757ae10909f212f063092d Mon Sep 17 00:00:00 2001 From: Mario Ortiz Manero Date: Fri, 2 Jul 2021 12:27:16 +0200 Subject: [PATCH 2/8] Add dead links flow --- .github/workflows/ci.yml | 20 ++++++++++++++++++++ Cargo.toml | 4 ++-- src/auth_code.rs | 6 +++--- src/auth_code_pkce.rs | 4 ++-- src/client_creds.rs | 4 ++-- src/lib.rs | 31 +++++++++++++++---------------- 6 files changed, 44 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 66862580..09e18a3f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,26 @@ jobs: command: fmt args: --all -- --check + check-doc: + name: Check Dead Links in the Docs + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Installs cargo-deadlinks + run: cargo install cargo-deadlinks + + - name: Build and check doc + run: RUSTDOCFLAGS='-D warnings' cargo doc --features=cli,env-file + + - name: Checks dead links + run: | + for crate in target/doc/rspotify*; do + echo "Checking in $crate" + cargo deadlinks --dir "$crate" + done + test: name: Test and Lint for each Client runs-on: ubuntu-latest diff --git a/Cargo.toml b/Cargo.toml index 6df17351..c0a32e3d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -85,8 +85,8 @@ __async = ["futures", "async-stream", "async-trait"] __sync = ["maybe-async/is_sync"] [package.metadata.docs.rs] -# Also documenting the CLI methods -features = ["cli"] +# Documenting the CLI methods, and working links for `dotenv` +features = ["cli", "env-file"] [[example]] name = "client_creds" diff --git a/src/auth_code.rs b/src/auth_code.rs index c409ad3f..119c43b1 100644 --- a/src/auth_code.rs +++ b/src/auth_code.rs @@ -40,11 +40,11 @@ use url::Url; /// is that this doesn't require the user to log in, and that it's a simpler /// procedure. /// -/// See [this related example](example-refresh-token) to learn more about +/// See [this related example][example-refresh-token] to learn more about /// refreshing tokens. /// -/// There's a [webapp example](example-webapp) for more details on how you can -/// implement it for something like a web server, or [this one](example-main) +/// There's a [webapp example][example-webapp] for more details on how you can +/// implement it for something like a web server, or [this one][example-main] /// for a CLI use case. /// /// An example of the CLI authentication: diff --git a/src/auth_code_pkce.rs b/src/auth_code_pkce.rs index 76c39d09..fca31d87 100644 --- a/src/auth_code_pkce.rs +++ b/src/auth_code_pkce.rs @@ -12,14 +12,14 @@ use maybe_async::maybe_async; use url::Url; /// The [Authorization Code Flow with Proof Key for Code Exchange -/// (PKCE)](reference) client for the Spotify API. +/// (PKCE)][reference] client for the Spotify API. /// /// This flow is very similar to the regular Authorization Code Flow, so please /// read [`AuthCodeSpotify`](crate::AuthCodeSpotify) for more information about /// it. The main difference in this case is that you can avoid storing your /// client secret by generating a *code verifier* and a *code challenge*. /// -/// There's an [example](example-main) available to learn how to use this +/// There's an [example][example-main] available to learn how to use this /// client. /// /// [reference]: https://developer.spotify.com/documentation/general/guides/authorization-guide/#authorization-code-flow-with-proof-key-for-code-exchange-pkce diff --git a/src/client_creds.rs b/src/client_creds.rs index 602e06a2..816dc04d 100644 --- a/src/client_creds.rs +++ b/src/client_creds.rs @@ -7,11 +7,11 @@ use crate::{ use maybe_async::maybe_async; -/// The [Client Credentials Flow](reference) client for the Spotify API. +/// The [Client Credentials Flow][reference] client for the Spotify API. /// /// This is the most basic flow. It requests a token to Spotify given some /// client credentials, without user authorization. The only step to take is to -/// call [`Self::request_token`]. See [this example](example-main). +/// call [`Self::request_token`]. See [this example][example-main]. /// /// Note: This flow does not include authorization and therefore cannot be used /// to access or to manage the endpoints related to user private data in diff --git a/src/lib.rs b/src/lib.rs index c49e9fa9..deaff6c9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,23 +1,23 @@ -//! Rspotify is a wrapper for the [Spotify Web API](spotify-main), inspired by -//! [spotipy](spotipy-github). It includes support for all the [authorization -//! flows](spotify-auth-flows), and helper methods for [all available endpoints -//! ](spotify-reference). +//! Rspotify is a wrapper for the [Spotify Web API][spotify-main], inspired by +//! [spotipy][spotipy-github]. It includes support for all the [authorization +//! flows][spotify-auth-flows], and helper methods for [all available +//! endpoints][spotify-reference]. //! //! ## Configuration //! //! ### HTTP Client //! -//! By default, Rspotify uses the [reqwest](reqwest-docs) asynchronous HTTP +//! By default, Rspotify uses the [reqwest][reqwest-docs] asynchronous HTTP //! client with its default TLS, but you can customize both the HTTP client and //! the TLS with the following features: //! -//! - [reqwest](reqwest-docs): enabling +//! - [reqwest][reqwest-docs]: enabling //! `client-reqwest`, TLS available: //! + `reqwest-default-tls` (reqwest's default) //! + `reqwest-rustls-tls` //! + `reqwest-native-tls` //! + `reqwest-native-tls-vendored` -//! - [ureq](ureq-docs): enabling `client-ureq`, TLS +//! - [ureq][ureq-docs]: enabling `client-ureq`, TLS //! available: //! + `ureq-rustls-tls` (ureq's default) //! @@ -49,7 +49,7 @@ //! //! ### Proxies //! -//! [reqwest supports system proxies by default](reqwest-proxies). It reads the +//! [reqwest supports system proxies by default][reqwest-proxies]. It reads the //! environment variables `HTTP_PROXY` and `HTTPS_PROXY` environmental variables //! to set HTTP and HTTPS proxies, respectively. //! @@ -77,9 +77,9 @@ //! All endpoints require app authorization; you will need to generate a token //! that indicates that the client has been granted permission to perform //! requests. You can start by [registering your app to get the necessary client -//! credentials](spotify-register-app). Read the [official guide for a detailed +//! credentials][spotify-register-app]. Read the [official guide for a detailed //! explanation of the different authorization flows -//! available](spotify-auth-flows). +//! available][spotify-auth-flows]. //! //! Rspotify has a different client for each of the available authentication //! flows. They may implement the endpoints in @@ -87,12 +87,12 @@ //! [`OAuthClient`](crate::clients::OAuthClient) according to what kind of //! flow it is. Please refer to their documentation for more details: //! -//! * [Client Credentials Flow](spotify-client-creds): see +//! * [Client Credentials Flow][spotify-client-creds]: see //! [`ClientCredsSpotify`]. -//! * [Authorization Code Flow](spotify-auth-code): see [`AuthCodeSpotify`]. +//! * [Authorization Code Flow][spotify-auth-code]: see [`AuthCodeSpotify`]. //! * [Authorization Code Flow with Proof Key for Code Exchange -//! (PKCE)](spotify-auth-code-pkce): see [`AuthCodePkceSpotify`]. -//! * [Implicit Grant Flow](spotify-implicit-grant): unimplemented, as Rspotify +//! (PKCE)][spotify-auth-code-pkce]: see [`AuthCodePkceSpotify`]. +//! * [Implicit Grant Flow][spotify-implicit-grant]: unimplemented, as Rspotify //! has not been tested on a browser yet. If you'd like support for it, let us //! know in an issue! //! @@ -105,7 +105,7 @@ //! ### Examples //! //! There are some [available examples on the GitHub -//! repository](examples-github) which can serve as a learning tool. +//! repository][examples-github] which can serve as a learning tool. //! //! [spotipy-github]: https://github.com/plamere/spotipy //! [reqwest-docs]: https://docs.rs/reqwest/ @@ -116,7 +116,6 @@ //! [spotify-auth-flows]: https://developer.spotify.com/documentation/general/guides/authorization-guide //! [spotify-reference]: https://developer.spotify.com/documentation/web-api/reference/ //! [spotify-register-app]: https://developer.spotify.com/dashboard/applications -//! [spotify]: https://developer.spotify.com/documentation/general/guides/authorization-guide/ //! [spotify-client-creds]: https://developer.spotify.com/documentation/general/guides/authorization-guide/#client-credentials-flow //! [spotify-auth-code]: https://developer.spotify.com/documentation/general/guides/authorization-guide/#authorization-code-flow //! [spotify-auth-code-pkce]: https://developer.spotify.com/documentation/general/guides/authorization-guide/#authorization-code-flow-with-proof-key-for-code-exchange-pkce From 263c29fd0935ba92b166a3bcaca223eabea8d902 Mon Sep 17 00:00:00 2001 From: Mario Ortiz Manero Date: Fri, 2 Jul 2021 13:49:07 +0200 Subject: [PATCH 3/8] Fix naming --- .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 09e18a3f..ff015f7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,7 +52,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - client: + features: - rspotify/cli,rspotify/env-file,rspotify/client-ureq,rspotify/ureq-rustls-tls,rspotify-http/client-ureq,rspotify-http/ureq-rustls-tls - rspotify/cli,rspotify/env-file,rspotify/client-reqwest,rspotify/reqwest-rustls-tls,rspotify-http/client-reqwest,rspotify-http/reqwest-rustls-tls steps: @@ -71,10 +71,10 @@ jobs: uses: actions-rs/cargo@v1 with: command: clippy - args: -p rspotify -p rspotify-http -p rspotify-model -p rspotify-macros --no-default-features --features=${{ matrix.client }} -- -D warnings + args: -p rspotify -p rspotify-http -p rspotify-model -p rspotify-macros --no-default-features --features=${{ matrix.features }} -- -D warnings - name: Run cargo test uses: actions-rs/cargo@v1 with: command: test - args: -p rspotify -p rspotify-http -p rspotify-model -p rspotify-macros --no-default-features --features=${{ matrix.client }} + args: -p rspotify -p rspotify-http -p rspotify-model -p rspotify-macros --no-default-features --features=${{ matrix.features }} From e0bd1bf319a0665af56652254da3bb7ca6a5840a Mon Sep 17 00:00:00 2001 From: Mario Ortiz Manero Date: Fri, 2 Jul 2021 14:08:35 +0200 Subject: [PATCH 4/8] Also check HTTP links in CI --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff015f7b..0ea1671b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,14 +27,14 @@ jobs: command: fmt args: --all -- --check - check-doc: - name: Check Dead Links in the Docs + docs: + name: Check Docs runs-on: ubuntu-latest steps: - name: Checkout sources uses: actions/checkout@v2 - - name: Installs cargo-deadlinks + - name: Install cargo-deadlinks run: cargo install cargo-deadlinks - name: Build and check doc @@ -44,7 +44,7 @@ jobs: run: | for crate in target/doc/rspotify*; do echo "Checking in $crate" - cargo deadlinks --dir "$crate" + cargo deadlinks --check-http --dir "$crate" done test: From baac69e2561a3c4ba3f52cbee5ac02582ad8edcd Mon Sep 17 00:00:00 2001 From: Mario Ortiz Manero Date: Fri, 2 Jul 2021 14:26:13 +0200 Subject: [PATCH 5/8] Fix model broken links --- rspotify-model/src/enums/misc.rs | 15 ++++++++------- rspotify-model/src/enums/types.rs | 10 +++++----- rspotify-model/src/search.rs | 4 ++-- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/rspotify-model/src/enums/misc.rs b/rspotify-model/src/enums/misc.rs index cb7e1211..9688c6f2 100644 --- a/rspotify-model/src/enums/misc.rs +++ b/rspotify-model/src/enums/misc.rs @@ -7,7 +7,7 @@ use super::Country; /// `skipping_next`, `skipping_prev`, `toggling_repeat_context`, /// `toggling_shuffle`, `toggling_repeat_track`, `transferring_playback`. /// -/// [Reference](https://developer.spotify.com/documentation/web-api/reference/object-model/#disallows-object) +/// [Reference](https://developer.spotify.com/documentation/web-api/reference/#object-disallowsobject) #[derive(Clone, Serialize, Deserialize, Copy, PartialEq, Eq, Debug, Hash, AsRefStr)] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] @@ -50,7 +50,7 @@ pub enum RepeatState { /// Type for include_external: `audio`. /// -/// [Reference](https://developer.spotify.com/documentation/web-api/reference/search/search/) +/// [Reference](https://developer.spotify.com/documentation/web-api/reference/#endpoint-search) #[derive(Clone, Serialize, Deserialize, Copy, PartialEq, Eq, Debug, AsRefStr)] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] @@ -72,7 +72,7 @@ pub enum DatePrecision { /// The reason for the restriction: `market`, `product`, `explicit` /// -/// [Reference](https://developer.spotify.com/documentation/web-api/reference/object-model/#track-restriction-object) +/// [Reference](https://developer.spotify.com/documentation/web-api/reference/#object-albumrestrictionobject) #[derive(Clone, Serialize, Deserialize, Copy, PartialEq, Eq, Debug, AsRefStr)] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] @@ -82,11 +82,12 @@ pub enum RestrictionReason { Explict, } -/// Indicates the modality (major or minor) of a track -/// This field will contain a 0 for `minor`, a 1 for `major` or -/// a -1 for `no result` +/// Indicates the modality (major or minor) of a track. /// -/// [Reference](https://developer.spotify.com/documentation/web-api/reference/tracks/get-audio-analysis/#section-object) +/// This field will contain a 0 for `minor`, a 1 for `major` or a -1 for `no +/// result` +/// +/// [Reference](https://developer.spotify.com/documentation/web-api/reference/#objects-index) #[derive(Clone, Serialize, Deserialize, Copy, PartialEq, Eq, Debug, AsRefStr)] pub enum Modality { Minor = 0, diff --git a/rspotify-model/src/enums/types.rs b/rspotify-model/src/enums/types.rs index 2115e408..df97d39a 100644 --- a/rspotify-model/src/enums/types.rs +++ b/rspotify-model/src/enums/types.rs @@ -4,7 +4,7 @@ use strum::{AsRefStr, Display, EnumString}; /// Copyright type: `C` = the copyright, `P` = the sound recording (performance) /// copyright. /// -/// [Reference](https://developer.spotify.com/documentation/web-api/reference/object-model/#copyright-object) +/// [Reference](https://developer.spotify.com/documentation/web-api/reference/#object-copyrightobject) #[derive(Clone, Serialize, Deserialize, Copy, PartialEq, Eq, Debug, AsRefStr)] pub enum CopyrightType { #[strum(serialize = "P")] @@ -17,7 +17,7 @@ pub enum CopyrightType { /// Album type: `album`, `single`, `appears_on`, `compilation` /// -/// [Reference](https://developer.spotify.com/documentation/web-api/reference/object-model/#album-object-full) +/// [Reference](https://developer.spotify.com/documentation/web-api/reference/#objects-index) #[derive(Clone, Serialize, Deserialize, Copy, PartialEq, Eq, Debug, AsRefStr)] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] @@ -89,7 +89,7 @@ pub enum SearchType { /// /// (The subscription level "open" can be considered the same as "free".) /// -/// [Reference](https://developer.spotify.com/documentation/web-api/reference/users-profile/get-current-users-profile/) +/// [Reference](https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-current-users-profile) #[derive(Clone, Serialize, Deserialize, Copy, PartialEq, Eq, Debug, AsRefStr)] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] @@ -101,7 +101,7 @@ pub enum SubscriptionLevel { /// Device Type: `computer`, `smartphone`, `speaker`, `TV` /// -/// [Reference](https://developer.spotify.com/documentation/web-api/reference/player/get-a-users-available-devices/#device-types) +/// [Reference](https://developer.spotify.com/documentation/web-api/reference/#object-deviceobject) #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, AsRefStr)] #[strum(serialize_all = "snake_case")] pub enum DeviceType { @@ -122,7 +122,7 @@ pub enum DeviceType { /// Recommendations seed type /// -/// [Reference](https://developer.spotify.com/documentation/web-api/reference/object-model/#recommendations-seed-object) +/// [Reference](https://developer.spotify.com/documentation/web-api/reference/#object-recommendationseedobject) #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, AsRefStr)] #[serde(rename_all = "snake_case")] pub enum RecommendationsSeedType { diff --git a/rspotify-model/src/search.rs b/rspotify-model/src/search.rs index d75d45cb..497a8d65 100644 --- a/rspotify-model/src/search.rs +++ b/rspotify-model/src/search.rs @@ -54,9 +54,9 @@ pub struct SearchEpisodes { pub episodes: Page, } -/// Search result +/// Search result of any kind /// -/// [Reference](https://developer.spotify.com/documentation/web-api/reference/search/search/) +/// [Reference](https://developer.spotify.com/documentation/web-api/reference/#category-search) #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] pub enum SearchResult { #[serde(rename = "playlists")] From 1adb86257b1f4e5bbcd27b744ba0f72e0d728285 Mon Sep 17 00:00:00 2001 From: Mario Ortiz Manero Date: Fri, 2 Jul 2021 14:35:55 +0200 Subject: [PATCH 6/8] Install custom toolchain --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ea1671b..ddc94bed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,6 +34,13 @@ jobs: - name: Checkout sources uses: actions/checkout@v2 + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - name: Install cargo-deadlinks run: cargo install cargo-deadlinks From 24cb2b9b9d47db1aa7b5cbc1de58506c015c8268 Mon Sep 17 00:00:00 2001 From: Mario Ortiz Manero Date: Fri, 2 Jul 2021 14:47:28 +0200 Subject: [PATCH 7/8] Fix relative path --- .github/workflows/ci.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ddc94bed..50c7cdf7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,13 +44,14 @@ jobs: - name: Install cargo-deadlinks run: cargo install cargo-deadlinks - - name: Build and check doc + - name: Build and Check run: RUSTDOCFLAGS='-D warnings' cargo doc --features=cli,env-file - - name: Checks dead links + - name: Look for Dead Links run: | - for crate in target/doc/rspotify*; do - echo "Checking in $crate" + cd target + for crate in doc/rspotify*; do + echo ">> Checking in $crate" cargo deadlinks --check-http --dir "$crate" done From 6b441c04baddabfbb56da9044419e954d72ce567 Mon Sep 17 00:00:00 2001 From: Mario Ortiz Manero Date: Sat, 3 Jul 2021 12:12:08 +0200 Subject: [PATCH 8/8] Set continue-on-error --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 50c7cdf7..5f308752 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,6 +54,7 @@ jobs: echo ">> Checking in $crate" cargo deadlinks --check-http --dir "$crate" done + continue-on-error: true test: name: Test and Lint for each Client