Skip to content

Commit 27c0e7d

Browse files
authored
Switch from Travis to Github Actions (#21)
* Switch from Travis to Github Actions * Clippy fixes Co-authored-by: Franklin Delehelle <[email protected]>
1 parent c2206e3 commit 27c0e7d

File tree

11 files changed

+173
-121
lines changed

11 files changed

+173
-121
lines changed

.github/workflows/rust.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
Formatting:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v2
15+
16+
- name: Install stable toolchain
17+
uses: actions-rs/toolchain@v1
18+
with:
19+
toolchain: stable
20+
override: true
21+
components: rustfmt
22+
23+
- name: Check format
24+
run: cargo fmt -- --check
25+
26+
Linting:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v2
31+
32+
- name: Install stable toolchain
33+
uses: actions-rs/toolchain@v1
34+
with:
35+
toolchain: stable
36+
override: true
37+
components: clippy
38+
39+
- name: Lint with clippy
40+
uses: actions-rs/clippy-check@v1
41+
with:
42+
token: ${{ secrets.GITHUB_TOKEN }}
43+
44+
Testing:
45+
needs: Formatting
46+
runs-on: ${{ matrix.os }}
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
build: [linux, windows, macos]
51+
include:
52+
- build: macos
53+
os: macos-latest
54+
rust: stable
55+
- build: windows
56+
os: windows-latest
57+
rust: stable
58+
- build: linux
59+
os: ubuntu-latest
60+
rust: stable
61+
steps:
62+
- name: Checkout repository
63+
uses: actions/checkout@v2
64+
65+
- uses: actions-rs/toolchain@v1
66+
with:
67+
toolchain: ${{ matrix.rust }}
68+
override: true
69+
70+
- name: Install ${{ matrix.rust }} toolchain
71+
uses: actions-rs/toolchain@v1
72+
with:
73+
toolchain: ${{ matrix.rust }}
74+
override: true
75+
76+
- name: Run tests
77+
uses: actions-rs/cargo@v1
78+
with:
79+
command: test
80+
args: --all --no-fail-fast
81+
82+
Coverage:
83+
needs: Formatting
84+
runs-on: ubuntu-latest
85+
steps:
86+
- name: Checkout repository
87+
uses: actions/checkout@v2
88+
89+
- name: Install nightly toolchain
90+
uses: actions-rs/toolchain@v1
91+
with:
92+
toolchain: nightly
93+
override: true
94+
95+
- name: Install cargo-tarpaulin
96+
uses: actions-rs/[email protected]
97+
with:
98+
crate: cargo-tarpaulin
99+
version: latest
100+
use-tool-cache: true
101+
102+
- name: Coverage with tarpaulin
103+
run: cargo tarpaulin --all --all-features --timeout 600 --out Lcov -- --test-threads 1
104+
105+
- name: Upload coverage
106+
uses: coverallsapp/github-action@master
107+
with:
108+
github-token: ${{ secrets.GITHUB_TOKEN }}
109+
path-to-lcov: ./lcov.info

.travis.yml

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

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ repository = "https://github.com/rust-bio/rust-bio"
88
documentation = "https://docs.rs/bio"
99
readme = "README.md"
1010
license = "MIT"
11-
license-file = "LICENSE.md"
1211

1312

1413
[dependencies]

src/alignment.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl Alignment {
219219
x_pretty.push_str(&format!("{}", String::from_utf8_lossy(&[x[x_i]])));
220220
x_i += 1;
221221

222-
inb_pretty.push_str("|");
222+
inb_pretty.push('|');
223223

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

309309
s.push_str(&inb_pretty[rng.clone()]);
310-
s.push_str("\n");
310+
s.push('\n');
311311

312312
s.push_str(&y_pretty[rng]);
313-
s.push_str("\n");
313+
s.push('\n');
314314

315315
s.push_str("\n\n");
316316
idx += step;

src/annot/contig.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ impl<R, S> Contig<R, S> {
6363
/// ```
6464
pub fn new(refid: R, start: isize, length: usize, strand: S) -> Self {
6565
Contig {
66-
refid: refid,
67-
start: start,
68-
length: length,
69-
strand: strand,
66+
refid,
67+
start,
68+
length,
69+
strand,
7070
}
7171
}
7272

@@ -118,8 +118,8 @@ impl<R, S> Contig<R, S> {
118118

119119
Ok(Contig {
120120
refid: pos.refid().clone(),
121-
start: start,
122-
length: length,
121+
start,
122+
length,
123123
strand: pos.strand(),
124124
})
125125
}
@@ -131,7 +131,7 @@ impl<R, S> Contig<R, S> {
131131
refid: self.refid,
132132
start: self.start,
133133
length: self.length,
134-
strand: strand,
134+
strand,
135135
}
136136
}
137137
}
@@ -313,21 +313,15 @@ where
313313
static ref CONTIG_RE: Regex = Regex::new(r"^(.*):(\d+)-(\d+)(\([+-]\))?$").unwrap();
314314
}
315315

