Skip to content

Commit

Permalink
added github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
0xMimir committed Sep 16, 2023
1 parent ec9fa22 commit 6890206
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 7 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Rust

on:
push:
branches: ["master"]


env:
CARGO_TERM_COLOR: always

jobs:
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt, clippy

- uses: Swatinem/rust-cache@v2

- name: Clippy
run: cargo clippy -- -D warnings

tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt, clippy

- name: Install tarpaulin
run: cargo install cargo-tarpaulin

- uses: Swatinem/rust-cache@v2

- name: Run tests
run: cargo tarpaulin --out xml --skip-clean

- name: Upload to codecov.io
uses: codecov/codecov-action@v3
with:
verbose: true
15 changes: 9 additions & 6 deletions src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ pub struct Brokr {
pub(crate) reqwest: Client,
}

impl Default for Brokr{
fn default() -> Self {
Self::new()
}
}

impl Brokr {
pub fn new() -> Self {
let mut link_finder = LinkFinder::default();
Expand All @@ -23,11 +29,11 @@ impl Brokr {
link_finder,
}
}

pub fn find_broken_lines(
&self,
path: &String,
extensions: &Vec<&str>,
extensions: &[&str],
) -> Result<Vec<InvalidLink>> {
let files = recurse_files(path, extensions)?;
let mut _invalid_links = Vec::new();
Expand Down Expand Up @@ -77,10 +83,7 @@ impl Brokr {
Err(_) => return true,
};

match response.error_for_status() {
Ok(_) => false,
Err(_) => true,
}
response.error_for_status().is_err()
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/lib-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use brokr::Brokr;
fn test_domain() {
let path = ".".to_owned();
let extensions = vec!["md", "html", "txt"];
let brokr = Brokr::new();
let brokr = Brokr::default();
let broken_links = brokr.find_broken_lines(&path, &extensions).unwrap();
let links = broken_links
.iter()
Expand Down

0 comments on commit 6890206

Please sign in to comment.