Skip to content

Commit

Permalink
Switch from Travis to Github Actions (#21)
Browse files Browse the repository at this point in the history
* Switch from Travis to Github Actions

* Clippy fixes

Co-authored-by: Franklin Delehelle <franklin.delehelle@odena.eu>
  • Loading branch information
delehef and delehef committed Jan 6, 2021
1 parent c2206e3 commit 27c0e7d
Show file tree
Hide file tree
Showing 11 changed files with 173 additions and 121 deletions.
109 changes: 109 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: CI

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

jobs:
Formatting:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt

- name: Check format
run: cargo fmt -- --check

Linting:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: clippy

- name: Lint with clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

Testing:
needs: Formatting
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
build: [linux, windows, macos]
include:
- build: macos
os: macos-latest
rust: stable
- build: windows
os: windows-latest
rust: stable
- build: linux
os: ubuntu-latest
rust: stable
steps:
- name: Checkout repository
uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true

- name: Install ${{ matrix.rust }} toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true

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

Coverage:
needs: Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true

- name: Install cargo-tarpaulin
uses: actions-rs/install@v0.1
with:
crate: cargo-tarpaulin
version: latest
use-tool-cache: true

- name: Coverage with tarpaulin
run: cargo tarpaulin --all --all-features --timeout 600 --out Lcov -- --test-threads 1

- name: Upload coverage
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./lcov.info
37 changes: 0 additions & 37 deletions .travis.yml

This file was deleted.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ repository = "https://github.com/rust-bio/rust-bio"
documentation = "https://docs.rs/bio"
readme = "README.md"
license = "MIT"
license-file = "LICENSE.md"


[dependencies]
Expand Down
8 changes: 4 additions & 4 deletions src/alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl Alignment {
x_pretty.push_str(&format!("{}", String::from_utf8_lossy(&[x[x_i]])));
x_i += 1;

inb_pretty.push_str("|");
inb_pretty.push('|');

y_pretty.push_str(&format!("{}", String::from_utf8_lossy(&[y[y_i]])));
y_i += 1;
Expand Down Expand Up @@ -304,13 +304,13 @@ impl Alignment {
while idx < ml {
let rng = idx..min(idx + step, ml);
s.push_str(&x_pretty[rng.clone()]);
s.push_str("\n");
s.push('\n');

s.push_str(&inb_pretty[rng.clone()]);
s.push_str("\n");
s.push('\n');

s.push_str(&y_pretty[rng]);
s.push_str("\n");
s.push('\n');

s.push_str("\n\n");
idx += step;
Expand Down
28 changes: 11 additions & 17 deletions src/annot/contig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ impl<R, S> Contig<R, S> {
/// ```
pub fn new(refid: R, start: isize, length: usize, strand: S) -> Self {
Contig {
refid: refid,
start: start,
length: length,
strand: strand,
refid,
start,
length,
strand,
}
}

Expand Down Expand Up @@ -118,8 +118,8 @@ impl<R, S> Contig<R, S> {

Ok(Contig {
refid: pos.refid().clone(),
start: start,
length: length,
start,
length,
strand: pos.strand(),
})
}
Expand All @@ -131,7 +131,7 @@ impl<R, S> Contig<R, S> {
refid: self.refid,
start: self.start,
length: self.length,
strand: strand,
strand,
}
}
}
Expand Down Expand Up @@ -313,21 +313,15 @@ where
static ref CONTIG_RE: Regex = Regex::new(r"^(.*):(\d+)-(\d+)(\([+-]\))?$").unwrap();
}

let cap = CONTIG_RE
.captures(s)
.ok_or_else(|| ParseAnnotError::BadAnnot)?;
let cap = CONTIG_RE.captures(s).ok_or(ParseAnnotError::BadAnnot)?;

let start = cap[2]
.parse::<isize>()
.map_err(|e| ParseAnnotError::ParseInt(e))?;
let end = cap[3]
.parse::<isize>()
.map_err(|e| ParseAnnotError::ParseInt(e))?;
let start = cap[2].parse::<isize>().map_err(ParseAnnotError::ParseInt)?;
let end = cap[3].parse::<isize>().map_err(ParseAnnotError::ParseInt)?;
let strand = cap
.get(4)
.map_or("", |m| m.as_str())
.parse::<S>()
.map_err(|e| ParseAnnotError::ParseStrand(e))?;
.map_err(ParseAnnotError::ParseStrand)?;

if start <= end {
Ok(Contig::new(
Expand Down
22 changes: 8 additions & 14 deletions src/annot/pos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ where
/// ```
fn add_assign(&mut self, dist: T) {
match self.strand {
ReqStrand::Forward => self.pos += dist.into(),
ReqStrand::Reverse => self.pos -= dist.into(),
ReqStrand::Forward => self.pos += dist,
ReqStrand::Reverse => self.pos -= dist,
}
}
}
Expand Down Expand Up @@ -138,8 +138,8 @@ where
/// ```
fn sub_assign(&mut self, dist: T) {
match self.strand {
ReqStrand::Forward => self.pos -= dist.into(),
ReqStrand::Reverse => self.pos += dist.into(),
ReqStrand::Forward => self.pos -= dist,
ReqStrand::Reverse => self.pos += dist,
}
}
}
Expand Down Expand Up @@ -169,9 +169,7 @@ impl<R, S> Loc for Pos<R, S> {
Self::Strand: Into<ReqStrand> + Copy,
T: Neg<Output = T> + Copy,
{
if self.refid != pos.refid {
None
} else if self.pos != pos.pos {
if (self.refid != pos.refid) || (self.pos != pos.pos) {
None
} else {
Some(Pos::new(
Expand Down Expand Up @@ -252,21 +250,17 @@ where
static ref POS_RE: Regex = Regex::new(r"^(.*):(\d+)(\([+-]\))?$").unwrap();
}

let cap = POS_RE
.captures(s)
.ok_or_else(|| ParseAnnotError::BadAnnot)?;
let cap = POS_RE.captures(s).ok_or(ParseAnnotError::BadAnnot)?;

let strand = cap
.get(3)
.map_or("", |m| m.as_str())
.parse::<S>()
.map_err(|e| ParseAnnotError::ParseStrand(e))?;
.map_err(ParseAnnotError::ParseStrand)?;

Ok(Pos::new(
R::from(cap[1].to_owned()),
cap[2]
.parse::<isize>()
.map_err(|e| ParseAnnotError::ParseInt(e))?,
cap[2].parse::<isize>().map_err(ParseAnnotError::ParseInt)?,
strand,
))
}
Expand Down
6 changes: 6 additions & 0 deletions src/annot/refids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ pub struct RefIDSet<R> {
refids: HashMap<String, R>,
}

impl<R> Default for RefIDSet<R> {
fn default() -> Self {
Self::new()
}
}

impl<R> RefIDSet<R> {
/// Create a new, empty table of interned reference names
pub fn new() -> Self {
Expand Down

0 comments on commit 27c0e7d

Please sign in to comment.