mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
Scripting tweaks (#138)
- No need to build with coverage by default on linux platforms - Will add coverage formally in CI later - Rename rust.yml to pr.yml Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
bb1b25ff2f
commit
5044d54d18
@@ -1,14 +0,0 @@
|
||||
[build]
|
||||
#target = "x86_64-unknown-linux-musl"
|
||||
|
||||
# Flags to enable code-coverage for all builds.
|
||||
# These can be removed later.
|
||||
#rustflags = ["-Cinstrument-coverage"]
|
||||
incremental = true
|
||||
|
||||
[env]
|
||||
# Name of coverage instrumentation log file.
|
||||
LLVM_PROFILE_FILE="target/cargo-test-%p-%m.profraw"
|
||||
|
||||
[target.x86_64-unknown-linux-gnu]
|
||||
rustflags = ["-Cinstrument-coverage"]
|
||||
@@ -1,71 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Copyright (c) Microsoft Corporation.
|
||||
# Licensed under the MIT License.
|
||||
|
||||
set -e
|
||||
|
||||
if ! command -v grcov > /dev/null; then
|
||||
cargo install grcov
|
||||
fi
|
||||
|
||||
if ! command -v llvm-profdata > /dev/null; then
|
||||
rustup component add llvm-tools-preview
|
||||
fi
|
||||
|
||||
#export LLVM_PROFILE_FILE='target/cargo-test-%p-%m.profraw'
|
||||
#export CARGO_INCREMENTAL=1
|
||||
#export RUSTFLAGS='-Cinstrument-coverage'
|
||||
|
||||
echo "Building with instrumentation"
|
||||
cargo build --all-targets
|
||||
|
||||
if [ "$1" == "--no-run" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Remove existing coverage information.
|
||||
rm -f target/*.profraw
|
||||
rm -rf target/coverage
|
||||
mkdir -p target/coverage
|
||||
|
||||
echo "Running tests"
|
||||
cargo test
|
||||
|
||||
# Generate html
|
||||
grcov target/ --binary-path ./target/debug/deps -s src/ -t html \
|
||||
--branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/coverage/html
|
||||
|
||||
if [ "$1" == "--show" ]; then
|
||||
echo "Opening report in browser"
|
||||
xdg-open target/coverage/html/index.html 2>/dev/null
|
||||
echo "Done"
|
||||
fi
|
||||
|
||||
# Generate markdown
|
||||
grcov target/ --binary-path ./target/debug/deps -s src/ -t markdown \
|
||||
--branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/coverage/markdown
|
||||
|
||||
cat target/coverage/markdown
|
||||
|
||||
# Print small-form table of files without 100% coverage.
|
||||
echo "Files without 100% coverage"
|
||||
while read p; do
|
||||
file=$(echo "$p" | cut -f 2 -d '|')
|
||||
percent=$(echo "$p" | cut -f 3 -d '|')
|
||||
missing=$(echo "$p" | cut -f 5 -d '|')
|
||||
|
||||
if [ -z "$file" ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
# Trim percentage using xargs.
|
||||
case $(echo "$percent" | xargs) in
|
||||
"100%"|"100.00%")
|
||||
continue
|
||||
esac
|
||||
|
||||
|
||||
echo "| $file | $percent |"
|
||||
done < target/coverage/markdown
|
||||
|
||||
#TODO: Maybe use coveralls format (json) and query data to lockdown code coverage.
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Copyright (c) Microsoft Corporation.
|
||||
# Licensed under the MIT License.
|
||||
|
||||
git stash
|
||||
cargo doc --no-deps
|
||||
git checkout docs
|
||||
rm -rf docs
|
||||
cp -r target/x86_64-unknown-linux-musl/doc ./docs
|
||||
echo "<meta http-equiv=\"refresh\" content=\"0; url=regorus/index.html\">" > docs/index.html
|
||||
git add docs
|
||||
git commit -s
|
||||
git push
|
||||
git checkout -
|
||||
git stash pop
|
||||
@@ -6,7 +6,7 @@ set -eo pipefail
|
||||
|
||||
if [ -f Cargo.toml ]; then
|
||||
# Ensure that all targets can be built.
|
||||
cargo build --all-targets
|
||||
cargo build -r --all-targets
|
||||
|
||||
#Ensure that code is correctly formatted.
|
||||
cargo fmt --check || (echo "Run cargo fmt to fix formatting" && exit 1)
|
||||
|
||||
@@ -10,10 +10,8 @@ if [ -f Cargo.toml ]; then
|
||||
"$dir/pre-commit"
|
||||
|
||||
# Ensure that all tests pass
|
||||
# Also generate coverage information.
|
||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
scripts/coverage
|
||||
fi
|
||||
cargo test -r
|
||||
cargo test -r --test aci
|
||||
|
||||
# Ensure that OPA conformance tests don't regress.
|
||||
cargo test -r --features opa-testutil --test opa -- $(tr '\n' ' ' < tests/opa.passing)
|
||||
|
||||
Reference in New Issue
Block a user