|
| 1 | +name: Performance Tests |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - release* |
| 8 | + - release/* |
| 9 | + - release-* |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + workflow_dispatch: |
| 14 | + inputs: |
| 15 | + compare_baseline: |
| 16 | + description: "Compare against baseline metrics" |
| 17 | + required: false |
| 18 | + default: "true" |
| 19 | + |
| 20 | +jobs: |
| 21 | + performance: |
| 22 | + name: E2E Performance Tests |
| 23 | + runs-on: ${{ matrix.os }} |
| 24 | + strategy: |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + include: |
| 28 | + - os: windows-latest |
| 29 | + target: x86_64-pc-windows-msvc |
| 30 | + - os: ubuntu-latest |
| 31 | + target: x86_64-unknown-linux-musl |
| 32 | + - os: macos-latest |
| 33 | + target: x86_64-apple-darwin |
| 34 | + - os: macos-14 |
| 35 | + target: aarch64-apple-darwin |
| 36 | + steps: |
| 37 | + - name: Checkout |
| 38 | + uses: actions/checkout@v4 |
| 39 | + |
| 40 | + - name: Set Python to PATH |
| 41 | + uses: actions/setup-python@v5 |
| 42 | + with: |
| 43 | + python-version: "3.12" |
| 44 | + |
| 45 | + - name: Add Conda to PATH (Windows) |
| 46 | + if: startsWith(matrix.os, 'windows') |
| 47 | + run: | |
| 48 | + $path = $env:PATH + ";" + $env:CONDA + "\condabin" |
| 49 | + echo "PATH=$path" >> $env:GITHUB_ENV |
| 50 | +
|
| 51 | + - name: Add Conda to PATH (Ubuntu) |
| 52 | + if: startsWith(matrix.os, 'ubuntu') |
| 53 | + run: echo "PATH=$PATH:$CONDA/condabin" >> $GITHUB_ENV |
| 54 | + shell: bash |
| 55 | + |
| 56 | + - name: Install Conda + add to PATH (macOS) |
| 57 | + if: startsWith(matrix.os, 'macos') |
| 58 | + run: | |
| 59 | + if [[ "${{ matrix.target }}" == "aarch64-apple-darwin" ]]; then |
| 60 | + curl -o ~/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh |
| 61 | + else |
| 62 | + curl -o ~/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh |
| 63 | + fi |
| 64 | + bash ~/miniconda.sh -b -p ~/miniconda |
| 65 | + echo "PATH=$PATH:$HOME/miniconda/bin" >> $GITHUB_ENV |
| 66 | + echo "CONDA=$HOME/miniconda" >> $GITHUB_ENV |
| 67 | + shell: bash |
| 68 | + |
| 69 | + - name: Create test Conda environment |
| 70 | + run: conda create -n perf-test-env python=3.12 -y |
| 71 | + |
| 72 | + - name: Create test venv |
| 73 | + run: python -m venv .venv |
| 74 | + shell: bash |
| 75 | + |
| 76 | + - name: Rust Tool Chain setup |
| 77 | + uses: dtolnay/rust-toolchain@stable |
| 78 | + with: |
| 79 | + toolchain: stable |
| 80 | + targets: ${{ matrix.target }} |
| 81 | + |
| 82 | + - name: Cargo Fetch |
| 83 | + run: cargo fetch |
| 84 | + shell: bash |
| 85 | + |
| 86 | + - name: Build Release |
| 87 | + run: cargo build --release --target ${{ matrix.target }} |
| 88 | + shell: bash |
| 89 | + |
| 90 | + - name: Run Performance Tests |
| 91 | + run: cargo test --release --features ci-perf --target ${{ matrix.target }} -- --nocapture --test-threads=1 2>&1 | tee perf-output.txt |
| 92 | + env: |
| 93 | + RUST_BACKTRACE: 1 |
| 94 | + RUST_LOG: warn |
| 95 | + shell: bash |
| 96 | + |
| 97 | + - name: Extract Performance Metrics |
| 98 | + id: metrics |
| 99 | + run: | |
| 100 | + # Extract JSON metrics from test output |
| 101 | + if grep -q "JSON metrics:" perf-output.txt; then |
| 102 | + # Extract lines after "JSON metrics:" until the closing brace |
| 103 | + sed -n '/JSON metrics:/,/^}/p' perf-output.txt | tail -n +2 > metrics.json |
| 104 | + |
| 105 | + # Parse key metrics |
| 106 | + SERVER_STARTUP=$(jq -r '.server_startup_ms // "N/A"' metrics.json) |
| 107 | + FULL_REFRESH=$(jq -r '.full_refresh_ms // "N/A"' metrics.json) |
| 108 | + ENV_COUNT=$(jq -r '.environments_count // "N/A"' metrics.json) |
| 109 | + |
| 110 | + echo "server_startup_ms=$SERVER_STARTUP" >> $GITHUB_OUTPUT |
| 111 | + echo "full_refresh_ms=$FULL_REFRESH" >> $GITHUB_OUTPUT |
| 112 | + echo "environments_count=$ENV_COUNT" >> $GITHUB_OUTPUT |
| 113 | + |
| 114 | + echo "### Performance Metrics (${{ matrix.os }})" >> $GITHUB_STEP_SUMMARY |
| 115 | + echo "| Metric | Value |" >> $GITHUB_STEP_SUMMARY |
| 116 | + echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY |
| 117 | + echo "| Server Startup | ${SERVER_STARTUP}ms |" >> $GITHUB_STEP_SUMMARY |
| 118 | + echo "| Full Refresh | ${FULL_REFRESH}ms |" >> $GITHUB_STEP_SUMMARY |
| 119 | + echo "| Environments Found | ${ENV_COUNT} |" >> $GITHUB_STEP_SUMMARY |
| 120 | + else |
| 121 | + echo "No JSON metrics found in output" |
| 122 | + fi |
| 123 | + shell: bash |
| 124 | + |
| 125 | + - name: Upload Performance Results |
| 126 | + uses: actions/upload-artifact@v4 |
| 127 | + with: |
| 128 | + name: perf-results-${{ matrix.os }}-${{ matrix.target }} |
| 129 | + path: | |
| 130 | + perf-output.txt |
| 131 | + metrics.json |
| 132 | + if-no-files-found: ignore |
| 133 | + |
| 134 | + summary: |
| 135 | + name: Performance Summary |
| 136 | + needs: performance |
| 137 | + runs-on: ubuntu-latest |
| 138 | + if: always() |
| 139 | + steps: |
| 140 | + - name: Download all artifacts |
| 141 | + uses: actions/download-artifact@v4 |
| 142 | + with: |
| 143 | + path: perf-results |
| 144 | + |
| 145 | + - name: Generate Summary Report |
| 146 | + run: | |
| 147 | + echo "# Performance Test Results" >> $GITHUB_STEP_SUMMARY |
| 148 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 149 | + echo "| Platform | Server Startup | Full Refresh | Environments |" >> $GITHUB_STEP_SUMMARY |
| 150 | + echo "|----------|----------------|--------------|--------------|" >> $GITHUB_STEP_SUMMARY |
| 151 | +
|
| 152 | + for dir in perf-results/*/; do |
| 153 | + if [ -f "${dir}metrics.json" ]; then |
| 154 | + platform=$(basename "$dir" | sed 's/perf-results-//') |
| 155 | + startup=$(jq -r '.server_startup_ms // "N/A"' "${dir}metrics.json") |
| 156 | + refresh=$(jq -r '.full_refresh_ms // "N/A"' "${dir}metrics.json") |
| 157 | + envs=$(jq -r '.environments_count // "N/A"' "${dir}metrics.json") |
| 158 | + echo "| $platform | ${startup}ms | ${refresh}ms | $envs |" >> $GITHUB_STEP_SUMMARY |
| 159 | + fi |
| 160 | + done |
| 161 | + shell: bash |
0 commit comments