-
Notifications
You must be signed in to change notification settings - Fork 103
60 lines (58 loc) · 2.65 KB
/
deno_test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
name: deno test
on:
workflow_call:
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
# Checkout target branch and run tests
- name: Run Tests with Coverage on target branch
run:
DEFAULT_BLOCK_GAS_LIMIT=7000000 STARKNET_NETWORK=http://0.0.0.0:1010
KAKAROT_ADDRESS=0x1d2e513630d8120666fc6e7d52ad0c01479fd99c183baac79fff9135f46e359
deno test --allow-env --allow-read --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:
DEFAULT_BLOCK_GAS_LIMIT=7000000 STARKNET_NETWORK=http://0.0.0.0:1010
KAKAROT_ADDRESS=0x1d2e513630d8120666fc6e7d52ad0c01479fd99c183baac79fff9135f46e359
deno test --allow-env --allow-read --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