-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ops): add move-tests github action and improve test coverage (#310)
- new github action: downloads the sui binary, runs the tests and also checks if there is enough test coverage. - new tests in the contract: increases test coverage in order to reach at least 80%.
- Loading branch information
Showing
2 changed files
with
148 additions
and
1 deletion.
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,45 @@ | ||
name: Run Move tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- move/** | ||
pull_request: | ||
paths: | ||
- move/** | ||
|
||
jobs: | ||
run-tests: | ||
name: Run Tests | ||
runs-on: ubuntu-latest | ||
|
||
defaults: | ||
run: | ||
working-directory: move/walrus_site | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download Sui | ||
run: | | ||
VERSION=$(curl -s https://api.github.com/repos/MystenLabs/sui/releases/latest | jq -r '.tag_name') | ||
curl -L "https://github.com/MystenLabs/sui/releases/download/$VERSION/sui-$VERSION-ubuntu-x86_64.tgz" -o sui.tgz | ||
sudo tar -xvzf sui.tgz -C /usr/local/bin | ||
# Run Tests with Coverage | ||
- name: Run tests | ||
run: sui-debug move test --coverage | ||
|
||
- name: Check Move Coverage | ||
run: | | ||
COVERAGE_OUTPUT=$(sui-debug move coverage summary) | ||
echo "$COVERAGE_OUTPUT" | ||
COVERAGE_PERCENT=$(echo "$COVERAGE_OUTPUT" | grep "% Move Coverage:" | sed -E 's/.*: ([0-9]+(\.[0-9]+)?).*/\1/') | ||
if (( $(echo "$COVERAGE_PERCENT < 80" | bc -l) )); then | ||
echo "Coverage is below 80%. Build failed." | ||
exit 1 | ||
fi | ||
echo "Coverage is $COVERAGE_PERCENT%. Build passed." |
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