fix duplicate line merges #228
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: SLO | |
| on: | |
| pull_request: | |
| types: [opened, reopened, synchronize, labeled] | |
| permissions: | |
| contents: read | |
| jobs: | |
| ydb-slo-action: | |
| if: contains(github.event.pull_request.labels.*.name, 'SLO') | |
| name: Run YDB SLO Tests (${{ matrix.sdk.name }}) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 120 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| sdk: | |
| - name: cpp-key-value | |
| preset: release-test-clang | |
| dockerfile: tests/slo_workloads/Dockerfile | |
| cache_scope: slo | |
| command: "" | |
| - name: cpp-key-value-userver | |
| preset: release-test-clang | |
| dockerfile: tests/slo_workloads/Dockerfile.userver | |
| cache_scope: slo-userver | |
| command: "" | |
| concurrency: | |
| group: slo-${{ github.ref }}-${{ matrix.sdk.name }} | |
| cancel-in-progress: true | |
| steps: | |
| - name: Install dependencies | |
| run: | | |
| set -euxo pipefail | |
| YQ_VERSION=v4.48.2 | |
| BUILDX_VERSION=0.30.1 | |
| COMPOSE_VERSION=2.40.3 | |
| sudo curl -fLo /usr/local/bin/yq \ | |
| "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" | |
| sudo chmod +x /usr/local/bin/yq | |
| sudo mkdir -p /usr/local/lib/docker/cli-plugins | |
| 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 | |
| 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 | |
| yq --version | |
| docker --version | |
| docker buildx version | |
| docker compose version | |
| - name: Checkout current SDK version | |
| uses: actions/checkout@v5 | |
| with: | |
| path: sdk-current | |
| fetch-depth: 0 | |
| submodules: true | |
| - name: Determine baseline commit | |
| id: baseline | |
| working-directory: sdk-current | |
| run: | | |
| set -euo pipefail | |
| BASELINE=$(git merge-base HEAD origin/main) | |
| echo "sha=${BASELINE}" >> "$GITHUB_OUTPUT" | |
| if git merge-base --is-ancestor "${BASELINE}" origin/main && \ | |
| [ "$(git rev-parse origin/main)" = "${BASELINE}" ]; then | |
| BASELINE_REF="main" | |
| else | |
| 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 SDK version | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ steps.baseline.outputs.sha }} | |
| path: sdk-baseline | |
| fetch-depth: 1 | |
| submodules: true | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # Use current's workload harness (Dockerfile, sources, .dockerignore) for | |
| # both builds so only the SDK library differs between current and | |
| # baseline. Without this the baseline image picks up the harness from | |
| # the merge-base commit, which can lag behind the action's contract. | |
| # buildx also expects .dockerignore at the context root, not under | |
| # tests/, so copy it up in each checkout. | |
| - name: Stage workload harness | |
| run: | | |
| set -euxo pipefail | |
| rm -rf sdk-baseline/tests/slo_workloads | |
| cp -a sdk-current/tests/slo_workloads sdk-baseline/tests/slo_workloads | |
| cp sdk-current/tests/slo_workloads/.dockerignore sdk-current/.dockerignore | |
| cp sdk-baseline/tests/slo_workloads/.dockerignore sdk-baseline/.dockerignore | |
| # `cache-to: type=gha` does NOT export `--mount=type=cache` content, so | |
| # ccache state is lost between runs. Persist /root/.ccache via host | |
| # directory + cache-dance: actions/cache restores the host dir, the | |
| # dance injects it into the BuildKit cache mount before the build and | |
| # extracts the updated state afterwards for the next save. | |
| - name: Restore ccache | |
| id: ccache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ccache | |
| key: ${{ matrix.sdk.cache_scope }}-ccache-${{ matrix.sdk.preset }}-${{ github.run_id }} | |
| restore-keys: | | |
| ${{ matrix.sdk.cache_scope }}-ccache-${{ matrix.sdk.preset }}- | |
| - name: Inject ccache into BuildKit | |
| uses: reproducible-containers/buildkit-cache-dance@v3.1.2 | |
| with: | |
| cache-map: | | |
| { | |
| "ccache": "/root/.ccache" | |
| } | |
| skip-extraction: false | |
| - name: Build current workload image | |
| uses: docker/build-push-action@v6 | |
| env: | |
| DOCKER_BUILD_SUMMARY: "false" | |
| DOCKER_BUILD_RECORD_UPLOAD: "false" | |
| with: | |
| context: sdk-current | |
| file: sdk-current/${{ matrix.sdk.dockerfile }} | |
| platforms: linux/amd64 | |
| tags: ydb-app-current | |
| load: true | |
| build-args: PRESET=${{ matrix.sdk.preset }} | |
| cache-from: type=gha,scope=${{ matrix.sdk.cache_scope }}-${{ matrix.sdk.preset }} | |
| cache-to: type=gha,mode=max,scope=${{ matrix.sdk.cache_scope }}-${{ matrix.sdk.preset }} | |
| - name: Build baseline workload image | |
| id: baseline-build | |
| continue-on-error: true | |
| uses: docker/build-push-action@v6 | |
| env: | |
| DOCKER_BUILD_SUMMARY: "false" | |
| DOCKER_BUILD_RECORD_UPLOAD: "false" | |
| with: | |
| context: sdk-baseline | |
| file: sdk-baseline/${{ matrix.sdk.dockerfile }} | |
| platforms: linux/amd64 | |
| tags: ydb-app-baseline | |
| load: true | |
| build-args: PRESET=${{ matrix.sdk.preset }} | |
| cache-from: type=gha,scope=${{ matrix.sdk.cache_scope }}-${{ matrix.sdk.preset }} | |
| - name: Fall back to current image for baseline | |
| if: steps.baseline-build.outcome == 'failure' | |
| run: | | |
| echo "Baseline build failed; reusing current image as baseline." | |
| docker tag ydb-app-current ydb-app-baseline | |
| - name: Run SLO Tests | |
| uses: ydb-platform/ydb-slo-action/init@v2 | |
| timeout-minutes: 30 | |
| with: | |
| github_issue: ${{ github.event.pull_request.number }} | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| workload_name: ${{ matrix.sdk.name }} | |
| workload_duration: "600" | |
| workload_current_ref: ${{ github.head_ref || github.ref_name }} | |
| workload_current_image: ydb-app-current | |
| workload_current_command: ${{ matrix.sdk.command }} --read-rps 1000 --write-rps 100 | |
| workload_baseline_ref: ${{ steps.baseline.outputs.ref }} | |
| workload_baseline_image: ydb-app-baseline | |
| workload_baseline_command: ${{ matrix.sdk.command }} --read-rps 1000 --write-rps 100 |