-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to mineunit/mineunit docker image (#15)
* Upgrade mineunit runner to use mineunit/mineunit docker image * Explicit error handling / fail fast where appropriate
- Loading branch information
Showing
6 changed files
with
97 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM mineunit/mineunit:latest | ||
|
||
USER root | ||
ENV USER=root | ||
|
||
RUN apk add --no-cache bash | ||
|
||
COPY scripts /scripts | ||
RUN chmod -R +x /scripts | ||
|
||
ENTRYPOINT ["/scripts/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
set -eo pipefail | ||
|
||
while read -r ENV; do export -- "$ENV"; done < <(env | grep -- '-[^=]*=' | sed -r ':ape s/^([^-=]*)-/\1_/;tape') | ||
|
||
cd "${INPUT_WORKING_DIRECTORY}" | ||
|
||
echo "Running tests in $(pwd)" | ||
/scripts/run-tests.sh | ||
ERR=$? | ||
|
||
if (($ERR != 0)); then | ||
exit $ERR | ||
fi | ||
|
||
echo "Generating report in $(pwd)" | ||
/scripts/run-report.sh | ||
ERR=$? | ||
|
||
exit $ERR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
set -eo pipefail | ||
|
||
# Generate luacov report and write it to output | ||
mineunit -r | ||
OUT="$(awk -v p=0 '/^----/{p++;next}p==2{exit}p' luacov.report.out | sort -hrk4)" | ||
printf 'mineunit-report<<END-OF-MINEUNIT-CONTENT\n%s\nEND-OF-MINEUNIT-CONTENT\n' "${OUT}" >> "${GITHUB_OUTPUT}" | ||
|
||
# Read and sort coverage information from luacov report | ||
COVERAGE_TOTAL="$(tail -n 2 luacov.report.out | grep ^Total | grep -o '[0-9.]\+%$')" | ||
echo "coverage-total=${COVERAGE_TOTAL}" >> "${GITHUB_OUTPUT}" | ||
awk -v p=0 '/^----/{p++;next}p==2{exit}p' luacov.report.out | sort -hrk4 > luacov.report.sum | ||
COVERAGE_FILES="$(grep -cv '\s0\.00%' luacov.report.sum)/$(wc -l<luacov.report.sum)" | ||
echo "coverage-files=${COVERAGE_FILES}" >> "${GITHUB_OUTPUT}" | ||
|
||
# badge-wrapper-actions-issue-1 | ||
echo "badge-name=${INPUT_BADGE_NAME}" >> "${GITHUB_OUTPUT}" | ||
echo "badge-label=${INPUT_BADGE_LABEL}" >> "${GITHUB_OUTPUT}" | ||
echo "badge-color=${INPUT_BADGE_COLOR}" >> "${GITHUB_OUTPUT}" | ||
echo "badge-status=${COVERAGE_TOTAL} in ${COVERAGE_FILES} files" >> "${GITHUB_OUTPUT}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
set +eo pipefail | ||
|
||
# Run tests, collect output and save return code | ||
exec 3>&1 | ||
OUT="$(mineunit -c ${INPUT_MINEUNIT_ARGS} | tee >(cat - >&3); exit ${PIPESTATUS[0]})" | ||
ERR=$? | ||
exec 3>&- | ||
|
||
# Check for some hard errors | ||
grep_eronly=(grep '0 successes / 0 failures / [1-9] error.\? / 0 pending') | ||
grep_nospec=(grep 'No test files found') | ||
("${grep_eronly[@]}"<<<"$OUT" && "${grep_nospec[@]}"<<<"$OUT")&>/dev/null && echo "mineunit-spec-missing=true" >> "${GITHUB_OUTPUT}" | ||
|
||
# Remove some shell stuff and write output | ||
OUT="$(sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g'<<<"$OUT")" | ||
printf 'mineunit-stdout<<END-OF-MINEUNIT-CONTENT\n%s\nEND-OF-MINEUNIT-CONTENT\n' "${OUT}" >> "${GITHUB_OUTPUT}" | ||
|
||
# Return original error code | ||
exit $ERR |