name: Contract Performance Benchmarks on: push: branches: [main, develop] paths: - 'contracts/**' - 'scripts/benchmarking/**' - '.gitea/workflows/contract-benchmarks.yml' pull_request: branches: [main, develop] workflow_dispatch: inputs: benchmark_type: description: 'Type of benchmark to run' required: false default: 'all' type: choice options: - all - gas-usage - execution-time - throughput concurrency: group: contract-benchmarks-${{ github.ref }} cancel-in-progress: true jobs: benchmark-gas-usage: runs-on: debian timeout-minutes: 30 env: WORKSPACE: /var/lib/aitbc-workspaces/gas-benchmarks steps: - name: Clone repository run: | rm -rf "${{ env.WORKSPACE }}" mkdir -p "${{ env.WORKSPACE }}" cd "${{ env.WORKSPACE }}" git clone --depth 1 http://gitea.bubuit.net:3000/oib/aitbc.git repo - name: Initialize job logging run: | cd "${{ env.WORKSPACE }}/repo" bash scripts/ci/setup-job-logging.sh - name: Setup Node.js environment run: | cd "${{ env.WORKSPACE }}/repo/contracts" # Install pnpm if not available if ! command -v pnpm &> /dev/null; then npm install -g pnpm fi pnpm install echo "โœ… Node.js environment ready" - name: Run gas usage benchmarks run: | cd "${{ env.WORKSPACE }}/repo/contracts" echo "๐Ÿงช Running gas usage benchmarks" # Run benchmarks (gas reporting will be added when tests are implemented) pnpm hardhat test test/benchmarks/gas-usage.test.js echo "โœ… Gas usage benchmarks completed" - name: Upload gas report run: | cd "${{ env.WORKSPACE }}/repo" echo "๐Ÿ“Š Gas report upload skipped (reports will be added when tests are implemented)" # Save report to artifacts directory (placeholder) mkdir -p /var/lib/aitbc/benchmarks echo "Gas report placeholder - $(date)" > /var/lib/aitbc/benchmarks/gas-report-placeholder-$(date +%Y%m%d-%H%M%S).txt echo "โœ… Gas report placeholder uploaded" - name: Cleanup if: always() run: rm -rf "${{ env.WORKSPACE }}" benchmark-execution-time: runs-on: debian timeout-minutes: 30 env: WORKSPACE: /var/lib/aitbc-workspaces/execution-benchmarks steps: - name: Clone repository run: | rm -rf "${{ env.WORKSPACE }}" mkdir -p "${{ env.WORKSPACE }}" cd "${{ env.WORKSPACE }}" git clone --depth 1 http://gitea.bubuit.net:3000/oib/aitbc.git repo - name: Initialize job logging run: | cd "${{ env.WORKSPACE }}/repo" bash scripts/ci/setup-job-logging.sh - name: Setup Node.js environment run: | cd "${{ env.WORKSPACE }}/repo/contracts" # Install pnpm if not available if ! command -v pnpm &> /dev/null; then npm install -g pnpm fi pnpm install echo "โœ… Node.js environment ready" - name: Run execution time benchmarks run: | cd "${{ env.WORKSPACE }}/repo/contracts" echo "๐Ÿงช Running execution time benchmarks" pnpm hardhat test test/benchmarks/execution-time.test.js echo "โœ… Execution time benchmarks completed" - name: Upload execution time report run: | cd "${{ env.WORKSPACE }}/repo" echo "๐Ÿ“Š Execution time report upload skipped (reports will be added when tests are implemented)" mkdir -p /var/lib/aitbc/benchmarks echo "Execution time report placeholder - $(date)" > /var/lib/aitbc/benchmarks/execution-time-placeholder-$(date +%Y%m%d-%H%M%S).json echo "โœ… Execution time report placeholder uploaded" - name: Cleanup if: always() run: rm -rf "${{ env.WORKSPACE }}" benchmark-throughput: runs-on: debian timeout-minutes: 30 env: WORKSPACE: /var/lib/aitbc-workspaces/throughput-benchmarks steps: - name: Clone repository run: | rm -rf "${{ env.WORKSPACE }}" mkdir -p "${{ env.WORKSPACE }}" cd "${{ env.WORKSPACE }}" git clone --depth 1 http://gitea.bubuit.net:3000/oib/aitbc.git repo - name: Initialize job logging run: | cd "${{ env.WORKSPACE }}/repo" bash scripts/ci/setup-job-logging.sh - name: Setup Node.js environment run: | cd "${{ env.WORKSPACE }}/repo/contracts" # Install pnpm if not available if ! command -v pnpm &> /dev/null; then npm install -g pnpm fi pnpm install echo "โœ… Node.js environment ready" - name: Run throughput benchmarks run: | cd "${{ env.WORKSPACE }}/repo/contracts" echo "๐Ÿงช Running throughput benchmarks" pnpm hardhat test test/benchmarks/throughput.test.js echo "โœ… Throughput benchmarks completed" - name: Upload throughput report run: | cd "${{ env.WORKSPACE }}/repo" echo "๐Ÿ“Š Throughput report upload skipped (reports will be added when tests are implemented)" mkdir -p /var/lib/aitbc/benchmarks echo "Throughput report placeholder - $(date)" > /var/lib/aitbc/benchmarks/throughput-placeholder-$(date +%Y%m%d-%H%M%S).json echo "โœ… Throughput report placeholder uploaded" - name: Cleanup if: always() run: rm -rf "${{ env.WORKSPACE }}" compare-benchmarks: runs-on: debian timeout-minutes: 15 needs: [benchmark-gas-usage, benchmark-execution-time, benchmark-throughput] env: WORKSPACE: /var/lib/aitbc-workspaces/benchmark-comparison steps: - name: Clone repository run: | rm -rf "${{ env.WORKSPACE }}" mkdir -p "${{ env.WORKSPACE }}" cd "${{ env.WORKSPACE }}" git clone --depth 1 http://gitea.bubuit.net:3000/oib/aitbc.git repo - name: Initialize job logging run: | cd "${{ env.WORKSPACE }}/repo" bash scripts/ci/setup-job-logging.sh - name: Compare with previous benchmarks run: | cd "${{ env.WORKSPACE }}/repo" echo "๐Ÿ“Š Comparing benchmark results" # Run comparison script bash scripts/benchmarking/compare-benchmarks.sh echo "โœ… Benchmark comparison completed" - name: Generate benchmark report run: | cd "${{ env.WORKSPACE }}/repo" echo "๐Ÿ“ Generating benchmark report" bash scripts/benchmarking/generate-report.sh echo "โœ… Benchmark report generated" - name: Cleanup if: always() run: rm -rf "${{ env.WORKSPACE }}"