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

Add code coverage via GitLab CI #567

Merged
merged 1 commit into from
Mar 31, 2019
Merged
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
11 changes: 11 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
image: "rust:latest"

run kcov:
stage: test
image: docker:latest
services:
- docker:dind
script:
- docker --version
- ./scripts/kcov.sh
- curl -v -s https://codecov.io/bash | bash
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> **S**pecs **P**arallel **ECS**

[![Build Status][bi]][bl] [![Crates.io][ci]][cl] [![Gitter][gi]][gl] ![MIT/Apache][li] [![Docs.rs][di]][dl] ![LoC][lo]
[![Build Status][bi]][bl] [![Crates.io][ci]][cl] [![Gitter][gi]][gl] ![MIT/Apache][li] [![Docs.rs][di]][dl] [![Code coverage][s7]][cov] ![LoC][lo]

[bi]: https://travis-ci.org/slide-rs/specs.svg?branch=master
[bl]: https://travis-ci.org/slide-rs/specs
Expand All @@ -18,6 +18,9 @@
[gi]: https://badges.gitter.im/slide-rs/specs.svg
[gl]: https://gitter.im/slide-rs/specs

[coi]: https://img.shields.io/codecov/c/gitlab/torkleyy/specs/master.svg
[cov]: https://codecov.io/gl/torkleyy/specs/branch/master

[lo]: https://tokei.rs/b1/github/slide-rs/specs?category=code

Specs is an Entity-Component System written in Rust.
Expand Down
26 changes: 26 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
codecov:
notify:
require_ci_to_pass: yes

coverage:
precision: 2
round: down
# range: "70...100"

status:
project: yes
patch: yes
changes: no

parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no

comment:
layout: "header, diff"
behavior: default
require_changes: no
24 changes: 24 additions & 0 deletions scripts/kcov.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

docker rm -f mykcov1

# Run image (non-blocking)
docker run -dt --security-opt seccomp=unconfined --name mykcov1 --entrypoint /bin/sh registry.gitlab.com/torkleyy/docker-cargo-kcov || exit 1

#docker cp Cargo.lock mykcov1:/volume
docker cp Cargo.toml mykcov1:/volume
docker cp src/ mykcov1:/volume
docker cp tests/ mykcov1:/volume
docker cp specs-derive/ mykcov1:/volume
docker cp examples/ mykcov1:/volume
docker cp benches/ mykcov1:/volume

docker exec -t mykcov1 /bin/sh -c "cargo check --all" || echo "Failed to generate rustc meta"
docker exec -t mykcov1 /bin/sh -c "cargo kcov --all" || echo "Failed generating report"

rm -R cov
mkdir -p cov
docker cp mykcov1:/volume/target/cov ./

# Force remove image
docker rm -f mykcov1