Skip to content

fix: tests

fix: tests #46

Workflow file for this run

#name: Codecov Rust
#
#on:
# push:
# branches: ["main"]
# pull_request:
# branches: ["main"]
#
#env:
# CARGO_TERM_COLOR: always
#
#jobs:
# build:
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/checkout@v3
#
# - uses: actions-rs/toolchain@v1
# with:
# toolchain: stable
# override: true
# components: llvm-tools-preview
#
# - name: Install grcov
# run: cargo install grcov
#
# - name: Install test requirements
# run: bash scripts/tests/requirements.sh
#
# - name: Build
# run: cargo build --verbose
#
# - name: Run tests
# env:
# CARGO_INCREMENTAL: 0
# RUSTFLAGS: "-C instrument-coverage"
# LLVM_PROFILE_FILE: "cargo-test-%p-%m.profraw"
# run: cargo test --verbose
#
# - name: Generate coverage
# run: |
# grcov . \
# --binary-path ./target/debug/ \
# -s . \
# -t lcov \
# --branch \
# --ignore-not-existing \
# -o lcov.info
#
# - name: Upload to Codecov
# uses: codecov/codecov-action@v5
# with:
# files: lcov.info
# verbose: true
# fail_ci_if_error: true
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
name: Codecov Rust
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
env:
CARGO_TERM_COLOR: always
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Install grcov
run: cargo install grcov
- name: Prepare coverage directory
run: mkdir -p coverage
- name: Build test image
run: docker compose -f docker-compose.test.yml build agent-test
- name: Run tests in container
env:
CARGO_TARGET_DIR: /app/target
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C instrument-coverage"
LLVM_PROFILE_FILE: "/app/coverage/cargo-test-%p-%m.profraw"
run: |
docker compose -f docker-compose.test.yml run --rm \
-e CARGO_TARGET_DIR \
-e CARGO_INCREMENTAL \
-e RUSTFLAGS \
-e LLVM_PROFILE_FILE \
agent-test bash -c "cargo test --verbose && sync"
- name: Verify profraw files
run: |
echo "==== PROFRAW FILES ===="
find coverage -type f || true
- name: Generate coverage
run: |
grcov ./coverage \
--binary-path ./target/debug/ \
-s /app \
--prefix-dir /app \
-t lcov \
--branch \
--ignore-not-existing \
--ignore "/*" \
--ignore "../*" \
-o lcov.info
- name: Check lcov content
run: |
echo "==== LCOV SIZE ===="
wc -l lcov.info || true
echo "==== LCOV HEAD ===="
head -20 lcov.info || true
- name: Upload to Codecov
uses: codecov/codecov-action@v5
with:
files: lcov.info
flags: unittests
name: rust-docker-coverage
verbose: true
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}