Skip to content
This repository was archived by the owner on Feb 17, 2024. It is now read-only.

Commit 7b72ef2

Browse files
committed
Add output_type and output_path parameters
This allows us to use the action to create HTML reports, for instance.
1 parent 018607c commit 7b72ef2

File tree

3 files changed

+39
-10
lines changed

3 files changed

+39
-10
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ name: CI
2828
on: [ push, pull_request ]
2929
jobs:
3030
test-coverage:
31-
name: cargo test with coveralls
3231
runs-on: ubuntu-latest
3332
steps:
3433
- uses: actions/checkout@v2
@@ -43,6 +42,12 @@ jobs:
4342
### Inputs
4443
4544
- `dependencies_debian`: Debian packages to install before running the tests.
45+
- `output_type`: output type to pass to grcov.
46+
- `output_path`: output path to pass to grcov.
47+
48+
49+
If neither `output_type` and `output_path` are defined, the action by
50+
default creates an lcov.info file in the current directory.
4651

4752
## Alternatives
4853

action.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,17 @@ branding:
66
color: black
77
inputs:
88
dependencies_debian:
9-
description: 'Dependencies as Debian packages to install; used if defined'
9+
description: Dependencies as Debian packages to install; used if defined
1010
default: ''
11+
output_type:
12+
description: Output type to pass to grcov
13+
default: ''
14+
output_path:
15+
description: Output path to pass to grcov and set as report variable
16+
default: ''
17+
outputs:
18+
report:
19+
description: Name of report file, for compatibility with rust-grcov
1120
runs:
1221
using: 'docker'
1322
image: 'Dockerfile'

entrypoint

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,25 @@ else
1313
}
1414
fi
1515

16-
OUTPUT_PATH=lcov.info
16+
GRCOV=( grcov . \
17+
-s . \
18+
--binary-path ./target/debug/ \
19+
--ignore "/*" --ignore "../*" \
20+
--branch --ignore-not-existing \
21+
)
22+
23+
if [ -n "$INPUT_OUTPUT_TYPE" ]; then
24+
GRCOV+=( -t "$INPUT_OUTPUT_TYPE" )
25+
fi
26+
27+
if [ -n "$INPUT_OUTPUT_PATH" ]; then
28+
GRCOV+=( -o "$INPUT_OUTPUT_PATH" )
29+
OUTPUT_PATH="$INPUT_OUTPUT_PATH"
30+
elif [ -z "$INPUT_OUTPUT_TYPE" ]; then
31+
# Default if no output_type was specified either
32+
GRCOV+=( -o lcov.info )
33+
OUTPUT_PATH="lcov.info"
34+
fi
1735

1836
set -e -x
1937

@@ -27,11 +45,8 @@ export RUST_BACKTRACE=1
2745

2846
cargo test --all-features --no-fail-fast
2947

30-
grcov . \
31-
-s . \
32-
--binary-path ./target/debug/ \
33-
--ignore "/*" --ignore "../*" \
34-
--branch --ignore-not-existing \
35-
-o "$OUTPUT_PATH"
36-
echo "::set-output name=report::$OUTPUT_PATH"
48+
"${GRCOV[@]}"
49+
if [ -n "$OUTPUT_PATH" ]; then
50+
echo "::set-output name=report::$OUTPUT_PATH"
51+
fi
3752

0 commit comments

Comments
 (0)