diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..fe21ad6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,89 @@ +on: [pull_request] + +name: CI + +jobs: + linting: + name: Linting + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Cache Rust dependencies + uses: actions/cache@v1.0.1 + with: + path: target + key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.OS }}-build- + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: rustfmt, clippy + + - name: cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + - name: Run cargo clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings + + - name: cargo check + uses: actions-rs/cargo@v1 + with: + command: check + ci-linux: + name: CI Linux + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Cache Rust dependencies + uses: actions/cache@v1.0.1 + with: + path: target + key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.OS }}-build- + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - name: cargo test + uses: actions-rs/cargo@v1 + with: + command: test + ci-mac: + name: CI MacOS + runs-on: macos-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + target: x86_64-apple-darwin + override: true + + - name: cargo test + uses: actions-rs/cargo@v1 + with: + command: test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..fe837af --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,61 @@ +name: Release + +on: + release: + types: [published] + +jobs: + release-linux: + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Cache Rust dependencies + uses: actions/cache@v1.0.1 + with: + path: target + key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.OS }}-build- + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - name: Build for release + run: cargo build --release + + - name: Upload binary to release + run: | + TAG_NAME=${GITHUB_REF#refs/tags/} + gh release upload $TAG_NAME 'target/release/protofetch#protofetch-linux' + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + release-mac: + runs-on: macos-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + target: x86_64-apple-darwin + + - name: Build for release + run: cargo build --release + + - name: Upload binary to release + run: | + TAG_NAME=${GITHUB_REF#refs/tags/} + gh release upload $TAG_NAME 'target/release/protofetch#protofetch-macos' + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/src/model.rs b/src/model.rs index 35691e3..00aaca1 100644 --- a/src/model.rs +++ b/src/model.rs @@ -62,6 +62,7 @@ impl Coordinate { #[derive(Debug, Clone)] pub enum Revision { + #[allow(dead_code)] Semver { major: SemverComponent, minor: SemverComponent, @@ -86,6 +87,7 @@ impl Display for Revision { } #[derive(Debug, Clone)] +#[allow(dead_code)] pub enum SemverComponent { Fixed(u8), Wildcard, @@ -219,8 +221,8 @@ fn parse_revision(value: &toml::Value) -> Result { }) } -fn _parse_semver(revstring: &String) -> Result { - let results = SEMVER_REGEX.captures(&revstring); +fn _parse_semver(revstring: &str) -> Result { + let results = SEMVER_REGEX.captures(revstring); Ok( match ( diff --git a/src/proto_repository.rs b/src/proto_repository.rs index 2e2aadd..391a964 100644 --- a/src/proto_repository.rs +++ b/src/proto_repository.rs @@ -116,11 +116,19 @@ impl ProtoRepository { wanted_path: worktree_path.to_str().unwrap_or("").to_string(), }); } else { - log::info!("Found existing worktree for {} at {}", self_name, canonical_wanted_path.to_string_lossy()); + log::info!( + "Found existing worktree for {} at {}", + self_name, + canonical_wanted_path.to_string_lossy() + ); } } Err(_) => { - log::info!("Creating new worktree for {} at {}", self_name, worktree_path.to_string_lossy()); + log::info!( + "Creating new worktree for {} at {}", + self_name, + worktree_path.to_string_lossy() + ); self.git_repo .worktree(worktree_name, &worktree_path, None)?;