Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 10 additions & 51 deletions .github/workflows/slo-report.yml
Original file line number Diff line number Diff line change
@@ -1,69 +1,28 @@
name: slo-report

# Reporting for pull requests from forks: their `pull_request` token is read-only,
# so the SLO workflow cannot publish the report itself. `workflow_run` runs in the
# base repository and has the permissions to do it.
#
# Everything else is reported by the SLO workflow directly, see slo.yml.
# Fork PRs need the privileged base-repository publisher.
# No pull request code is checked out by this privileged publisher.
on:
workflow_run:
workflows: ["SLO"]
types:
- completed
types: [completed]

jobs:
publish-slo-report:
if: >-
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.head_repository.full_name != github.repository
runs-on: ubuntu-latest
name: Publish YDB SLO Report
permissions:
actions: read
checks: write
contents: read
pull-requests: write
if: >-
github.event.workflow_run.conclusion != 'cancelled' &&
github.event.workflow_run.conclusion != 'skipped' &&
github.event.workflow_run.head_repository.full_name != github.repository
steps:
- name: Publish YDB SLO Report
uses: ydb-platform/ydb-slo-action/report@v2
uses: ydb-platform/ydb-slo-action/report@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_run_id: ${{ github.event.workflow_run.id }}

remove-slo-label:
needs: publish-slo-report
if: >-
always() && github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion != 'skipped' &&
github.event.workflow_run.head_repository.full_name != github.repository
runs-on: ubuntu-latest
name: Remove SLO Label
permissions:
pull-requests: write
steps:
- name: Remove SLO label from PR
uses: actions/github-script@v7
with:
script: |
const pullRequests = context.payload.workflow_run.pull_requests;
if (!pullRequests || pullRequests.length === 0) {
console.log('No pull requests associated with this workflow run');
return;
}
for (const pr of pullRequests) {
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
name: 'SLO'
});
console.log(`Removed SLO label from PR #${pr.number}`);
} catch (error) {
if (error.status === 404) {
console.log(`SLO label not found on PR #${pr.number}, skipping`);
} else {
throw error;
}
}
}
github_workflows: SLO
remove_label: SLO
76 changes: 21 additions & 55 deletions .github/workflows/slo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,28 +110,24 @@ jobs:
path: baseline
fetch-depth: 1

- name: Check baseline workload availability
id: baseline-workload
- name: Stage shared workload harness
run: |
# Revisions older than the migration to ydb-slo-action cannot report the
# metrics the report is built from, so they are not used as a baseline.
if [[ -f "$GITHUB_WORKSPACE/baseline/slo-workload/src/Metrics.php" ]]; then
echo "available=true" >> "$GITHUB_OUTPUT"
else
echo "available=false" >> "$GITHUB_OUTPUT"
fi
set -euxo pipefail
# Share the checker, not the SDK sources or the built image.
rm -rf "$GITHUB_WORKSPACE/baseline/slo-workload"
cp -a "$GITHUB_WORKSPACE/current/slo-workload" "$GITHUB_WORKSPACE/baseline/slo-workload"

- name: Build current workload image
working-directory: current
run: docker build --platform linux/amd64 -f slo-workload/Dockerfile -t ydb-app-current .

- name: Build baseline workload image
if: steps.baseline-workload.outputs.available == 'true'
working-directory: baseline
run: docker build --platform linux/amd64 -f slo-workload/Dockerfile -t ydb-app-baseline .

- name: Run SLO Tests
uses: ydb-platform/ydb-slo-action/init@v2
# Pin legacy telemetry fixes until ydb-slo-action#81 is merged.
uses: ydb-platform/ydb-slo-action/init@d66bd1e10f893e5f70d542c4430a3cffb6d6f9f8
timeout-minutes: 30
with:
github_issue: ${{ github.event.inputs.github_issue }}
Expand All @@ -144,67 +140,37 @@ jobs:
workload_current_command: >-
-read-rps ${{ inputs.slo_workload_read_max_rps || '1000' }}
-write-rps ${{ inputs.slo_workload_write_max_rps || '100' }}
workload_baseline_ref: ${{ steps.baseline-workload.outputs.available == 'true' && steps.baseline.outputs.ref || '' }}
workload_baseline_image: ${{ steps.baseline-workload.outputs.available == 'true' && 'ydb-app-baseline' || '' }}
workload_baseline_ref: ${{ steps.baseline.outputs.ref }}
workload_baseline_image: ydb-app-baseline
workload_baseline_command: >-
-read-rps ${{ inputs.slo_workload_read_max_rps || '1000' }}
-write-rps ${{ inputs.slo_workload_write_max_rps || '100' }}
disable_compose_profiles: ${{ steps.baseline-workload.outputs.available != 'true' && 'workload-baseline' || '' }}
workload_type: table

# Pull requests from forks get their report from slo-report.yml: their token is
# read-only and cannot publish anything.
# Build graph artifacts for every run. Same-repository PRs report directly;
# fork PR comments belong to the privileged workflow_run publisher.
publish-slo-report:
needs: ydb-slo-action
if: >-
!cancelled() && needs.ydb-slo-action.result != 'skipped' &&
(github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository)
!cancelled() && needs.ydb-slo-action.result != 'skipped'

name: Publish YDB SLO Report
runs-on: ubuntu-latest
permissions:
actions: read
checks: write
contents: read
pull-requests: write

steps:
- name: Publish YDB SLO Report
uses: ydb-platform/ydb-slo-action/report@v2
uses: ydb-platform/ydb-slo-action/report@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_run_id: ${{ github.run_id }}

# Pull requests from forks get the label removed by slo-report.yml: their token is
# read-only and cannot edit the labels.
remove-slo-label:
needs: [ydb-slo-action, publish-slo-report]
if: >-
always() && needs.ydb-slo-action.result != 'skipped' &&
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository

name: Remove SLO Label
runs-on: ubuntu-latest
permissions:
pull-requests: write

steps:
- name: Remove SLO label from PR
uses: actions/github-script@v7
with:
script: |
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: 'SLO'
});
console.log(`Removed SLO label from PR #${context.issue.number}`);
} catch (error) {
if (error.status === 404) {
console.log(`SLO label not found on PR #${context.issue.number}, skipping`);
} else {
throw error;
}
}
post_comment: >-
${{ github.event_name == 'workflow_dispatch' ||
github.event.pull_request.head.repo.full_name == github.repository }}
remove_label: >-
${{ github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository && 'SLO' || '' }}
10 changes: 10 additions & 0 deletions slo-workload/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ deploys a YDB cluster with Prometheus and a chaos monkey, starts the workload im
revision side by side, and builds a comparison report out of the metrics both of them push. See
[.github/workflows/slo.yml](../.github/workflows/slo.yml) and [.github/workflows/slo-report.yml](../.github/workflows/slo-report.yml).

The workflow uses Action v3 with `metrics_schema: legacy_table`, retaining the
existing `sdk.*` metrics. A baseline SDK checkout is always built independently.
Both builds use the current `slo-workload` harness so older SDK revisions can
participate without changing their SDK sources. A failed baseline build fails
the job; the current image is never substituted for it.

Same-repository PRs publish their report directly; fork PRs use the privileged
`workflow_run` publisher without checking out PR code. Action v3 removes the
`SLO` label after reporting, including when report generation fails.

## Usage

```
Expand Down
Loading