Skip to content

Commit 8d18df9

Browse files
authored
Merge pull request #58 from mlange-42/gh-ci-migration
Set up GH Actions CI
2 parents 3196813 + 020a8be commit 8d18df9

12 files changed

Lines changed: 206 additions & 131 deletions

File tree

.github/workflows/crates-io.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Crates.io
2+
3+
on:
4+
release:
5+
types: [ created ]
6+
7+
env:
8+
CARGO_TERM_COLOR: always
9+
10+
jobs:
11+
publish:
12+
name: Publish to crates.io
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
- name: Install Rust
18+
uses: actions-rs/toolchain@v1
19+
with:
20+
toolchain: stable
21+
override: true
22+
- name: Publish binaries
23+
uses: katyo/publish-crates@v1
24+
with:
25+
registry-token: ${{ secrets.CRATES_IO_TOKEN }}

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [ created ]
6+
7+
env:
8+
CARGO_TERM_COLOR: always
9+
REPO: git-graph
10+
11+
jobs:
12+
release:
13+
name: Release for ${{ matrix.os }}
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
include:
18+
- os: ubuntu-latest
19+
bin_extension: ""
20+
os_name: "linux-amd64"
21+
- os: windows-latest
22+
bin_extension: ".exe"
23+
os_name: "windows-amd64"
24+
- os: macos-latest
25+
bin_extension: ""
26+
os_name: "macos-amd64"
27+
28+
steps:
29+
- uses: actions/checkout@v2
30+
- name: Get tag
31+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
32+
shell: bash
33+
- name: Build
34+
run: |
35+
cargo build --release
36+
- name: Compress
37+
run: |
38+
cp -f target/release/$REPO${{ matrix.bin_extension }} .
39+
tar -czf release.tar.gz $REPO${{ matrix.bin_extension }}
40+
shell: bash
41+
- name: Upload binaries to release
42+
uses: svenstaro/upload-release-action@v2
43+
with:
44+
repo_token: ${{ secrets.GITHUB_TOKEN }}
45+
file: release.tar.gz
46+
asset_name: ${{ env.REPO }}-${{ env.RELEASE_VERSION }}-${{ matrix.os_name }}.tar.gz
47+
tag: ${{ github.ref }}

.github/workflows/tests.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
test:
14+
name: Test Suite
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout sources
18+
uses: actions/checkout@v2
19+
20+
- name: Install stable toolchain
21+
uses: actions-rs/toolchain@v1
22+
with:
23+
profile: minimal
24+
toolchain: stable
25+
override: true
26+
27+
- name: Run cargo test
28+
uses: actions-rs/cargo@v1
29+
with:
30+
command: test
31+
args: --all
32+
33+
lints:
34+
name: Lints
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout sources
38+
uses: actions/checkout@v2
39+
40+
- name: Install stable toolchain
41+
uses: actions-rs/toolchain@v1
42+
with:
43+
profile: minimal
44+
toolchain: stable
45+
override: true
46+
components: rustfmt, clippy
47+
48+
- name: Run cargo fmt
49+
uses: actions-rs/cargo@v1
50+
with:
51+
command: fmt
52+
args: --all -- --check
53+
54+
- name: Run cargo clippy
55+
uses: actions-rs/cargo@v1
56+
with:
57+
command: clippy
58+
args: --all --all-targets -- --deny warnings

.travis.yml

Lines changed: 0 additions & 52 deletions
This file was deleted.

Cargo.lock

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[package]
22
name = "git-graph"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
authors = ["Martin Lange <martin_lange_@gmx.net>"]
55
description = "Command line tool to show clear git graphs arranged for your branching model"
66
repository = "https://github.com/mlange-42/git-graph.git"
77
keywords = ["git", "graph"]
88
license = "MIT"
99
readme = "README.md"
10-
edition = "2018"
10+
edition = "2021"
1111

1212
[profile.release]
1313
opt-level = 3
@@ -19,7 +19,7 @@ overflow-checks = false
1919

2020
[dependencies]
2121
git2 = {version = "0.13", default-features = false, optional = false}
22-
regex = {version = "1.4", default-features = false, optional = false, features = ["std"]}
22+
regex = {version = "1.6", default-features = false, optional = false, features = ["std"]}
2323
serde = "1.0"
2424
serde_derive = {version = "1.0", default-features = false, optional = false}
2525
toml = "0.5"

