|
| 1 | +# .github/workflows/benchmarks.yml |
| 2 | +name: Validate-Benchmarks |
| 3 | + |
| 4 | +on: |
| 5 | + pull_request: |
| 6 | + types: |
| 7 | + - opened |
| 8 | + - synchronize |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: run-benchmarks-${{ github.ref }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + validate-benchmarks: |
| 17 | + runs-on: Benchmarking |
| 18 | + |
| 19 | + env: |
| 20 | + SKIP_BENCHMARKS: '0' |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Check out PR branch |
| 24 | + if: ${{ env.SKIP_BENCHMARKS != '1' }} |
| 25 | + uses: actions/checkout@v4 |
| 26 | + with: |
| 27 | + ref: ${{ github.head_ref }} |
| 28 | + fetch-depth: 0 |
| 29 | + |
| 30 | + - name: Install GitHub CLI |
| 31 | + if: ${{ env.SKIP_BENCHMARKS != '1' }} |
| 32 | + run: | |
| 33 | + sudo apt-get update |
| 34 | + sudo apt-get install -y gh |
| 35 | + echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token |
| 36 | +
|
| 37 | + - name: Check skip label |
| 38 | + if: ${{ env.SKIP_BENCHMARKS != '1' }} |
| 39 | + run: | |
| 40 | + labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') |
| 41 | + if echo "$labels" | grep -q "skip-validate-benchmarks"; then |
| 42 | + echo "skip-validate-benchmarks label found — skipping benchmarks." |
| 43 | + echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV" |
| 44 | + fi |
| 45 | +
|
| 46 | + - name: Install system dependencies |
| 47 | + if: ${{ env.SKIP_BENCHMARKS != '1' }} |
| 48 | + run: | |
| 49 | + sudo apt-get update |
| 50 | + sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler |
| 51 | +
|
| 52 | + - name: Check skip label |
| 53 | + if: ${{ env.SKIP_BENCHMARKS != '1' }} |
| 54 | + run: | |
| 55 | + labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') |
| 56 | + if echo "$labels" | grep -q "skip-validate-benchmarks"; then |
| 57 | + echo "skip-validate-benchmarks label found — skipping benchmarks." |
| 58 | + echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV" |
| 59 | + fi |
| 60 | +
|
| 61 | + - name: Install Rust toolchain |
| 62 | + if: ${{ env.SKIP_BENCHMARKS != '1' }} |
| 63 | + uses: actions-rs/toolchain@v1 |
| 64 | + with: |
| 65 | + profile: minimal |
| 66 | + toolchain: stable |
| 67 | + |
| 68 | + - name: Check skip label |
| 69 | + if: ${{ env.SKIP_BENCHMARKS != '1' }} |
| 70 | + run: | |
| 71 | + labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') |
| 72 | + if echo "$labels" | grep -q "skip-validate-benchmarks"; then |
| 73 | + echo "skip-validate-benchmarks label found — skipping benchmarks." |
| 74 | + echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV" |
| 75 | + fi |
| 76 | +
|
| 77 | + - name: Cache Rust build |
| 78 | + if: ${{ env.SKIP_BENCHMARKS != '1' }} |
| 79 | + uses: Swatinem/rust-cache@v2 |
| 80 | + with: |
| 81 | + key: bench-${{ hashFiles('**/Cargo.lock') }} |
| 82 | + |
| 83 | + - name: Check skip label |
| 84 | + if: ${{ env.SKIP_BENCHMARKS != '1' }} |
| 85 | + run: | |
| 86 | + labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') |
| 87 | + if echo "$labels" | grep -q "skip-validate-benchmarks"; then |
| 88 | + echo "skip-validate-benchmarks label found — skipping benchmarks." |
| 89 | + echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV" |
| 90 | + fi |
| 91 | +
|
| 92 | + - name: Build node with benchmarks |
| 93 | + if: ${{ env.SKIP_BENCHMARKS != '1' }} |
| 94 | + run: | |
| 95 | + cargo build --profile production -p node-subtensor --features runtime-benchmarks |
| 96 | +
|
| 97 | + - name: Check skip label |
| 98 | + if: ${{ env.SKIP_BENCHMARKS != '1' }} |
| 99 | + run: | |
| 100 | + labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') |
| 101 | + if echo "$labels" | grep -q "skip-validate-benchmarks"; then |
| 102 | + echo "skip-validate-benchmarks label found — skipping benchmarks." |
| 103 | + echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV" |
| 104 | + fi |
| 105 | +
|
| 106 | + - name: Run & validate benchmarks |
| 107 | + if: ${{ env.SKIP_BENCHMARKS != '1' }} |
| 108 | + run: | |
| 109 | + chmod +x scripts/benchmark_action.sh |
| 110 | + ./scripts/benchmark_action.sh |
| 111 | +
|
| 112 | + - name: Check skip label after run |
| 113 | + if: ${{ env.SKIP_BENCHMARKS != '1' }} |
| 114 | + run: | |
| 115 | + labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') |
| 116 | + if echo "$labels" | grep -q "skip-validate-benchmarks"; then |
| 117 | + echo "skip-validate-benchmarks label was found — but benchmarks already ran." |
| 118 | + fi |
0 commit comments