Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 19 additions & 42 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: CI
on:
push:
branches:
- main
pull_request:
workflow_dispatch:

Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## next

- set MSRV to `1.70`

## 0.1.0

- replace `structopt` with `clap`
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ authors = [
"hasezoey <[email protected]>",
]
edition = "2021"
rust-version = "1.70"

[features]
default = ["tsync", "backtrace", "derive-queryablebyname"]
Expand Down
2 changes: 1 addition & 1 deletion src/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>`
pub fn to_rust_type(&self) -> Cow<str> {
pub fn to_rust_type(&self) -> Cow<'_, str> {
let mut rust_type = self.base_type.clone();

// order matters!
Expand Down
14 changes: 7 additions & 7 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,21 @@ impl Error {
M: Into<String>,
P: AsRef<Path>,
{
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<M, P>(msg: M, path: P) -> Self
where
M: Into<String>,
P: AsRef<Path>,
{
return Self::new(ErrorEnum::NotADirectory(
Self::new(ErrorEnum::NotADirectory(
msg.into(),
path.as_ref().to_string_lossy().to_string(),
));
))
}
}

Expand All @@ -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()
}
}

Expand Down Expand Up @@ -148,13 +148,13 @@ pub trait IOErrorToError<T> {

impl<T> IOErrorToError<T> for std::result::Result<T, std::io::Error> {
fn attach_path_err<P: AsRef<Path>>(self, path: P) -> Result<T> {
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<P: AsRef<Path>, M: AsRef<str>>(self, path: P, msg: M) -> Result<T> {
Expand Down
Loading