|
| 1 | +name: Tron Smart Contracts Tests |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + paths: |
| 8 | + - 'packages/smart-contracts/tron/**' |
| 9 | + - 'packages/smart-contracts/tronbox-config.js' |
| 10 | + - '.github/workflows/tron-smart-contracts.yml' |
| 11 | + push: |
| 12 | + branches: |
| 13 | + - master |
| 14 | + paths: |
| 15 | + - 'packages/smart-contracts/tron/**' |
| 16 | + - 'packages/smart-contracts/tronbox-config.js' |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +jobs: |
| 20 | + tron-compile-check: |
| 21 | + name: Tron Contract Compilation Check |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout repository |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Setup Node.js |
| 29 | + uses: actions/setup-node@v4 |
| 30 | + with: |
| 31 | + node-version: '22' |
| 32 | + cache: 'yarn' |
| 33 | + |
| 34 | + - name: Install TronBox globally |
| 35 | + run: npm install -g tronbox |
| 36 | + |
| 37 | + - name: Install dependencies |
| 38 | + run: yarn install --frozen-lockfile |
| 39 | + |
| 40 | + - name: Compile Tron contracts |
| 41 | + working-directory: packages/smart-contracts |
| 42 | + run: yarn tron:compile |
| 43 | + |
| 44 | + - name: Verify build artifacts exist |
| 45 | + working-directory: packages/smart-contracts |
| 46 | + run: | |
| 47 | + echo "Checking build artifacts..." |
| 48 | + ls -la tron-build/ |
| 49 | +
|
| 50 | + # Verify key contracts were compiled |
| 51 | + if [ ! -f "tron-build/ERC20FeeProxy.json" ]; then |
| 52 | + echo "ERROR: ERC20FeeProxy.json not found!" |
| 53 | + exit 1 |
| 54 | + fi |
| 55 | +
|
| 56 | + if [ ! -f "tron-build/TestTRC20.json" ]; then |
| 57 | + echo "ERROR: TestTRC20.json not found!" |
| 58 | + exit 1 |
| 59 | + fi |
| 60 | +
|
| 61 | + echo "✅ All required artifacts present" |
| 62 | +
|
| 63 | + tron-tests: |
| 64 | + name: Tron Contract Tests |
| 65 | + runs-on: ubuntu-latest |
| 66 | + needs: tron-compile-check |
| 67 | + |
| 68 | + steps: |
| 69 | + - name: Checkout repository |
| 70 | + uses: actions/checkout@v4 |
| 71 | + |
| 72 | + - name: Set up QEMU for ARM64 emulation |
| 73 | + uses: docker/setup-qemu-action@v3 |
| 74 | + with: |
| 75 | + platforms: arm64 |
| 76 | + |
| 77 | + - name: Setup Node.js |
| 78 | + uses: actions/setup-node@v4 |
| 79 | + with: |
| 80 | + node-version: '22' |
| 81 | + cache: 'yarn' |
| 82 | + |
| 83 | + - name: Install TronBox globally |
| 84 | + run: npm install -g tronbox |
| 85 | + |
| 86 | + - name: Install dependencies |
| 87 | + run: yarn install --frozen-lockfile |
| 88 | + |
| 89 | + - name: Start Tron Runtime Environment (ARM64 via QEMU) |
| 90 | + run: | |
| 91 | + docker run -d --name tron-tre \ |
| 92 | + --platform linux/arm64 \ |
| 93 | + -p 9090:9090 \ |
| 94 | + tronbox/tre |
| 95 | +
|
| 96 | + echo "Waiting for Tron node to start (ARM64 emulation may be slow)..." |
| 97 | + sleep 30 |
| 98 | +
|
| 99 | + - name: Wait for Tron node to be ready |
| 100 | + run: | |
| 101 | + echo "Waiting for Tron node..." |
| 102 | + for i in {1..90}; do |
| 103 | + if curl -s http://localhost:9090/wallet/getnowblock > /dev/null 2>&1; then |
| 104 | + echo "Tron node is ready!" |
| 105 | + exit 0 |
| 106 | + fi |
| 107 | + echo "Attempt $i/90 - Tron node not ready yet..." |
| 108 | + sleep 5 |
| 109 | + done |
| 110 | + echo "Tron node failed to start" |
| 111 | + docker logs tron-tre |
| 112 | + exit 1 |
| 113 | +
|
| 114 | + - name: Compile Tron contracts |
| 115 | + working-directory: packages/smart-contracts |
| 116 | + run: yarn tron:compile |
| 117 | + |
| 118 | + - name: Wait for blockchain to stabilize |
| 119 | + run: | |
| 120 | + echo "Waiting for blockchain to produce more blocks..." |
| 121 | + sleep 30 |
| 122 | +
|
| 123 | + - name: Run Tron tests |
| 124 | + working-directory: packages/smart-contracts |
| 125 | + run: yarn tron:test |
| 126 | + env: |
| 127 | + CI: true |
| 128 | + |
| 129 | + - name: Stop Tron container |
| 130 | + if: always() |
| 131 | + run: docker stop tron-tre || true |
| 132 | + |
| 133 | + - name: Upload test artifacts |
| 134 | + if: failure() |
| 135 | + uses: actions/upload-artifact@v4 |
| 136 | + with: |
| 137 | + name: tron-test-logs |
| 138 | + path: | |
| 139 | + packages/smart-contracts/tron-build/ |
| 140 | + retention-days: 7 |
0 commit comments