Upload coverage to GitHub Pages instead of codecov

This commit is contained in:
Dominik Nakamura 2021-06-14 15:48:52 +09:00
parent b6e5835a64
commit 5d2ae149e9
No known key found for this signature in database
GPG Key ID: E4C6A749B2491910
3 changed files with 13 additions and 24 deletions

2
.gitignore vendored
View File

@ -4,5 +4,3 @@
*.profraw
.env
Cargo.lock
codecov
lcov.info

View File

@ -4,31 +4,22 @@ default:
# run integration tests with coverage
coverage:
cargo install grcov
cargo install grcov --git https://github.com/mozilla/grcov.git --rev c7a9b20d246a0cda812db509f206b38b3116cba4
rustup component add --toolchain nightly llvm-tools-preview
rm -rf *.profraw ./target/debug/coverage lcov.info
rm -rf *.profraw ./target/debug/coverage
RUSTFLAGS="-Zinstrument-coverage -Clink-dead-code" LLVM_PROFILE_FILE="coverage-%p-%m.profraw" cargo +nightly test --all-features
rustup run nightly grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage
rustup run nightly grcov . -s . --binary-path ./target/debug/ -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info
rm -f *.profraw
# upload coverage to https://codecov.io
upload-coverage: get-codecov
@# {{env_var("CODECOV_TOKEN")}}
just coverage
bash -c "export CODECOV_TOKEN=$CODECOV_TOKEN && ./codecov -f lcov.info"
get-codecov:
#!/usr/bin/env bash
set -euo pipefail
curl -s https://codecov.io/bash > codecov;
VERSION=$(grep -o 'VERSION=\"[0-9\.]*\"' codecov | cut -d'"' -f2);
for i in 1 256 512
do
shasum -a $i -c --ignore-missing <(curl -s "https://raw.githubusercontent.com/codecov/codecov-bash/${VERSION}/SHA${i}SUM") ||
shasum -a $i -c <(curl -s "https://raw.githubusercontent.com/codecov/codecov-bash/${VERSION}/SHA${i}SUM")
done
chmod +x codecov
# upload coverage to GitHub Pages
upload-coverage: coverage
git checkout gh-pages
rm -rf badges examples src tests coverage.json index.html
cp -R target/debug/coverage/ .
git add -A badges examples src tests coverage.json index.html
git commit -m "Coverage for $(git rev-parse --short main)"
# git push
git checkout main

View File

@ -11,8 +11,8 @@
[crates-url]: https://crates.io/crates/obws
[doc-img]: https://img.shields.io/badge/docs.rs-obws-4d76ae?style=for-the-badge
[doc-url]: https://docs.rs/obws
[cover-img]: https://img.shields.io/codecov/c/gh/dnaka91/obws?style=for-the-badge
[cover-url]: https://codecov.io/gh/dnaka91/obws
[cover-img]: https://img.shields.io/endpoint?url=https://dnaka91.github.io/obws/coverage.json&style=for-the-badge
[cover-url]: https://dnaka91.github.io/obws
Remote control OBS with the [obs-websocket] plugin from Rust 🦀.