Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
larkinscott committed Jan 29, 2024
0 parents commit 8cdf673
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Main
on:
push:
branches:
- main

permissions:
actions: write
contents: read

jobs:
test:
name: Test
runs-on: ubuntu-latest-16-cores

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]

- name: Checkout repo
uses: actions/checkout@v3

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: cargo build
run: cargo build --workspace --verbose

- name: cargo test
run: cargo llvm-cov --all-features --workspace --lcov --output-path target/lcov.info

- name: Download and install qlty CLI
run: curl -fsSL https://tinyurl.com/qlty-beta-install | bash

- name: qlty init
run: ~/.qlty/bin/qlty init --no

- name: Upload coverage to qlty
run: PROJECT_ID=e02159bf-9c4b-411f-afe2-d824ee3ff475 ~/.qlty/bin/qlty coverage ./target/lcov.info --verbose --upload --tag rust-example-coverage
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "rust_example"
version = "0.1.0"
edition = "2021"

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

[dependencies]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Qlty Rust coverage setup example
34 changes: 34 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
fn add(a: i32, b: i32) -> i32 {
a + b
}

fn subtract(a: i32, b: i32) -> i32 {
a - b
}

fn multiply(a: i32, b: i32) -> i32 {
a * b
}

fn main() {
println!("Hello, world!");

println!("3 + 2 = {}", add(3, 2));
println!("5 - 3 = {}", subtract(5, 3));
println!("4 * 3 = {}", multiply(4, 3));
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_add() {
assert_eq!(add(2, 2), 4);
}

#[test]
fn test_subtract() {
assert_eq!(subtract(5, 3), 2);
}
}

0 comments on commit 8cdf673

Please sign in to comment.