316-
let cap = CONTIG_RE
317-
.captures(s)
318-
.ok_or_else(|| ParseAnnotError::BadAnnot)?;
316+
let cap = CONTIG_RE.captures(s).ok_or(ParseAnnotError::BadAnnot)?;
319317

320-
let start = cap[2]
321-
.parse::<isize>()
322-
.map_err(|e| ParseAnnotError::ParseInt(e))?;
323-
let end = cap[3]
324-
.parse::<isize>()
325-
.map_err(|e| ParseAnnotError::ParseInt(e))?;
318+
let start = cap[2].parse::<isize>().map_err(ParseAnnotError::ParseInt)?;
319+
let end = cap[3].parse::<isize>().map_err(ParseAnnotError::ParseInt)?;
326320
let strand = cap
327321
.get(4)
328322
.map_or("", |m| m.as_str())
329323
.parse::<S>()
330-
.map_err(|e| ParseAnnotError::ParseStrand(e))?;
324+
.map_err(ParseAnnotError::ParseStrand)?;
331325

332326
if start <= end {
333327
Ok(Contig::new(

src/annot/pos.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ where
107107
/// ```
108108
fn add_assign(&mut self, dist: T) {
109109
match self.strand {
110-
ReqStrand::Forward => self.pos += dist.into(),
111-
ReqStrand::Reverse => self.pos -= dist.into(),
110+
ReqStrand::Forward => self.pos += dist,
111+
ReqStrand::Reverse => self.pos -= dist,
112112
}
113113
}
114114
}
@@ -138,8 +138,8 @@ where
138138
/// ```
139139
fn sub_assign(&mut self, dist: T) {
140140
match self.strand {
141-
ReqStrand::Forward => self.pos -= dist.into(),
142-
ReqStrand::Reverse => self.pos += dist.into(),
141+
ReqStrand::Forward => self.pos -= dist,
142+
ReqStrand::Reverse => self.pos += dist,
143143
}
144144
}
145145
}
@@ -169,9 +169,7 @@ impl<R, S> Loc for Pos<R, S> {
169169
Self::Strand: Into<ReqStrand> + Copy,
170170
T: Neg<Output = T> + Copy,
171171
{
172-
if self.refid != pos.refid {
173-
None
174-
} else if self.pos != pos.pos {
172+
if (self.refid != pos.refid) || (self.pos != pos.pos) {
175173
None
176174
} else {
177175
Some(Pos::new(
@@ -252,21 +250,17 @@ where
252250
static ref POS_RE: Regex = Regex::new(r"^(.*):(\d+)(\([+-]\))?$").unwrap();
253251
}
254252

255-
let cap = POS_RE
256-
.captures(s)
257-
.ok_or_else(|| ParseAnnotError::BadAnnot)?;
253+
let cap = POS_RE.captures(s).ok_or(ParseAnnotError::BadAnnot)?;
258254

259255
let strand = cap
260256
.get(3)
261257
.map_or("", |m| m.as_str())
262258
.parse::<S>()
263-
.map_err(|e| ParseAnnotError::ParseStrand(e))?;
259+
.map_err(ParseAnnotError::ParseStrand)?;
264260

265261
Ok(Pos::new(
266262
R::from(cap[1].to_owned()),
267-
cap[2]
268-
.parse::<isize>()
269-
.map_err(|e| ParseAnnotError::ParseInt(e))?,
263+
cap[2].parse::<isize>().map_err(ParseAnnotError::ParseInt)?,
270264
strand,
271265
))
272266
}

src/annot/refids.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ pub struct RefIDSet<R> {
4141
refids: HashMap<String, R>,
4242
}
4343

44+
impl<R> Default for RefIDSet<R> {
45+
fn default() -> Self {
46+
Self::new()
47+
}
48+
}
49+
4450
impl<R> RefIDSet<R> {
4551
/// Create a new, empty table of interned reference names
4652
pub fn new() -> Self {

0 commit comments

Comments
 (0)