src/config.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,8 @@ pub fn get_available_models<P: AsRef<Path>>(app_model_path: &P) -> Result<Vec<St
3434
Ok(e) => {
3535
if let (Some(name), Some(ext)) = (e.path().file_name(), e.path().extension()) {
3636
if ext == "toml" {
37-
if let Some(name) = name.to_str() {
38-
Some((&name[..(name.len() - 5)]).to_string())
39-
} else {
40-
None
41-
}
37+
name.to_str()
38+
.map(|name| (name[..(name.len() - 5)]).to_string())
4239
} else {
4340
None
4441
}

src/graph.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ impl GitGraph {
7878

7979
assign_children(&mut commits, &indices);
8080

81-
let mut all_branches = assign_branches(&repository, &mut commits, &indices, &settings)?;
82-
correct_fork_merges(&commits, &indices, &mut all_branches, &settings)?;
81+
let mut all_branches = assign_branches(&repository, &mut commits, &indices, settings)?;
82+
correct_fork_merges(&commits, &indices, &mut all_branches, settings)?;
8383
assign_sources_targets(&commits, &indices, &mut all_branches);
8484

8585
let (shortest_first, forward) = match settings.branch_order {
@@ -325,7 +325,7 @@ fn assign_branches(
325325
) -> Result<Vec<BranchInfo>, String> {
326326
let mut branch_idx = 0;
327327

328-
let mut branches = extract_branches(repository, commits, &indices, settings)?;
328+
let mut branches = extract_branches(repository, commits, indices, settings)?;
329329

330330
let mut index_map: Vec<_> = (0..branches.len())
331331
.map(|old_idx| {
@@ -342,7 +342,7 @@ fn assign_branches(
342342
}
343343
let oid = info.oid;
344344
let any_assigned =
345-
trace_branch(repository, commits, &indices, &mut branches, oid, old_idx)
345+
trace_branch(repository, commits, indices, &mut branches, oid, old_idx)
346346
.unwrap_or(false);
347347

348348
if any_assigned || !is_merged {
@@ -649,15 +649,15 @@ fn extract_branches(
649649
counter += 1;
650650
let term_col = to_terminal_color(
651651
&branch_color(
652-
&name,
652+
name,
653653
&settings.branches.terminal_colors[..],
654654
&settings.branches.terminal_colors_unknown,
655655
counter,
656656
)[..],
657657
)?;
658-
let pos = branch_order(&name, &settings.branches.order);
658+
let pos = branch_order(name, &settings.branches.order);
659659
let svg_col = branch_color(
660-
&name,
660+
name,
661661
&settings.branches.svg_colors,
662662
&settings.branches.svg_colors_unknown,
663663
counter,
@@ -736,7 +736,7 @@ fn trace_branch<'repo>(
736736
let mut temp_index = prev_index;
737737
for sibling_oid in &commits[*index].children {
738738
if sibling_oid != &curr_oid {
739-
let sibling_index = indices[&sibling_oid];
739+
let sibling_index = indices[sibling_oid];
740740
if sibling_index > temp_index {
741741
temp_index = sibling_index;
742742
}
@@ -957,27 +957,27 @@ mod tests {
957957
let bitbucket_pull = "Merged in feature/my-feature (pull request #1)";
958958

959959
assert_eq!(
960-
super::parse_merge_summary(&gitlab_pull, &patterns),
960+
super::parse_merge_summary(gitlab_pull, &patterns),
961961
Some("feature/my-feature".to_string()),
962962
);
963963
assert_eq!(
964-
super::parse_merge_summary(&git_default, &patterns),
964+
super::parse_merge_summary(git_default, &patterns),
965965
Some("feature/my-feature".to_string()),
966966
);
967967
assert_eq!(
968-
super::parse_merge_summary(&git_master, &patterns),
968+
super::parse_merge_summary(git_master, &patterns),
969969
Some("feature/my-feature".to_string()),
970970
);
971971
assert_eq!(
972-
super::parse_merge_summary(&github_pull, &patterns),
972+
super::parse_merge_summary(github_pull, &patterns),
973973
Some("feature/my-feature".to_string()),
974974
);
975975
assert_eq!(
976-
super::parse_merge_summary(&github_pull_2, &patterns),
976+
super::parse_merge_summary(github_pull_2, &patterns),
977977
Some("feature/my-feature".to_string()),
978978
);
979979
assert_eq!(
980-
super::parse_merge_summary(&bitbucket_pull, &patterns),
980+
super::parse_merge_summary(bitbucket_pull, &patterns),
981981
Some("feature/my-feature".to_string()),
982982
);
983983
}

src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ fn from_args() -> Result<(), String> {
278278
let debug = matches.is_present("debug");
279279
let style = matches
280280
.value_of("style")
281-
.map(|s| Characters::from_str(s))
281+
.map(Characters::from_str)
282282
.unwrap_or_else(|| Ok(Characters::thin()))?;
283283

284284
let model = get_model(
@@ -338,7 +338,7 @@ fn from_args() -> Result<(), String> {
338338
strings.join(" ")
339339
)
340340
})?;
341-
Some((None, wrap.get(0).cloned(), wrap.get(1).cloned()))
341+
Some((None, wrap.first().cloned(), wrap.get(1).cloned()))
342342
}
343343
_ => {
344344
let wrap = strings
@@ -352,7 +352,7 @@ fn from_args() -> Result<(), String> {
352352
)
353353
})?;
354354
Some((
355-
wrap.get(0).cloned(),
355+
wrap.first().cloned(),
356356
wrap.get(1).cloned(),
357357
wrap.get(2).cloned(),
358358
))
@@ -408,9 +408,9 @@ fn run(
408408
let now = Instant::now();
409409

410410
if svg {
411-
println!("{}", print_svg(&graph, &settings)?);
411+
println!("{}", print_svg(&graph, settings)?);
412412
} else {
413-
let (g_lines, t_lines, _indices) = print_unicode(&graph, &settings)?;
413+
let (g_lines, t_lines, _indices) = print_unicode(&graph, settings)?;
414414
if pager && atty::is(atty::Stream::Stdout) {
415415
print_paged(&g_lines, &t_lines).map_err(|err| err.to_string())?;
416416
} else {

0 commit comments

Comments
 (0)