Skip to content

Commit

Permalink
Setup Github actions (#1)
Browse files Browse the repository at this point in the history
* converted project to workspace to extract benchmark code from library to enable building for stable

* added workflow to build on nightly, stable and perform benchmarks

* fixed clippy lints

* reformatted everything with rustfmt

* reformatted everything with rustfmt

* using single workflow which includes build, check, fmt, clippy, test and benchmarks

* only building on push

* fixed typos and removed pull_request target

* only building irc-rust

* using 1.40.0 as MSRV and updated install instructions in readme

* running github-actions check and clippy only for irc-rust project

* added missing parallel-finished arg for grcov-finalize

* only testing on nightly so benchmarks are also counted

* removed panic_abort flags for tests with coverage as they fail if benchmarks are present too

* enabling lto for benchmarks

* added coveralls test coverage

* added workaround to replace double colons in github-action

* using underscores instead of spaces for benchmark result workaround

* added personal token to benchmark uploads

* only running test coverage for irc-rust package

Co-authored-by: moblaa <moblaa@pm.me>
  • Loading branch information
MoBlaa and moblaa committed Sep 7, 2020
1 parent f177d0f commit 07084d3
Show file tree
Hide file tree
Showing 18 changed files with 422 additions and 135 deletions.
208 changes: 208 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
name: Rust Overall workflow

on: [push]

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
- nightly
- 1.40.0
steps:
- uses: actions/checkout@v2
- name: Loading Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.rust }}
- name: Install latest toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Run cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: --package irc-rust
check:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
- nightly
- 1.40.0
steps:
- uses: actions/checkout@v2
- name: Loading Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.rust }}
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check
args: --package irc-rust
fmt:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
- nightly
- 1.40.0
steps:
- uses: actions/checkout@v2
- name: Loading Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.rust }}
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: rustfmt
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
- nightly
- 1.40.0
steps:
- uses: actions/checkout@v2
- name: Loading Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.rust }}
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: clippy
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --package irc-rust -- -D warnings
test:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- nightly
steps:
- uses: actions/checkout@v2
- name: Loading Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.rust }}
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --package irc-rust
env:
CARGO_INCREMENTAL: 0
# '-Cpanic=abort -Zpanic_abort_tests' fails if benchmarks are part of tests
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off"
- name: Gather coverage data
id: coverage
uses: actions-rs/grcov@v0.1
with:
coveralls-token: ${{ secrets.COVERALLS_TOKEN }}
- name: Coveralls upload
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel: true
path-to-lcov: ${{ steps.coverage.outputs.report }}
grcov_finalize:
runs-on: ubuntu-latest
needs: test
steps:
- name: Coveralls finalization
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
bench:
# Benchmarks can only run on nightly yet
# Currently fails to extract benchmark information https://github.com/rhysd/github-action-benchmark/issues/39
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Loading Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-nightly
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- name: Benchmarks
# Currently fails to extract benchmark information https://github.com/rhysd/github-action-benchmark/issues/39
# Thats why '::' is replaced with ' '
run: cargo +nightly bench | sed 's/::/__/' | tee output.txt
- name: Store benchmark result
uses: rhysd/github-action-benchmark@v1
with:
tool: 'cargo'
output-file-path: output.txt
github-token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
auto-push: true
28 changes: 7 additions & 21 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
[package]
name = "irc-rust"
version = "0.3.0"
authors = ["mo_blaa <mo.blaa@pm.me>"]
edition = "2018"
description = "IRC Helper easing the access and creation of IRC Messages"
documentation = "https://docs.rs/irc_rust"
homepage = "https://github.com/MoBlaa/irc_rust"
repository = "https://github.com/MoBlaa/irc_rust"
license = "MIT"
readme = "README.md"
keywords = ["irc", "api"]
categories = ["parser-implementations", "encoding"]
[workspace]
members = [
"lib",
"bench"
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = { version = "1.0.111", optional = true, features = ["derive"]}

[dev-dependencies]
rand = "0.7.3"
serde_json = "1.0.53"
[profile.bench]
lto = true
10 changes: 0 additions & 10 deletions Makefile

This file was deleted.

37 changes: 32 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
# irc-rust [![https://docs.rs/irc-rust/badge.svg](https://docs.rs/irc-rust/badge.svg)](https://docs.rs/irc-rust) [![crates.io](https://img.shields.io/crates/v/irc-rust.svg)](https://crates.io/crates/irc-rust)
IRC Helper easing the access and creation of IRC Messages.
# irc-rust [![https://docs.rs/irc-rust/badge.svg](https://docs.rs/irc-rust/badge.svg)](https://docs.rs/irc-rust) [![crates.io](https://img.shields.io/crates/v/irc-rust.svg)](https://crates.io/crates/irc-rust) [![Coverage Status](https://coveralls.io/repos/github/MoBlaa/irc_rust/badge.svg?branch=github-actions)](https://coveralls.io/github/MoBlaa/irc_rust?branch=github-actions)
IRC Helper easing the access and creation of IRC Messages. Minimum supported rust version (MRSV) is **1.40.0**.

Github-actions runs `build`, `check`, `fmt`, `clippy` and `test` against the latest stable, nightly and 1.40.0 rust toolchains.

## Installation

Requirements:

- [`Install nightly Rust toolchain`](https://www.rust-lang.org/tools/install):
```shell script
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y
.rustup.rs | sh
```

Installation:

- Add to `Cargo.toml`:
```toml
[dependencies]
irc-rust = "0.3"
```
- Or use [`cargo edit`](https://github.com/killercup/cargo-edit) to get the latest every time:
```shell script
cargo install cargo-edit
cargo add irc-rust # In your project root
```

## Basic Usage

```rust
use irc_rust::Message;

let message = Message::from("@key1=value1;key2=value2 :name!user@host CMD param1 param2 :trailing");

assert_eq!(message.to_string(), "@key1=value1;key2=value2 :name!user@host CMD param1 param2 :trailing");
fn main() {
let message = Message::from("@key1=value1;key2=value2 :name!user@host CMD param1 param2 :trailing");

assert_eq!(message.to_string(), "@key1=value1;key2=value2 :name!user@host CMD param1 param2 :trailing");
}
```
21 changes: 21 additions & 0 deletions bench/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "irc-rust-bench"
version = "0.1.0"
authors = ["moblaa <moblaa@pm.me>"]
edition = "2018"
description = "Benchmarking project for irc-rust to enable building for stable"
license = "MIT"
repository = "https://github.com/MoBlaa/irc_rust.git"
readme = "../README.md"
keywords = ["benchmarks"]
categories = ["benchmarks"]
publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
irc-rust = { path = "../lib" }

[dev-dependencies]
rand = "0.7.3"
serde_json = "1.0.53"
6 changes: 2 additions & 4 deletions src/bench.rs → bench/src/bench.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
extern crate rand;
extern crate test;

use test::Bencher;

use rand::Rng;
use test::Bencher;

use crate::message::Message;
use crate::{Params, Tags, InvalidIrcFormatError};
use irc_rust::{InvalidIrcFormatError, Message, Params, Tags};
use std::convert::TryFrom;

#[bench]
Expand Down
6 changes: 6 additions & 0 deletions bench/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#![feature(test)]
#![allow(clippy::cargo)]
#![allow(clippy::all)]

#[cfg(test)]
mod bench;
27 changes: 27 additions & 0 deletions lib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Cargo
# will have compiled files and executables
/target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk


#Added by cargo

/target


#Added by cargo
#
#already existing elements were commented out

#/target
#Cargo.lock

.idea
*.iml
*.iws
22 changes: 22 additions & 0 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "irc-rust"
version = "0.3.0"
authors = ["mo_blaa <mo.blaa@pm.me>"]
edition = "2018"
description = "IRC Helper easing the access and creation of IRC Messages"
documentation = "https://docs.rs/irc_rust"
homepage = "https://github.com/MoBlaa/irc_rust"
repository = "https://github.com/MoBlaa/irc_rust"
license = "MIT"
readme = "../README.md"
keywords = ["irc", "api"]
categories = ["parser-implementations", "encoding"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = { version = "1.0.111", optional = true, features = ["derive"]}

[dev-dependencies]
rand = "0.7.3"
serde_json = "1.0.53"
File renamed without changes.
Loading

0 comments on commit 07084d3

Please sign in to comment.