|
| 1 | +on: |
| 2 | + workflow_call: |
| 3 | + inputs: |
| 4 | + architecture: |
| 5 | + required: true |
| 6 | + type: string |
| 7 | + instance-type: |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + ami-id: |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + |
| 14 | +env: |
| 15 | + TAGS: | # Make sure there is no trailing comma! |
| 16 | + [ |
| 17 | + {"Key": "Name", "Value": "redisearch-ci-runner"}, |
| 18 | + {"Key": "Environment", "Value": "CI"}, |
| 19 | + {"Key": "Run ID", "Value": "${{ github.run_id }}"}, |
| 20 | + {"Key": "PR", "Value": "${{ github.event.number }}"}, |
| 21 | + {"Key": "Owner", "Value": "${{ github.actor }}"}, |
| 22 | + {"Key": "Project", "Value": "${{ github.repository }}"}, |
| 23 | + {"Key": "Context", "Value": "micro-benchmarks"} |
| 24 | + ] |
| 25 | +
|
| 26 | +jobs: |
| 27 | + start-runner: |
| 28 | + name: Start self-hosted EC2 runner |
| 29 | + runs-on: ubuntu-latest |
| 30 | + outputs: |
| 31 | + runner_label: ${{ steps.start-ec2-runner.outputs.label }} |
| 32 | + ec2_instance_id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }} |
| 33 | + steps: |
| 34 | + - name: Configure AWS credentials |
| 35 | + uses: aws-actions/configure-aws-credentials@v4 |
| 36 | + with: |
| 37 | + aws-access-key-id: ${{ secrets.PERFORMANCE_EC2_ACCESS_KEY }} |
| 38 | + aws-secret-access-key: ${{ secrets.PERFORMANCE_EC2_SECRET_KEY }} |
| 39 | + aws-region: ${{ secrets.PERFORMANCE_EC2_AWS_REGION }} |
| 40 | + - name: Start EC2 runner |
| 41 | + id: start-ec2-runner |
| 42 | + uses: machulav/ec2-github-runner@v2 |
| 43 | + with: |
| 44 | + mode: start |
| 45 | + github-token: ${{ secrets.CI_GH_P_TOKEN }} |
| 46 | + ec2-image-id: ${{ inputs.ami-id }} |
| 47 | + ec2-instance-type: ${{ inputs.instance-type }} |
| 48 | + subnet-id: ${{ secrets.AWS_EC2_SUBNET_ID_BENCHMARK }} |
| 49 | + security-group-id: ${{ secrets.AWS_EC2_SG_ID_BENCHMARK }} |
| 50 | + aws-resource-tags: ${{ env.TAGS }} |
| 51 | + |
| 52 | + micro-benchmark: |
| 53 | + name: Run micro-benchmarks on runner |
| 54 | + needs: start-runner |
| 55 | + runs-on: ${{ needs.start-runner.outputs.runner_label }} |
| 56 | + steps: |
| 57 | + - name: Pre checkout deps |
| 58 | + run: sudo apt-get update && sudo apt-get -y install git |
| 59 | + - name: Checkout code |
| 60 | + uses: actions/checkout@v4 |
| 61 | + with: |
| 62 | + submodules: recursive |
| 63 | + - name: Print runner info |
| 64 | + run: | |
| 65 | + printf "Runner lscpu:\n$(lscpu)\n" |
| 66 | + printf "Runner lsmem:\n$(lsmem)\n" |
| 67 | + printf "Runner nproc:\n$(nproc)\n" |
| 68 | + printf "Runner uname:\n$(uname -a)\n" |
| 69 | + printf "Runner arch:\n$(arch)\n" |
| 70 | + - name: Install benchmark dependencies |
| 71 | + run: | |
| 72 | + export HOME=/home/ubuntu |
| 73 | + cd .install |
| 74 | + ./install_script.sh sudo |
| 75 | + cd .. |
| 76 | + # Then install Python dependencies |
| 77 | + sudo apt install python3-pip -y |
| 78 | + pip3 install --upgrade pip PyYAML setuptools redisbench-admin>=0.11.37 |
| 79 | + env: |
| 80 | + DEBIAN_FRONTEND: noninteractive |
| 81 | + - name: Run Micro Benchmark |
| 82 | + env: |
| 83 | + ARCH: ${{ inputs.architecture }} |
| 84 | + timeout-minutes: 300 |
| 85 | + run: | |
| 86 | + export HOME=/home/ubuntu |
| 87 | + export PATH="$HOME/.cargo/bin:$PATH" |
| 88 | + ./build.sh run_microbenchmarks |
| 89 | + - name: Collect results |
| 90 | + run: | |
| 91 | + # Determine OS name |
| 92 | + OS_NAME=$(uname | tr '[:upper:]' '[:lower:]') |
| 93 | + if [[ "$OS_NAME" == "darwin" ]]; then |
| 94 | + OS_NAME="macos" |
| 95 | + fi |
| 96 | +
|
| 97 | + # Get architecture using uname -m |
| 98 | + ARCH=$(uname -m) |
| 99 | + if [[ "$ARCH" == "arm64" ]]; then |
| 100 | + ARCH="aarch64" |
| 101 | + elif [[ "$ARCH" == "x86_64" ]]; then |
| 102 | + ARCH="x64" |
| 103 | + fi |
| 104 | +
|
| 105 | + # Set flavor (assuming release build for benchmarks) |
| 106 | + FLAVOR="release" |
| 107 | +
|
| 108 | + # Create full variant string for the build directory |
| 109 | + FULL_VARIANT="${OS_NAME}-${ARCH}-${FLAVOR}" |
| 110 | +
|
| 111 | + # Set coordinator type (assuming OSS) |
| 112 | + COORD="oss" |
| 113 | + OUTDIR="search-community" |
| 114 | +
|
| 115 | + # Set the final BINDIR |
| 116 | + BINDIR="bin/${FULL_VARIANT}/${OUTDIR}" |
| 117 | +
|
| 118 | + # Update the binary directory path for ARM architectures |
| 119 | + echo "Looking for benchmark results in $BINDIR/micro-benchmarks" |
| 120 | +
|
| 121 | + # Find all JSON result files |
| 122 | + JSON_FILES=$(find $BINDIR/micro-benchmarks -name "*_results.json") |
| 123 | +
|
| 124 | + if [ -z "$JSON_FILES" ]; then |
| 125 | + echo "No benchmark result files found in $BINDIR/micro-benchmarks" |
| 126 | + exit 1 |
| 127 | + fi |
| 128 | +
|
| 129 | + # Print found files for debugging |
| 130 | + echo "Found the following result files:" |
| 131 | + echo "$JSON_FILES" | tr ' ' '\n' |
| 132 | +
|
| 133 | + # Process each file individually |
| 134 | + for file in $JSON_FILES; do |
| 135 | + echo "Processing $file..." |
| 136 | + redisbench-admin export \ |
| 137 | + --redistimeseries_host ${{ secrets.PERFORMANCE_RTS_HOST }} \ |
| 138 | + --redistimeseries_port ${{ secrets.PERFORMANCE_RTS_PORT }} \ |
| 139 | + --redistimeseries_user default \ |
| 140 | + --redistimeseries_pass '${{ secrets.PERFORMANCE_RTS_AUTH }}' \ |
| 141 | + --github_repo ${{ github.event.repository.name }} \ |
| 142 | + --github_org ${{ github.repository_owner }} \ |
| 143 | + --github_branch ${{ github.head_ref || github.ref_name }} \ |
| 144 | + --github_actor ${{ github.triggering_actor }} \ |
| 145 | + --results-format google.benchmark \ |
| 146 | + --benchmark-result-file "$file" \ |
| 147 | + --triggering_env redisearch-micro-benchmarks \ |
| 148 | + --architecture ${{ inputs.architecture }} |
| 149 | + done |
| 150 | +
|
| 151 | + stop-runner: |
| 152 | + name: Stop self-hosted EC2 runner |
| 153 | + needs: |
| 154 | + - start-runner # required to get output from the start-runner job |
| 155 | + - micro-benchmark # required to wait when the main job is done |
| 156 | + runs-on: ubuntu-latest |
| 157 | + if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs |
| 158 | + steps: |
| 159 | + - name: Configure AWS credentials |
| 160 | + uses: aws-actions/configure-aws-credentials@v4 |
| 161 | + with: |
| 162 | + aws-access-key-id: ${{ secrets.PERFORMANCE_EC2_ACCESS_KEY }} |
| 163 | + aws-secret-access-key: ${{ secrets.PERFORMANCE_EC2_SECRET_KEY }} |
| 164 | + aws-region: ${{ secrets.PERFORMANCE_EC2_AWS_REGION }} |
| 165 | + - name: Stop EC2 runner |
| 166 | + uses: machulav/ec2-github-runner@v2 |
| 167 | + with: |
| 168 | + mode: stop |
| 169 | + github-token: ${{ secrets.CI_GH_P_TOKEN }} |
| 170 | + label: ${{ needs.start-runner.outputs.runner_label }} |
| 171 | + ec2-instance-id: ${{ needs.start-runner.outputs.ec2_instance_id }} |
0 commit comments