mirror of
https://github.com/Portabase/agent.git
synced 2026-09-10 10:08:01 +00:00
90 lines
2.7 KiB
YAML
90 lines
2.7 KiB
YAML
name: Codecov Rust
|
|
|
|
on:
|
|
push:
|
|
branches: ["main"]
|
|
pull_request:
|
|
branches: ["main"]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
CARGO_TARGET_DIR: /app/target
|
|
CARGO_INCREMENTAL: 0
|
|
RUSTFLAGS: "-C instrument-coverage -C link-dead-code"
|
|
LLVM_PROFILE_FILE: "/app/coverage/cargo-test-%p-%m.profraw"
|
|
|
|
jobs:
|
|
coverage:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Build test image
|
|
run: docker compose -f docker-compose.test.yml build agent-test
|
|
|
|
- name: Start agent-test container
|
|
run: docker compose -f docker-compose.test.yml up -d agent-test
|
|
|
|
- name: Run tests inside container
|
|
run: |
|
|
docker compose -f docker-compose.test.yml exec -T \
|
|
-e CARGO_TARGET_DIR \
|
|
-e CARGO_INCREMENTAL \
|
|
-e RUSTFLAGS \
|
|
-e LLVM_PROFILE_FILE \
|
|
agent-test bash -c "
|
|
mkdir -p /app/coverage &&
|
|
rm -rf /app/target/* /app/coverage/* &&
|
|
cargo test --verbose -- --test-threads=2 &&
|
|
sync
|
|
"
|
|
|
|
- name: Verify profraw files exist
|
|
run: |
|
|
docker compose -f docker-compose.test.yml exec -T \
|
|
agent-test bash -c '
|
|
count=$(find /app/coverage -type f -name "*.profraw" | wc -l)
|
|
echo "profraw files: $count"
|
|
test "$count" -gt 0
|
|
'
|
|
|
|
- name: Generate coverage report inside container
|
|
run: |
|
|
docker compose -f docker-compose.test.yml exec -T \
|
|
agent-test bash -c "
|
|
rustup component add llvm-tools-preview &&
|
|
grcov /app/coverage \
|
|
--binary-path /app/target/debug \
|
|
-s /app \
|
|
--llvm \
|
|
-t lcov \
|
|
--branch \
|
|
--ignore-not-existing \
|
|
--ignore '/app/target/*' \
|
|
-o /app/lcov.info
|
|
"
|
|
|
|
- name: Copy lcov.info from container to host
|
|
run: docker compose -f docker-compose.test.yml cp agent-test:/app/lcov.info ./lcov.info
|
|
|
|
- name: Show basic coverage report info
|
|
run: |
|
|
echo "lcov.info size:" $(wc -c ./lcov.info | awk '{print $1}')
|
|
head -n 30 ./lcov.info || true
|
|
test -s ./lcov.info
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
files: ./lcov.info
|
|
flags: unittests
|
|
name: rust-unit-coverage
|
|
verbose: true
|
|
fail_ci_if_error: true
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
use_pypi: true
|
|
|
|
- name: Stop and remove container
|
|
if: always()
|
|
run: docker compose -f docker-compose.test.yml down --volumes |