diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 044809a3..df00aab5 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,8 +1,6 @@ name: CI on: push: - branches: - - main pull_request: workflow_dispatch: @@ -15,20 +13,23 @@ concurrency: jobs: build: - name: cargo build - runs-on: ubuntu-latest + name: cargo build & test + strategy: + matrix: + os: [ubuntu-latest] + rust: [stable, "1.70"] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - uses: rui314/setup-mold@v1 - uses: dtolnay/rust-toolchain@stable - - uses: actions/cache@v3 with: - path: | - ./.cargo/.build - ./target - ~/.cargo - key: ${{ runner.os }}-cargo-dev-${{ hashFiles('**/Cargo.lock') }} + toolchain: ${{ matrix.rust }} + - uses: Swatinem/rust-cache@v2 + with: + shared-key: "build" - run: cargo build --all-targets + - run: cargo test clippy: name: cargo clippy @@ -38,14 +39,11 @@ jobs: - uses: actions/checkout@v4 - uses: rui314/setup-mold@v1 - uses: dtolnay/rust-toolchain@stable - - run: rustup component add clippy - - uses: actions/cache@v3 with: - path: | - ./.cargo/.build - ./target - ~/.cargo - key: ${{ runner.os }}-cargo-dev-${{ hashFiles('**/Cargo.lock') }} + components: clippy + - uses: Swatinem/rust-cache@v2 + with: + shared-key: "build" - run: cargo clippy --all test-script: @@ -56,33 +54,12 @@ jobs: - uses: actions/checkout@v4 - uses: rui314/setup-mold@v1 - uses: dtolnay/rust-toolchain@stable - - uses: actions/cache@v3 + - uses: Swatinem/rust-cache@v2 with: - path: | - ./.cargo/.build - ./target - ~/.cargo - key: ${{ runner.os }}-cargo-dev-${{ hashFiles('**/Cargo.lock') }} + shared-key: "build" - run: bash test/test_all.sh - run: git diff --exit-code --stat || exit 1 - # things that use the cargo-test cache - test: - name: cargo test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: rui314/setup-mold@v1 - - uses: dtolnay/rust-toolchain@stable - - uses: actions/cache@v3 - with: - path: | - ./.cargo/.build - ./target - ~/.cargo - key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }} - - run: cargo test - # Things that don't need a cache fmt: name: cargo fmt @@ -92,13 +69,13 @@ jobs: - uses: dtolnay/rust-toolchain@stable with: toolchain: nightly - - run: rustup component add rustfmt + components: rustfmt - run: cargo fmt --all -- --check release: runs-on: ubuntu-latest name: release - needs: [build, clippy, test, test-script, fmt] + needs: [build, clippy, test-script, fmt] if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' permissions: contents: write # for actions/checkout to fetch code and for semantic-release to push commits, release releases and tags diff --git a/CHANGELOG.md b/CHANGELOG.md index 09d61f23..0ba37f6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## next + +- set MSRV to `1.70` + ## 0.1.0 - replace `structopt` with `clap` diff --git a/Cargo.toml b/Cargo.toml index f3a3fb39..304de16a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ authors = [ "hasezoey ", ] edition = "2021" +rust-version = "1.70" [features] default = ["tsync", "backtrace", "derive-queryablebyname"] diff --git a/src/code.rs b/src/code.rs index 29367b5c..44629b74 100644 --- a/src/code.rs +++ b/src/code.rs @@ -86,7 +86,7 @@ pub struct StructField { impl StructField { /// Assemble the current options into a rust type, like `base_type: String, is_optional: true` to `Option` - pub fn to_rust_type(&self) -> Cow { + pub fn to_rust_type(&self) -> Cow<'_, str> { let mut rust_type = self.base_type.clone(); // order matters! diff --git a/src/error.rs b/src/error.rs index 70d5641a..6012686e 100644 --- a/src/error.rs +++ b/src/error.rs @@ -61,10 +61,10 @@ impl Error { M: Into, P: AsRef, { - return Self::new(ErrorEnum::IoError( + Self::new(ErrorEnum::IoError( ioError::new(kind, msg.into()), format_path(path.as_ref().to_string_lossy().to_string()), - )); + )) } pub fn not_a_directory(msg: M, path: P) -> Self @@ -72,10 +72,10 @@ impl Error { M: Into, P: AsRef, { - return Self::new(ErrorEnum::NotADirectory( + Self::new(ErrorEnum::NotADirectory( msg.into(), path.as_ref().to_string_lossy().to_string(), - )); + )) } } @@ -87,7 +87,7 @@ impl std::fmt::Display for Error { impl std::error::Error for Error { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - return self.source.source(); + self.source.source() } } @@ -148,13 +148,13 @@ pub trait IOErrorToError { impl IOErrorToError for std::result::Result { fn attach_path_err>(self, path: P) -> Result { - return match self { + match self { Ok(v) => Ok(v), Err(e) => Err(crate::Error::new(ErrorEnum::IoError( e, format_path(path.as_ref().to_string_lossy().to_string()), ))), - }; + } } fn attach_path_msg, M: AsRef>(self, path: P, msg: M) -> Result {