Skip to content

Commit 41e9eca

Browse files
authored
Add coverage option (#18)
1 parent 8e46ac4 commit 41e9eca

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ jobs:
4141
Optional parameters for `mt-mods/mineunit-actions`:
4242

4343
* **`working-directory`** Working directory for unit tests, can be used when testing modpacks or multiple mods.
44+
* **`mineunit-args`** Mineunit extra arguments, for example to specify `--engine-version 5.7.0`.
45+
* **`coverage`** Luacov code coverage. Enabled by default.
4446
* **`badge-name`** Code coverage badge name.
4547
* **`badge-label`** Code coverage badge label.
4648
* **`badge-color`** Code coverage badge color.
47-
* **`mineunit-args`** Mineunit extra arguments, for example to specify `--engine-version 5.7.0`.
4849
* **`mineunit-version`** Mineunit version.
4950

5051
Outputs:

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ inputs:
1313
mineunit-args:
1414
description: "Additional arguments for mineunit"
1515
required: false
16+
coverage:
17+
description: "Enable code coverage"
18+
required: true
19+
default: true
1620
badge-name:
1721
description: "Code coverage badge name"
1822
required: true

scripts/entrypoint.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ ERR=$?
1111

1212
if (($ERR != 0)); then
1313
exit $ERR
14+
elif [[ "$INPUT_COVERAGE" != "true" ]]; then
15+
exit 0
1416
fi
1517

1618
echo "Generating report in $(pwd)"

scripts/run-tests.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
#!/bin/bash
22
set +eo pipefail
33

4+
# Configure (todo: kind of backwards currently)
5+
BUILTIN_ARGS=(-c)
6+
if [[ "$INPUT_COVERAGE" != "true" ]]; then
7+
BUILTIN_ARGS=()
8+
fi
9+
410
# Run tests, collect output and save return code
511
exec 3>&1
6-
OUT="$(mineunit -c ${INPUT_MINEUNIT_ARGS} | tee >(cat - >&3); exit ${PIPESTATUS[0]})"
12+
OUT="$(mineunit "${BUILTIN_ARGS[@]}" ${INPUT_MINEUNIT_ARGS} | tee >(cat - >&3); exit ${PIPESTATUS[0]})"
713
ERR=$?
814
exec 3>&-
915

0 commit comments

Comments
 (0)