Skip to content

Commit

Permalink
feat: add test coverage in the deno CI (#1232)
Browse files Browse the repository at this point in the history
* feat: add test coverage in the deno CI

* fix: continue-on-error when artifacts is not present for download

* trigger CI for validation

* fix: coverage_percentage

* trigger CI for validation

* fix: download-artifact

* fix: calculate coverage drop against main branch

* fix: code style

* trigger CI for validation

* revert trigger CI for validation

* fix: use action instead of checkout and deno coverage --html

* fix: deno coverage --html instead of lcov

* fix: remove artifacts
  • Loading branch information
eugypalu authored Jun 25, 2024
1 parent 3963258 commit a451b94
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
44 changes: 43 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,49 @@ jobs:
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- run: KAKAROT_ADDRESS=0x1 deno test --allow-env
# Checkout target branch and run tests
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Run Tests with Coverage on target branch
run: KAKAROT_ADDRESS=0x1 deno test --allow-env --coverage=cov_profile
- name: Generate Coverage Report on target branch
run: deno coverage cov_profile --html
- name: Install bc
run: |
sudo apt-get update
sudo apt-get install -y bc
- name: Extract coverage percentage from HTML for the target branch
run: |
cat cov_profile/html/index.html
coverage_percentage=$(grep -A 3 "<div class='fl pad1y space-right2'>" cov_profile/html/index.html | grep "<span class='strong'>" | awk -F'[<>]' '{gsub("%","",$3); print $3}')
echo $coverage_percentage > curr_coverage_percentage.txt
# Checkout base branch and run tests
- uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
clean: false
- name: Run Tests with Coverage on base branch
run: KAKAROT_ADDRESS=0x1 deno test --allow-env --coverage=cov_profile_main
- name: Generate HTML report from for the base branch
run: deno coverage cov_profile_main --html
- name: Extract coverage percentage from HTML for the base branch
run: |
coverage_percentage_main=$(grep -A 3 "<div class='fl pad1y space-right2'>" cov_profile_main/html/index.html | grep "<span class='strong'>" | awk -F'[<>]' '{gsub("%","",$3); print $3}')
echo $coverage_percentage_main > coverage_percentage_main.txt
- name: Compare coverage percentage
run: |
previous_coverage=$(awk '{print $2}' coverage_percentage_main.txt)
echo "Previous coverage percentage was $previous_coverage%"
current_coverage=$(awk '{print $2}' curr_coverage_percentage.txt)
echo "Current coverage percentage is $current_coverage%"
change=$(echo "$previous_coverage - $current_coverage" | bc)
echo "Coverage change is $change%"
if (( $(echo "$change > 5.0" | bc -l) )); then
echo "Coverage dropped by more than 5%!"
exit 1
fi
test-rust:
runs-on: ubuntu-latest-16-cores
timeout-minutes: 30
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
vscode
broadcast
.idea
.DS_Store

# ignore genesis.json
.hive
Expand Down

0 comments on commit a451b94

Please sign in to comment.