Add trunk to CI and fixes #2
Workflow file for this run
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
--- | ||
name: deno test | ||
on: | ||
workflow_call: | ||
jobs: | ||
formatting: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
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=0x11c5faab8a76b3caff6e243b8d13059a7fb723a0ca12bbaadde95fb9e501bda | ||
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=0x11c5faab8a76b3caff6e243b8d13059a7fb723a0ca12bbaadde95fb9e501bda | ||
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 |