Merge pull request #1 from Frost/ci
Add CI workflow for linting and tests
This commit is contained in:
commit
1971673660
|
|
@ -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
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
language: rust
|
|
||||||
rust:
|
|
||||||
- stable
|
|
||||||
- beta
|
|
||||||
- nightly
|
|
||||||
matrix:
|
|
||||||
allow_failures:
|
|
||||||
- rust: nightly
|
|
||||||
|
|
@ -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();
|
let all_authors = get_available_coauthors();
|
||||||
match all_authors.get(initials) {
|
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 => {
|
None => {
|
||||||
eprintln!("Error: author with initials {} not found", initials);
|
eprintln!("Error: author with initials {} not found", initials);
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
|
|
@ -52,7 +52,7 @@ fn override_main_author(initials: &String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_coauthors_to_gitmessage_file(coauthor_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");
|
let mut content = String::from("\n\n");
|
||||||
for author in &coauthors {
|
for author in &coauthors {
|
||||||
content.push_str(&format!("Co-authored-by: {}\n", &author.to_string()));
|
content.push_str(&format!("Co-authored-by: {}\n", &author.to_string()));
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ impl fmt::Display for Author {
|
||||||
pub fn get_main_author() -> Author {
|
pub fn get_main_author() -> Author {
|
||||||
let cfg = match Repository::open_from_env() {
|
let cfg = match Repository::open_from_env() {
|
||||||
Ok(repo) => repo.config().unwrap(),
|
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();
|
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| {
|
with_git_repo_or_exit(|repo| {
|
||||||
let mut config = repo.config().unwrap();
|
let mut config = repo.config().unwrap();
|
||||||
config
|
config
|
||||||
.set_str("commit.template", &".git/.gitmessage")
|
.set_str("commit.template", ".git/.gitmessage")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue