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

Automatic code coverage reports #4188

Merged
merged 1 commit into from
Jan 3, 2023
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
74 changes: 74 additions & 0 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Code coverage

on:
workflow_dispatch:
schedule:
# Run it every 3 days.
- cron: "0 3 * * *"

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
THEGRAPH_STORE_POSTGRES_DIESEL_URL: "postgresql://postgres:postgres@localhost:5432/graph_node_test"
RUSTFLAGS: "-C link-arg=-fuse-ld=lld -D warnings"
N_CONCURRENT_TESTS: "4"
TESTS_GANACHE_HARD_WAIT_SECONDS: "30"

jobs:
# Heavily inspired from <https://github.com/taiki-e/cargo-llvm-cov#continuous-integration>.
coverage:
name: Code coverage of integration tests
runs-on: ubuntu-latest
timeout-minutes: 60
services:
ipfs:
image: ipfs/go-ipfs:v0.10.0
ports:
- 5001:5001
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: graph_node_test
POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C"
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: Install Node 14
uses: actions/setup-node@v3
with:
node-version: "14"
cache: yarn
cache-dependency-path: "tests/integration-tests/yarn.lock"
- name: Install lld
run: sudo apt-get install -y lld jq
- uses: actions-rs/cargo@v1
with:
command: install
args: cargo-llvm-cov

- name: Build graph-node
uses: actions-rs/cargo@v1
with:
command: build
args: --bin graph-node

- name: Generate code coverage
run: cargo llvm-cov --package graph-tests --lcov --output-path lcov.info -- --nocapture
- uses: actions/upload-artifact@v3
with:
name: code-coverage-info
path: lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
# No token needed, because the repo is public.
files: lcov.info
fail_ci_if_error: true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Code coverage stuff
*.profraw
lcov.info

# Generated by Cargo
# will have compiled files and executables
/target/
Expand Down