-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 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,54 @@ | ||
name: Run Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- actions | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.11 | ||
|
||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install --extra-index-url https://pypi.chia.net/simple/ chia-dev-tools==1.2.5 | ||
pip install -r requirements.txt | ||
- name: Run pytest | ||
run: | | ||
python -m pytest | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Install npm dependencies | ||
run: npm install | ||
|
||
- name: Run Hardhat tests | ||
run: | | ||
npx hardhat test | ||
- name: Check test coverage for Solidity contracts | ||
run: | | ||
COVERAGE=$(npx hardhat coverage) | ||
SECOND_PART=$(echo "$COVERAGE" | awk -F 'contracts/ |' '{print $2}') | ||
PARTS=$(echo "$SECOND_PART" | cut -d '|' -f 2-5) | ||
if [ "$(echo "$PARTS" | tr -d '[:space:]')" = "100|100|100|100" ]; then | ||
echo "Test coverage is 100% for the contracts/*.sol" | ||
else | ||
echo "Test coverage is less than 100% for contracts/*.sol" | ||
exit 1 | ||
fi |