Skip to content

Pre-commit lint staged only, add yarn test:coverage:file #1172

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"test:e2e": "scripts/e2e",
"test:gas": "RUN_EVM=true REPORT_GAS=true scripts/test",
"test:coverage": "scripts/coverage",
"test:coverage:file": "scripts/test-coverage-file",
"test:upgrade": "scripts/upgrade",
"lint": "yarn lint:ts && yarn lint:sol",
"lint:ts": "eslint '**/*.{js,ts}' --fix",
Expand All @@ -103,16 +104,17 @@
},
"lint-staged": {
"contracts/**/*.sol": [
"yarn lint:sol"
"prettier --write",
"solhint --fix --noPrompt --config node_modules/solhint-graph-config/index.js"
],
"**/*.ts": [
"yarn lint:ts"
"eslint --fix"
],
"**/*.js": [
"yarn lint:ts"
"eslint --fix"
],
"**/*.json": [
"yarn lint:ts"
"eslint --fix"
]
},
"repository": {
Expand Down
23 changes: 23 additions & 0 deletions packages/contracts/scripts/test-coverage-file
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -eo pipefail

# Check if a test file was provided
if [ $# -eq 0 ]; then
echo "Error: You must provide a test file path"
echo "Usage: ./scripts/test-coverage-file test/unit/rewards/rewards.test.ts"
exit 1
fi

# Build contracts first to ensure tests run against latest code
echo "Building contracts before running coverage..."
yarn build

echo "{}" > addresses-local.json
Copy link
Preview

Copilot AI May 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding cleanup of the 'addresses-local.json' file after test execution to avoid leaving residual files or accidental commits.

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tmigone I think leaving the file is a designed feature of how other scripts work, so I am not going to change this unless you suggest I should.


echo "Running coverage for test file: $1"
DISABLE_SECURE_ACCOUNTS=true \
L1_GRAPH_CONFIG=config/graph.hardhat.yml \
L2_GRAPH_CONFIG=config/graph.arbitrum-hardhat.yml \
ADDRESS_BOOK=addresses-local.json \
npx hardhat coverage --testfiles "$1"