diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f7b9144 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,46 @@ +on: push + +name: CI + +jobs: + lint_and_test: + name: lint and test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: clippy, rustfmt + - uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --all-features -- -D warnings + - run: cargo check --workspace --all-features + - run: cargo test --all-targets + - run: cargo fmt --all -- --check + + build_package: + needs: lint_and_test + if: github.ref == 'refs/heads/main' + name: Build package + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - run: cargo build --release + - uses: actions/upload-artifact@v2 + with: + name: git-mob-${{ matrix.os }} + path: | + target/release/git-* + !target/release/*.d diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8c91a74..0000000 --- a/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: rust -rust: - - stable - - beta - - nightly -matrix: - allow_failures: - - rust: nightly diff --git a/src/bin/git-mob.rs b/src/bin/git-mob.rs index aa9a39b..2ff9a5f 100644 --- a/src/bin/git-mob.rs +++ b/src/bin/git-mob.rs @@ -40,10 +40,10 @@ fn list_coauthors() { } } -fn override_main_author(initials: &String) { +fn override_main_author(initials: &str) { let all_authors = get_available_coauthors(); match all_authors.get(initials) { - Some(new_main_author) => set_main_author(&new_main_author), + Some(new_main_author) => set_main_author(new_main_author), None => { eprintln!("Error: author with initials {} not found", initials); process::exit(1); @@ -52,7 +52,7 @@ fn override_main_author(initials: &String) { } fn write_coauthors_to_gitmessage_file(coauthor_initials: &[String]) { - let coauthors = select_coauthors(&coauthor_initials); + let coauthors = select_coauthors(coauthor_initials); let mut content = String::from("\n\n"); for author in &coauthors { content.push_str(&format!("Co-authored-by: {}\n", &author.to_string())); diff --git a/src/lib.rs b/src/lib.rs index 11020e9..e3882a4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,7 +26,7 @@ impl fmt::Display for Author { pub fn get_main_author() -> Author { let cfg = match Repository::open_from_env() { Ok(repo) => repo.config().unwrap(), - Err(_e) => Config::open_default().unwrap() + Err(_e) => Config::open_default().unwrap(), }; let name = cfg.get_entry("user.name").unwrap(); @@ -50,7 +50,7 @@ pub fn ensure_commit_template_is_set() { with_git_repo_or_exit(|repo| { let mut config = repo.config().unwrap(); config - .set_str("commit.template", &".git/.gitmessage") + .set_str("commit.template", ".git/.gitmessage") .unwrap(); }) }