Skip to content

Set up GH Actions CI #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/crates-io.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Crates.io

on:
release:
types: [ created ]

env:
CARGO_TERM_COLOR: always

jobs:
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Publish binaries
uses: katyo/publish-crates@v1
with:
registry-token: ${{ secrets.CRATES_IO_TOKEN }}
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Release

on:
release:
types: [ created ]

env:
CARGO_TERM_COLOR: always
REPO: git-graph

jobs:
release:
name: Release for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
bin_extension: ""
os_name: "linux-amd64"
- os: windows-latest
bin_extension: ".exe"
os_name: "windows-amd64"
- os: macos-latest
bin_extension: ""
os_name: "macos-amd64"

steps:
- uses: actions/checkout@v2
- name: Get tag
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
shell: bash
- name: Build
run: |
cargo build --release
- name: Compress
run: |
cp -f target/release/$REPO${{ matrix.bin_extension }} .
tar -czf release.tar.gz $REPO${{ matrix.bin_extension }}
shell: bash
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: release.tar.gz
asset_name: ${{ env.REPO }}-${{ env.RELEASE_VERSION }}-${{ matrix.os_name }}.tar.gz
tag: ${{ github.ref }}
58 changes: 58 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
CARGO_TERM_COLOR: always

jobs:
test:
name: Test Suite
runs-on: ubuntu-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

- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --all

lints:
name: Lints
runs-on: ubuntu-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
components: rustfmt, clippy

- name: Run 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: --all --all-targets -- --deny warnings
52 changes: 0 additions & 52 deletions .travis.yml

This file was deleted.

12 changes: 7 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "git-graph"
version = "0.5.0"
version = "0.5.1"
authors = ["Martin Lange <martin_lange_@gmx.net>"]
description = "Command line tool to show clear git graphs arranged for your branching model"
repository = "https://github.com/mlange-42/git-graph.git"
keywords = ["git", "graph"]
license = "MIT"
readme = "README.md"
edition = "2018"
edition = "2021"

[profile.release]
opt-level = 3
Expand All @@ -19,7 +19,7 @@ overflow-checks = false

[dependencies]
git2 = {version = "0.13", default-features = false, optional = false}
regex = {version = "1.4", default-features = false, optional = false, features = ["std"]}
regex = {version = "1.6", default-features = false, optional = false, features = ["std"]}
serde = "1.0"
serde_derive = {version = "1.0", default-features = false, optional = false}
toml = "0.5"
Expand Down
7 changes: 2 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ pub fn get_available_models<P: AsRef<Path>>(app_model_path: &P) -> Result<Vec<St
Ok(e) => {
if let (Some(name), Some(ext)) = (e.path().file_name(), e.path().extension()) {
if ext == "toml" {
if let Some(name) = name.to_str() {
Some((&name[..(name.len() - 5)]).to_string())
} else {
None
}
name.to_str()
.map(|name| (name[..(name.len() - 5)]).to_string())
} else {
None
}
Expand Down
28 changes: 14 additions & 14 deletions src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ impl GitGraph {

assign_children(&mut commits, &indices);

let mut all_branches = assign_branches(&repository, &mut commits, &indices, &settings)?;
correct_fork_merges(&commits, &indices, &mut all_branches, &settings)?;
let mut all_branches = assign_branches(&repository, &mut commits, &indices, settings)?;
correct_fork_merges(&commits, &indices, &mut all_branches, settings)?;
assign_sources_targets(&commits, &indices, &mut all_branches);

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

let mut branches = extract_branches(repository, commits, &indices, settings)?;
let mut branches = extract_branches(repository, commits, indices, settings)?;

let mut index_map: Vec<_> = (0..branches.len())
.map(|old_idx| {
Expand All @@ -342,7 +342,7 @@ fn assign_branches(
}
let oid = info.oid;
let any_assigned =
trace_branch(repository, commits, &indices, &mut branches, oid, old_idx)
trace_branch(repository, commits, indices, &mut branches, oid, old_idx)
.unwrap_or(false);

if any_assigned || !is_merged {
Expand Down Expand Up @@ -649,15 +649,15 @@ fn extract_branches(
counter += 1;
let term_col = to_terminal_color(
&branch_color(
&name,
name,
&settings.branches.terminal_colors[..],
&settings.branches.terminal_colors_unknown,
counter,
)[..],
)?;
let pos = branch_order(&name, &settings.branches.order);
let pos = branch_order(name, &settings.branches.order);
let svg_col = branch_color(
&name,
name,
&settings.branches.svg_colors,
&settings.branches.svg_colors_unknown,
counter,
Expand Down Expand Up @@ -736,7 +736,7 @@ fn trace_branch<'repo>(
let mut temp_index = prev_index;
for sibling_oid in &commits[*index].children {
if sibling_oid != &curr_oid {
let sibling_index = indices[&sibling_oid];
let sibling_index = indices[sibling_oid];
if sibling_index > temp_index {
temp_index = sibling_index;
}
Expand Down Expand Up @@ -957,27 +957,27 @@ mod tests {
let bitbucket_pull = "Merged in feature/my-feature (pull request #1)";

assert_eq!(
super::parse_merge_summary(&gitlab_pull, &patterns),
super::parse_merge_summary(gitlab_pull, &patterns),
Some("feature/my-feature".to_string()),
);
assert_eq!(
super::parse_merge_summary(&git_default, &patterns),
super::parse_merge_summary(git_default, &patterns),
Some("feature/my-feature".to_string()),
);
assert_eq!(
super::parse_merge_summary(&git_master, &patterns),
super::parse_merge_summary(git_master, &patterns),
Some("feature/my-feature".to_string()),
);
assert_eq!(
super::parse_merge_summary(&github_pull, &patterns),
super::parse_merge_summary(github_pull, &patterns),
Some("feature/my-feature".to_string()),
);
assert_eq!(
super::parse_merge_summary(&github_pull_2, &patterns),
super::parse_merge_summary(github_pull_2, &patterns),
Some("feature/my-feature".to_string()),
);
assert_eq!(
super::parse_merge_summary(&bitbucket_pull, &patterns),
super::parse_merge_summary(bitbucket_pull, &patterns),
Some("feature/my-feature".to_string()),
);
}
Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ fn from_args() -> Result<(), String> {
let debug = matches.is_present("debug");
let style = matches
.value_of("style")
.map(|s| Characters::from_str(s))
.map(Characters::from_str)
.unwrap_or_else(|| Ok(Characters::thin()))?;

let model = get_model(
Expand Down Expand Up @@ -338,7 +338,7 @@ fn from_args() -> Result<(), String> {
strings.join(" ")
)
})?;
Some((None, wrap.get(0).cloned(), wrap.get(1).cloned()))
Some((None, wrap.first().cloned(), wrap.get(1).cloned()))
}
_ => {
let wrap = strings
Expand All @@ -352,7 +352,7 @@ fn from_args() -> Result<(), String> {
)
})?;
Some((
wrap.get(0).cloned(),
wrap.first().cloned(),
wrap.get(1).cloned(),
wrap.get(2).cloned(),
))
Expand Down Expand Up @@ -408,9 +408,9 @@ fn run(
let now = Instant::now();

if svg {
println!("{}", print_svg(&graph, &settings)?);
println!("{}", print_svg(&graph, settings)?);
} else {
let (g_lines, t_lines, _indices) = print_unicode(&graph, &settings)?;
let (g_lines, t_lines, _indices) = print_unicode(&graph, settings)?;
if pager && atty::is(atty::Stream::Stdout) {
print_paged(&g_lines, &t_lines).map_err(|err| err.to_string())?;
} else {
Expand Down
Loading