Skip to content

Commit

Permalink
fix: workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmuente committed Sep 13, 2021
1 parent cfce138 commit 828ec46
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 13 deletions.
60 changes: 57 additions & 3 deletions .github/workflows/build.yml
@@ -1,10 +1,64 @@
on: [push, pull_request]

name: Continuous integration

jobs:
build:
name: build
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- run: cargo build --release --all-features
override: true
- uses: actions-rs/cargo@v1
with:
command: check

test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
16 changes: 6 additions & 10 deletions src/main.rs
@@ -1,10 +1,10 @@
use clap::{AppSettings, Clap};
use exitcode;
use std::net::TcpStream;
use std::thread;
use std::sync::mpsc;
use std::sync::Arc;
use std::sync::Mutex;
use std::sync::mpsc;
use exitcode;
use std::thread;

#[derive(Clap)]
#[clap(version = "1.0", author = "Josh M. <https://github.com/joshmuente>")]
Expand All @@ -17,7 +17,7 @@ struct Opts {
#[clap(short, long, takes_value = true, default_value = "65535")]
to_port: usize,
#[clap(short, long, takes_value = true, default_value = "10")]
amount_thread: usize
amount_thread: usize,
}

pub struct ThreadPool {
Expand Down Expand Up @@ -112,12 +112,10 @@ fn main() {

let pool = ThreadPool::new(opts.amount_thread);

for i in opts.from_port..opts.to_port+1 {
for i in opts.from_port..opts.to_port + 1 {
let x = i.clone();
let host = opts.host.clone();
pool.execute(move || {
check_port(host, x as i32)
});
pool.execute(move || check_port(host, x as i32));
}

drop(pool);
Expand All @@ -131,5 +129,3 @@ fn check_port(host: String, port: i32) {
println!("{} open", port);
}
}


0 comments on commit 828ec46

Please sign in to comment.