chore: Migrate project from pnpm to bun for dependency management and… #40
This file contains hidden or 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: Smart Contract Tests | |
| on: | |
| push: | |
| paths: | |
| - 'contracts/**' | |
| - 'lib/**' | |
| - '.github/workflows/contract-tests.yml' | |
| pull_request: | |
| paths: | |
| - 'contracts/**' | |
| - 'lib/**' | |
| - '.github/workflows/contract-tests.yml' | |
| workflow_dispatch: | |
| jobs: | |
| contract-tests: | |
| name: Foundry Tests & Analysis | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install Foundry | |
| uses: foundry-rs/foundry-toolchain@v1 | |
| with: | |
| version: nightly | |
| # Skip all bun/Node.js dependencies - contracts tests don't need them | |
| - name: Build contracts | |
| run: | | |
| echo "🔧 Building contracts..." | |
| cd contracts | |
| # Build contracts with size reporting | |
| forge build --sizes | |
| if [ $? -ne 0 ]; then | |
| echo "❌ Contract compilation failed" | |
| exit 1 | |
| fi | |
| echo "✅ Contracts compiled successfully" | |
| echo "" | |
| echo "📊 Contract sizes:" | |
| forge build --sizes | tail -20 # Show size information | |
| - name: Run contract tests | |
| run: | | |
| echo "🧪 Running Foundry test suite..." | |
| cd contracts | |
| # Run tests with detailed output and gas reporting | |
| forge test -vvv --gas-report | |
| if [ $? -eq 0 ]; then | |
| echo "" | |
| echo "✅ All contract tests passed!" | |
| else | |
| echo "" | |
| echo "❌ Some contract tests failed" | |
| echo "💡 Check test output above for details" | |
| exit 1 | |
| fi | |
| - name: Generate and upload coverage report | |
| run: | | |
| echo "📊 Generating coverage report..." | |
| cd contracts | |
| # Generate coverage in lcov format for better tooling support | |
| forge coverage --report lcov | |
| if [ -f lcov.info ]; then | |
| echo "✅ Coverage report generated" | |
| echo "" | |
| echo "📈 Coverage summary:" | |
| # Show basic coverage info if lcov tools are available | |
| if command -v lcov &> /dev/null; then | |
| lcov --summary lcov.info | |
| else | |
| echo "📄 Coverage data saved to lcov.info" | |
| fi | |
| else | |
| echo "⚠️ Coverage report not generated" | |
| fi | |
| continue-on-error: true # Don't fail build if coverage fails | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| if: always() | |
| with: | |
| files: ./contracts/lcov.info | |
| flags: contract-tests | |
| name: contract-coverage | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| fail_ci_if_error: false | |
| - name: Contract security analysis | |
| run: | | |
| echo "🔍 Running basic security analysis..." | |
| cd contracts | |
| echo "📋 Checking compilation warnings:" | |
| forge build 2>&1 | tee build-warnings.log | |
| if grep -E "(Warning|Error):" build-warnings.log; then | |
| echo "⚠️ Found compilation warnings/errors" | |
| else | |
| echo "✅ No compilation warnings found" | |
| fi | |
| echo "" | |
| echo "📋 Contract complexity analysis:" | |
| find src -name "*.sol" -exec wc -l {} + | sort -n | tail -10 | |
| echo "" | |
| echo "💡 For comprehensive security analysis, consider:" | |
| echo " • Slither static analysis" | |
| echo " • Mythril symbolic execution" | |
| echo " • Manual audit for mainnet deployment" | |
| continue-on-error: true | |
| - name: Archive test artifacts | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: contract-test-artifacts | |
| path: | | |
| contracts/out/ | |
| contracts/lcov.info | |
| contracts/cache/ | |
| contracts/build-warnings.log | |
| retention-days: 7 | |
| - name: Test Summary | |
| if: always() | |
| run: | | |
| echo "" | |
| echo "🏗️ CONTRACT TESTS COMPLETED" | |
| echo "===========================" | |
| if [ "${{ job.status }}" = "success" ]; then | |
| echo "✅ All contract tests passed!" | |
| echo "📊 Coverage reports generated" | |
| echo "🔧 Contracts compiled successfully" | |
| echo "🎉 Smart contracts are ready for deployment" | |
| else | |
| echo "❌ Contract tests failed" | |
| echo "💡 Check output above for details" | |
| echo "🔧 Fix issues before deployment" | |
| fi |