-
Notifications
You must be signed in to change notification settings - Fork 0
Update Deterministic hardhat via viatrix PR #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
fa80c06
2614b4b
a99aa0b
229201e
34e9877
688b200
ca22cbd
e7ffbd8
110547b
52dbfc2
36824b8
bdff146
4379e3f
895684d
4e45989
b8e4e88
7ad3687
81912c2
c4aa6c0
c0dc1c8
9ba1f4a
b7cf55d
bf20db6
e739570
3dc28d3
2574d78
66b36aa
e8e846c
1fd7472
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ on: | |
|
|
||
| jobs: | ||
| coverage: | ||
| runs-on: ubuntu-latest | ||
| runs-on: ubuntu-22.04 | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
|
|
@@ -21,124 +21,70 @@ jobs: | |
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Print environment versions | ||
| run: | | ||
| echo "Node.js: $(node -v)" | ||
| echo "NPM: $(npm -v)" | ||
| npx hardhat --version | ||
| npx solcjs --version 2>/dev/null || echo "(will be downloaded by Hardhat if needed)" | ||
|
|
||
| - name: Setup environment variables | ||
| run: cp .env.example .env | ||
| run: | | ||
| cp .env.example .env | ||
| echo "✅ Environment configured" | ||
|
|
||
| - name: Get baseline from main branch | ||
| - name: Fetch main branch baseline | ||
| run: | | ||
| # Fetch main branch | ||
| echo "📥 Fetching coverage baseline from main branch..." | ||
| git fetch origin main | ||
| # Get baseline from main (for comparison - must not decrease) | ||
| git show origin/main:coverage-baseline.json > baseline-from-main.json 2>/dev/null || echo '{"lines":"0","functions":"0","branches":"0","statements":"0"}' > baseline-from-main.json | ||
| echo "📊 Baseline from main branch:" | ||
| cat baseline-from-main.json | ||
|
|
||
| - name: Get baseline from PR | ||
| run: | | ||
| # Get baseline from current PR branch (what developer committed) | ||
| if [ -f coverage-baseline.json ]; then | ||
| # Validate JSON format | ||
| if jq empty coverage-baseline.json 2>/dev/null; then | ||
| cp coverage-baseline.json baseline-from-pr.json | ||
| echo "📊 Baseline from PR (committed by developer):" | ||
| cat baseline-from-pr.json | ||
| else | ||
| echo "❌ ERROR: coverage-baseline.json is not valid JSON!" | ||
| echo "Please run: npm run coverage:update-baseline" | ||
| exit 1 | ||
| fi | ||
| else | ||
| echo "❌ ERROR: No coverage-baseline.json found in PR!" | ||
| echo "" | ||
| echo "You must run coverage locally and commit the baseline file." | ||
| echo "" | ||
| echo "📝 To fix: Run these commands locally and commit the result:" | ||
| echo " npm run coverage" | ||
| echo " npm run coverage:update-baseline" | ||
| echo " git add coverage-baseline.json" | ||
| echo " git commit -m 'chore: update coverage baseline'" | ||
| echo "" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Run coverage | ||
| id: run_coverage | ||
| timeout-minutes: 15 | ||
| run: | | ||
| set -e # Exit immediately if coverage fails | ||
| set -e | ||
| echo "" | ||
| echo "📊 Running test coverage analysis in CI..." | ||
| echo "This generates fresh coverage from your PR code" | ||
| npm run coverage | ||
| echo "✅ Coverage completed successfully" | ||
|
|
||
| - name: Validate coverage | ||
| - name: Display coverage comparison | ||
| run: | | ||
| set -e | ||
| echo "" | ||
| echo "==================================================" | ||
| echo "🔍 COVERAGE VALIDATION" | ||
| echo " COVERAGE VALIDATION" | ||
| echo "==================================================" | ||
|
|
||
| # Parse CI-generated coverage using dedicated script | ||
| CI_LINES=$(npx ts-node --files scripts/get-coverage-percentage.ts) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the get-coverage-percentage script not used anymore, and instead inline nodejs code is used? |
||
|
|
||
| # Get baselines | ||
| PR_LINES=$(jq -r .lines baseline-from-pr.json) | ||
| MAIN_LINES=$(jq -r .lines baseline-from-main.json) | ||
|
Comment on lines
-82
to
-83
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why abandoning this part if it was perfectly alright? |
||
|
|
||
| echo "" | ||
| echo "📊 Coverage Results:" | ||
| echo " CI (actual): $CI_LINES%" | ||
| echo " PR baseline: $PR_LINES%" | ||
| echo " Main baseline: $MAIN_LINES%" | ||
| echo "" | ||
|
|
||
| # Check 1: CI must match PR baseline (developer ran coverage correctly) | ||
| echo "Check 1: Did developer run coverage locally?" | ||
| if [ "$CI_LINES" = "$PR_LINES" ]; then | ||
| echo " ✅ PASS - CI coverage matches PR baseline ($CI_LINES% == $PR_LINES%)" | ||
| else | ||
| echo " ❌ FAIL - CI coverage doesn't match PR baseline!" | ||
| echo "" | ||
| echo " Expected: $PR_LINES% (from your committed coverage-baseline.json)" | ||
| echo " Actual: $CI_LINES% (from fresh CI coverage run)" | ||
| echo "" | ||
| echo "💡 This means either:" | ||
| echo " 1. You forgot to run 'npm run coverage:update-baseline' locally" | ||
| echo " 2. You modified coverage-baseline.json manually (cheating)" | ||
| echo " 3. Your local coverage differs from CI (check .env setup)" | ||
| echo "" | ||
| echo "📝 To fix: Run these commands locally and commit the result:" | ||
| echo " npm run coverage" | ||
| echo " npm run coverage:update-baseline" | ||
| echo " git add coverage-baseline.json" | ||
| echo " git commit -m 'chore: update coverage baseline'" | ||
| echo "" | ||
| exit 1 | ||
| fi | ||
| # Extract coverage from CI run (actual) | ||
| CI_COV=$(npx ts-node --files scripts/get-coverage-percentage.ts) | ||
|
|
||
| echo "" | ||
| # Extract PR baseline (what developer committed) | ||
| PR_BASELINE=$(jq -r '.lines // "0"' coverage-baseline.json) | ||
|
|
||
| # Check 2: CI must be >= main baseline (coverage didn't decrease) | ||
| echo "Check 2: Did coverage decrease?" | ||
| if awk "BEGIN {exit !($CI_LINES >= $MAIN_LINES)}"; then | ||
| if awk "BEGIN {exit !($CI_LINES > $MAIN_LINES)}"; then | ||
| echo " ✅ PASS - Coverage improved! ($MAIN_LINES% → $CI_LINES%)" | ||
| else | ||
| echo " ✅ PASS - Coverage maintained ($CI_LINES%)" | ||
| fi | ||
| else | ||
| echo " ❌ FAIL - Coverage decreased!" | ||
| echo "" | ||
| echo " Main baseline: $MAIN_LINES%" | ||
| echo " Your PR: $CI_LINES%" | ||
| echo " Decrease: $(awk "BEGIN {print $MAIN_LINES - $CI_LINES}")%" | ||
| echo "" | ||
| echo "💡 Please add tests to maintain or improve coverage." | ||
| echo "" | ||
| exit 1 | ||
| fi | ||
| # Extract main baseline (production baseline) | ||
| MAIN_BASELINE=$(jq -r '.lines // "0"' baseline-from-main.json) | ||
|
|
||
| echo "📊 Coverage Results (Lines):" | ||
| echo " CI (actual): ${CI_COV}% ← Fresh coverage from this PR" | ||
| echo " PR baseline: ${PR_BASELINE}% ← Baseline you committed" | ||
| echo " Main baseline: ${MAIN_BASELINE}% ← Baseline from main branch" | ||
| echo "" | ||
| echo "✓ Check 1: CI coverage should match PR baseline" | ||
| echo " (proves you ran coverage locally)" | ||
| echo "✓ Check 2: CI coverage should be >= Main baseline - 0.2%" | ||
| echo " (proves coverage didn't decrease beyond tolerance)" | ||
| echo "" | ||
| echo "💡 Allowed tolerance: ±0.2%" | ||
| echo "" | ||
| echo "==================================================" | ||
| echo "✅ ALL CHECKS PASSED" | ||
| echo "==================================================" | ||
| echo "" | ||
|
|
||
| - name: Verify coverage | ||
| run: | | ||
| set -e | ||
| echo "🔍 Running coverage validation..." | ||
| npx ts-node --files scripts/check-coverage.ts --main-baseline=baseline-from-main.json | ||
|
|
||
| - name: Upload coverage report (optional) | ||
| if: always() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| pragma solidity 0.8.28; | ||
|
|
||
| /** | ||
| * @title Interface for Arbitrum Gateway Router | ||
| */ | ||
| interface IArbitrumGatewayRouter { | ||
|
|
||
| event TransferRouted( | ||
| address indexed token, | ||
| address indexed _userFrom, | ||
| address indexed _userTo, | ||
| address gateway | ||
| ); | ||
|
|
||
| /** | ||
| * @notice For new versions of gateways it's recommended to use outboundTransferCustomRefund() method. | ||
| * @notice Some legacy gateways (for example, DAI) don't have the outboundTransferCustomRefund method | ||
| * @notice so using outboundTransfer() method is a universal solution | ||
| */ | ||
| function outboundTransfer( | ||
| address _token, | ||
| address _to, | ||
| uint256 _amount, | ||
| uint256 _maxGas, | ||
| uint256 _gasPriceBid, | ||
| bytes calldata _data | ||
| ) external payable returns (bytes memory); | ||
|
|
||
| /** | ||
| * @notice Calculate the address used when bridging an ERC20 token | ||
| * @dev the L1 and L2 address oracles may not always be in sync. | ||
| * For example, a custom token may have been registered but not deploy or the contract self destructed. | ||
| * @param l1ERC20 address of L1 token | ||
| * @return L2 address of a bridged ERC20 token | ||
| */ | ||
| function calculateL2TokenAddress(address l1ERC20) external view returns (address); | ||
|
|
||
| function getGateway(address _token) external view returns (address gateway); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this code was abandoned?