Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: coverall test coverage support on CI #72

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@

name: Test Coverage

on:
push:
branches:
- main
- dev
tags:
- '**'
pull_request:
branches:
- '**'

jobs:
coverage:
name: Test Coverage
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1

- uses: actions/setup-python@v2
name: Install Python 3.9
with:
python-version: 3.9

- name: Update pip
run: |
python -m pip install --upgrade pip

- name: Set up rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
default: true
profile: minimal
components: llvm-tools-preview

- name: Install dependencies
run: |
python -m venv venv
ln -s venv/bin/activate
. ./activate

git clone https://github.com/Chia-Network/clvm_tools.git --branch=develop --single-branch
git clone https://github.com/Chia-Network/clvm.git --branch=develop --single-branch
python -m pip install ./clvm_tools
python -m pip install ./clvm
python -m pip install colorama
python -m pip install maturin
python -m pip install pytest
sudo apt install lcov

rustup target add x86_64-unknown-linux-musl
cargo install grcov
cargo install cargo-binutils

- name: Build
run: |
. ./activate
RUSTFLAGS="-Zinstrument-coverage" maturin develop

- name: Run tests
run: |
. ./activate
LLVM_PROFILE_FILE="pytest.profraw" pytest clvm/tests
grcov . -s . --binary-path ./venv/lib/python3.9/site-packages/ -t lcov --branch --ignore-not-existing -o pytest.lcov.info --keep-only src
rm pytest.profraw

LLVM_PROFILE_FILE="unittest.profraw" RUSTFLAGS="-Zinstrument-coverage" cargo test --no-default-features
grcov . -s . --binary-path ./target/debug/build -t lcov --branch --ignore-not-existing -o unittest.lcov.info --keep-only src

# merge the lcov files
lcov unittest.lcov.info pytest.lcov.info -o lcov.info

- name: Coveralls
uses: coverallsapp/github-action@master
with:
path-to-lcov: ./lcov.info
github-token: ${{ secrets.GITHUB_TOKEN }}

6 changes: 0 additions & 6 deletions src/int_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ pub struct IntAllocator {
atom_vec: Vec<IntAtomBuf>,
}

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

impl IntAllocator {
pub fn new() -> Self {
let mut r = IntAllocator {
Expand Down
8 changes: 0 additions & 8 deletions src/number.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::allocator::Allocator;
use crate::node::Node;
use crate::reduction::EvalErr;

use num_bigint::BigInt;
Expand All @@ -22,13 +21,6 @@ pub fn ptr_from_number<T: Allocator>(
allocator.new_atom(&slice)
}

impl<T: Allocator> From<&Node<'_, T>> for Option<Number> {
fn from(item: &Node<T>) -> Self {
let v: &[u8] = &item.atom()?;
Some(number_from_u8(v))
}
}

pub fn number_from_u8(v: &[u8]) -> Number {
let len = v.len();
if len == 0 {
Expand Down