Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: fail actions on build/test failure
Browse files Browse the repository at this point in the history
milapsheth committed Jun 3, 2024
1 parent 405ff8c commit 470bb7e
Showing 3 changed files with 33 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@
},
"main": "index.js",
"scripts": {
"build": "for d in ./move/*/; do cd $d; sui move build --lint --warnings-are-errors & cd ../../; done; wait",
"test": "for d in ./move/*/; do sui move test --path $d ; done",
"build": "./scripts/run.sh build",
"test": "./scripts/run.sh test",
"coverage": "./scripts/coverage.sh",
"lint": "eslint --fix './scripts/*.js'",
"prettier": "prettier --write './scripts/*.js'"
22 changes: 11 additions & 11 deletions scripts/coverage.sh
Original file line number Diff line number Diff line change
@@ -19,30 +19,30 @@ if ! which "$SUI" >/dev/null 2>&1; then
fi
fi

for d in ./move/*/; do
"$SUI" move test --path "$d" --coverage &
for module in ./move/*/; do
"$SUI" move test --path "$module" --coverage &
done

wait

found=0

for d in ./move/*/; do
echo "Generating coverage info for package $d"
for module in ./move/*/; do
echo "Generating coverage info for package ${module}"

if [ ! -f "$d/.coverage_map.mvcov" ]; then
echo "\n NO tests found for module $d. Skipped.\n" >> .coverage.info
echo "\n NO tests found for module $d. Skipped.\n" >> .coverage.extended.info
if [ ! -f "${module}/.coverage_map.mvcov" ]; then
echo "\n NO tests found for module ${module}. Skipped.\n" >> .coverage.info
echo "\n NO tests found for module ${module}. Skipped.\n" >> .coverage.extended.info
continue
fi

found=1

echo "Coverage report for module $d\n" >> .coverage.info
echo "Coverage report for module $d\n" >> .coverage.extended.info
echo "Coverage report for module ${module}\n" >> .coverage.info
echo "Coverage report for module ${module}\n" >> .coverage.extended.info

"$SUI" move coverage summary --path "$d" >> .coverage.info
"$SUI" move coverage summary --summarize-functions --path "$d" >> .coverage.extended.info
"$SUI" move coverage summary --path "${module}" >> .coverage.info
"$SUI" move coverage summary --summarize-functions --path "${module}" >> .coverage.extended.info

echo "" >> .coverage.info
echo "" >> .coverage.extended.info
20 changes: 20 additions & 0 deletions scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

if [[ ${#} -ne 1 || ( "$1" != "build" && "$1" != "test" ) ]]; then
echo "Usage: $0 [build|test]"
exit 1
fi

exit_code=0

for module in ./move/*/; do
if ! sui move build --lint --warnings-are-errors --path "$module"; then
exit_code=1
fi
done

if [ $exit_code -ne 0 ]; then
echo ""
echo -e "\033[0;31mBuild failed\033[0m"
exit 1
fi

0 comments on commit 470bb7e

Please sign in to comment.