From 5162dbee8ee29aac74914b919cad7c5bffb07995 Mon Sep 17 00:00:00 2001 From: Hubert Date: Fri, 24 Jun 2022 11:43:48 +0200 Subject: [PATCH] add proper CI (#3) * add proper CI * fmt * badge * bump edition * working badge for crates.io --- .github/workflows/rust.yml | 104 ++++++++++++++++++++++++++++++++----- Cargo.toml | 4 +- README.md | 4 +- src/bin/wake.rs | 2 +- 4 files changed, 97 insertions(+), 17 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index d54fa2f..3710567 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,22 +1,102 @@ name: Rust on: - push: - branches: [ "master" ] pull_request: - branches: [ "master" ] - -env: - CARGO_TERM_COLOR: always + branches: + - master + push: + branches: + - master jobs: - build: + test: + name: test + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + - name: Checkout Sources + uses: actions/checkout@v3 + - name: Install Toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + - name: Rust Cache + uses: Swatinem/rust-cache@v1.4.0 + - name: Run tests + run: cargo test --verbose + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + - name: Checkout Sources + uses: actions/checkout@v3 + - name: Install Toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + - name: Install Clippy + run: rustup component add clippy + - name: Install RustFmt + run: rustup component add rustfmt + - name: Rust Cache + uses: Swatinem/rust-cache@v1.4.0 + - name: Run format check + run: cargo fmt --all --check + - name: Run clippy + run: cargo clippy --all --all-targets -- -D warnings + + audit: + name: Audit runs-on: ubuntu-latest + steps: + - name: Checkout Sources + uses: actions/checkout@v2 + - name: Install Toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + - name: Install Audit + run: cargo install cargo-audit + - name: Rust Cache + uses: Swatinem/rust-cache@v1.4.0 + - name: Run Audit + uses: actions-rs/cargo@v1 + with: + command: audit + build: + name: Build + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + rv: [stable, beta, nightly] steps: - - uses: actions/checkout@v3 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + - name: Checkout Sources + uses: actions/checkout@v2 + - name: Install Toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rv }} + - name: Rust Cache + uses: Swatinem/rust-cache@v1.4.0 + - name: Cargo Build + uses: actions-rs/cargo@v1 + with: + command: build diff --git a/Cargo.toml b/Cargo.toml index c68bcc5..c76306e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "wakey" -version = "0.1.2" +version = "0.2.0" authors = ["Hubert Bugaj"] -edition = "2018" +edition = "2021" license = "MIT" repository = "https://github.com/LesnyRumcajs/wakey" diff --git a/README.md b/README.md index dfd04ec..2fc3145 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Wakey -[![Build Status](https://travis-ci.com/LesnyRumcajs/wakey.svg?branch=master)](https://travis-ci.com/LesnyRumcajs/wakey) -[![Build Status](http://meritbadge.herokuapp.com/wakey)](https://crates.io/crates/wakey/) +[![Rust](https://github.com/LesnyRumcajs/wakey/actions/workflows/rust.yml/badge.svg)](https://github.com/LesnyRumcajs/wakey/actions/workflows/rust.yml) +[![Crates.io](https://img.shields.io/crates/v/wakey.svg)](https://crates.io/crates/wakey) [![docs.rs](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/wakey) Library for managing Wake-on-LAN packets. It supports: diff --git a/src/bin/wake.rs b/src/bin/wake.rs index 0c08148..76e5737 100644 --- a/src/bin/wake.rs +++ b/src/bin/wake.rs @@ -10,7 +10,7 @@ struct CmdArgs { fn main() { let args = CmdArgs::parse(); if let Some(m) = args.mac { - let sep = m.chars().find(|ch| *ch == ':' || *ch == '-').unwrap_or('/'); + let sep = m.chars().find(|ch| *ch == ':' || *ch == '-').unwrap_or('/'); let wol = wakey::WolPacket::from_string(&m, sep); if wol.send_magic().is_ok() { println!("sent the magic packet.");