Skip to content

Commit

Permalink
Add CI workflows (#1)
Browse files Browse the repository at this point in the history
* Fix some clippy warnings

* Add CI workflow

* fmt

* Annotate placeholders with allow(dead_code)

* CI changes

* Caching

* Release

* No cache on mac

* No caching on mac
  • Loading branch information
iravid authored Oct 27, 2021
1 parent 5d83831 commit 12f4f14
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 4 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
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
61 changes: 61 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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}}
6 changes: 4 additions & 2 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ impl Coordinate {

#[derive(Debug, Clone)]
pub enum Revision {
#[allow(dead_code)]
Semver {
major: SemverComponent,
minor: SemverComponent,
Expand All @@ -86,6 +87,7 @@ impl Display for Revision {
}

#[derive(Debug, Clone)]
#[allow(dead_code)]
pub enum SemverComponent {
Fixed(u8),
Wildcard,
Expand Down Expand Up @@ -219,8 +221,8 @@ fn parse_revision(value: &toml::Value) -> Result<Revision, ParseError> {
})
}

fn _parse_semver(revstring: &String) -> Result<Revision, ParseError> {
let results = SEMVER_REGEX.captures(&revstring);
fn _parse_semver(revstring: &str) -> Result<Revision, ParseError> {
let results = SEMVER_REGEX.captures(revstring);

Ok(
match (
Expand Down
12 changes: 10 additions & 2 deletions src/proto_repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down

0 comments on commit 12f4f14

Please sign in to comment.