Skip to content

Refactor SLO workload to use environment variables #1470

Refactor SLO workload to use environment variables

Refactor SLO workload to use environment variables #1470

Workflow file for this run

name: SLO
on:
pull_request:
types: [opened, reopened, synchronize, labeled]
branches:
- main
workflow_dispatch:
inputs:
github_issue:
description: "GitHub issue / PR number where the SLO report will be posted (optional; will be inferred for PR runs)"
required: false
baseline_ref:
description: "Baseline commit/branch/tag to compare against (leave empty to auto-detect merge-base with main)"
required: false
slo_workload_read_max_rps:
description: "Maximum read RPS for the SLO workload"
required: false
default: "1000"
slo_workload_write_max_rps:
description: "Maximum write RPS for the SLO workload"
required: false
default: "100"
slo_workload_duration_seconds:
description: "Duration of the SLO workload in seconds"
required: false
default: "600"
permissions:
contents: read
pull-requests: write
checks: write
jobs:
ydb-slo-action:
name: Run YDB SLO Tests
runs-on: "large-runner-python-sdk"
# Run on PRs only when labeled "SLO"; allow manual runs via workflow_dispatch
if: ${{ github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'SLO') }}
strategy:
fail-fast: false
matrix:
sdk:
- name: sync-table
command: "--read-rps ${{ inputs.slo_workload_read_max_rps || '1000' }} --write-rps ${{ inputs.slo_workload_write_max_rps || '100' }}"
- name: sync-query
command: "--read-rps ${{ inputs.slo_workload_read_max_rps || '1000' }} --write-rps ${{ inputs.slo_workload_write_max_rps || '100' }}"
concurrency:
group: slo-${{ github.ref }}-${{ matrix.sdk.name }}
cancel-in-progress: true
steps:
- name: Install dependencies
run: |
YQ_VERSION=v4.48.2
BUILDX_VERSION=0.30.1
COMPOSE_VERSION=2.40.3
sudo curl -L https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -o /usr/local/bin/yq && \
sudo chmod +x /usr/local/bin/yq
echo "Updating Docker plugins..."
sudo mkdir -p /usr/local/lib/docker/cli-plugins
echo "Installing Docker Buildx ${BUILDX_VERSION}..."
sudo curl -fLo /usr/local/lib/docker/cli-plugins/docker-buildx \
"https://github.com/docker/buildx/releases/download/v${BUILDX_VERSION}/buildx-v${BUILDX_VERSION}.linux-amd64"
sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-buildx
echo "Installing Docker Compose ${COMPOSE_VERSION}..."
sudo curl -fLo /usr/local/lib/docker/cli-plugins/docker-compose \
"https://github.com/docker/compose/releases/download/v${COMPOSE_VERSION}/docker-compose-linux-x86_64"
sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
echo "Installed versions:"
yq --version
docker --version
docker buildx version
docker compose version
- name: Checkout current version
uses: actions/checkout@v6
with:
path: current
fetch-depth: 0
- name: Determine baseline commit
id: baseline
shell: bash
run: |
cd current
if [[ -n "${{ inputs.baseline_ref }}" ]]; then
BASELINE="${{ inputs.baseline_ref }}"
else
BASELINE=$(git merge-base HEAD origin/main)
fi
echo "sha=$BASELINE" >> $GITHUB_OUTPUT
# Try to determine a human-readable ref name for baseline
# Check if baseline is on main
if git merge-base --is-ancestor $BASELINE origin/main && \
[ "$(git rev-parse origin/main)" = "$BASELINE" ]; then
BASELINE_REF="main"
else
# Try to find a branch containing this commit
BRANCH=$(git branch -r --contains $BASELINE | grep -v HEAD | head -1 | sed 's/.*\///' || echo "")
if [ -n "$BRANCH" ]; then
BASELINE_REF="${BRANCH}@${BASELINE:0:7}"
else
BASELINE_REF="${BASELINE:0:7}"
fi
fi
echo "ref=$BASELINE_REF" >> $GITHUB_OUTPUT
- name: Checkout baseline version
uses: actions/checkout@v6
with:
ref: ${{ steps.baseline.outputs.sha }}
path: baseline
- name: Build workload images (current + baseline)
run: |
docker build \
-f "$GITHUB_WORKSPACE/current/tests/slo/Dockerfile" \
-t "ydb-app-current" \
"$GITHUB_WORKSPACE/current"
docker build \
-f "$GITHUB_WORKSPACE/baseline/tests/slo/Dockerfile" \
-t "ydb-app-baseline" \
"$GITHUB_WORKSPACE/baseline"
- name: Run SLO Tests
uses: ydb-platform/ydb-slo-action/init@v2
timeout-minutes: 30
with:
github_issue: ${{ github.event.inputs.github_issue }}
github_token: ${{ secrets.GITHUB_TOKEN }}
workload_name: ${{ matrix.sdk.name }}
workload_duration: ${{ inputs.slo_workload_duration_seconds || '600' }}
workload_current_ref: ${{ github.head_ref || github.ref_name }}
workload_current_image: ydb-app-current
workload_current_command: ${{ matrix.sdk.command }}
workload_baseline_ref: ${{ steps.baseline.outputs.ref }}
workload_baseline_image: ydb-app-current
workload_baseline_command: ${{ matrix.sdk.command }}
ydb-slo-action-report:
runs-on: ubuntu-latest
name: Publish YDB SLO Report
needs: ydb-slo-action
permissions:
checks: write
contents: read
pull-requests: write
steps:
- name: Publish YDB SLO Report
uses: ydb-platform/ydb-slo-action/report@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_run_id: ${{ github.run_id }}