|
| 1 | +# SPDX-License-Identifier: Apache-2.0 |
| 2 | +# SPDX-FileCopyrightText: Copyright the Vortex contributors |
| 3 | + |
| 4 | +name: "Fetch benchmark baseline" |
| 5 | +description: >- |
| 6 | + Write the develop baseline for a PR benchmark run, read from the benchmarks Postgres: assume the |
| 7 | + read-only benchmarks role over OIDC and sign in as bench_ci_read with an RDS IAM token. If the |
| 8 | + baseline cannot be read, it writes no baseline file and the report says the baseline could not be |
| 9 | + read. The calling job needs `id-token: write`. Composite actions cannot read `vars`, so callers |
| 10 | + pass the repository variables in. |
| 11 | +
|
| 12 | +inputs: |
| 13 | + pr-records: |
| 14 | + description: "The PR run's --ingest-jsonl output" |
| 15 | + default: results.ingest.jsonl |
| 16 | + output: |
| 17 | + description: "Where to write the baseline records" |
| 18 | + default: base.ingest.jsonl |
| 19 | + role-arn: |
| 20 | + description: "The read-only benchmarks role (vars.GH_BENCH_READ_ROLE_ARN)" |
| 21 | + required: true |
| 22 | + region: |
| 23 | + description: "AWS region of the benchmarks RDS instance (vars.RDS_BENCH_REGION)" |
| 24 | + required: true |
| 25 | + endpoint: |
| 26 | + description: "Hostname of the benchmarks RDS instance (vars.RDS_BENCH_INSTANCE_ENDPOINT)" |
| 27 | + required: true |
| 28 | + database: |
| 29 | + description: "Name of the benchmarks database (vars.RDS_BENCH_DB_NAME)" |
| 30 | + required: true |
| 31 | + |
| 32 | +runs: |
| 33 | + using: "composite" |
| 34 | + steps: |
| 35 | + # The credentials stay in step outputs so the job's existing AWS credentials, which later |
| 36 | + # steps such as the S3 cleanup still use, are not replaced. |
| 37 | + - name: Configure AWS credentials for the benchmarks database (OIDC) |
| 38 | + id: aws |
| 39 | + if: inputs.role-arn != '' |
| 40 | + continue-on-error: true |
| 41 | + uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6 |
| 42 | + with: |
| 43 | + role-to-assume: ${{ inputs.role-arn }} |
| 44 | + aws-region: ${{ inputs.region }} |
| 45 | + retry-max-attempts: 1 |
| 46 | + output-credentials: true |
| 47 | + output-env-credentials: false |
| 48 | + - name: Fetch baseline |
| 49 | + shell: bash |
| 50 | + env: |
| 51 | + PR_RECORDS: ${{ inputs.pr-records }} |
| 52 | + OUTPUT: ${{ inputs.output }} |
| 53 | + AWS_OUTCOME: ${{ steps.aws.outcome }} |
| 54 | + AWS_ACCESS_KEY_ID: ${{ steps.aws.outputs.aws-access-key-id }} |
| 55 | + AWS_SECRET_ACCESS_KEY: ${{ steps.aws.outputs.aws-secret-access-key }} |
| 56 | + AWS_SESSION_TOKEN: ${{ steps.aws.outputs.aws-session-token }} |
| 57 | + AWS_REGION: ${{ inputs.region }} |
| 58 | + RDS_BENCH_INSTANCE_ENDPOINT: ${{ inputs.endpoint }} |
| 59 | + RDS_BENCH_DB_NAME: ${{ inputs.database }} |
| 60 | + run: | |
| 61 | + set -Eeu -o pipefail |
| 62 | + if [[ "$AWS_OUTCOME" != "success" ]]; then |
| 63 | + # No baseline file tells the report that the baseline could not be read. |
| 64 | + echo "::warning::Could not assume the read-only benchmarks role; reporting without a baseline." |
| 65 | + exit 0 |
| 66 | + fi |
| 67 | + curl -fsSL https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem \ |
| 68 | + -o "${RUNNER_TEMP}/rds-global-bundle.pem" |
| 69 | + DSN="postgresql://bench_ci_read@${RDS_BENCH_INSTANCE_ENDPOINT}:5432/${RDS_BENCH_DB_NAME}?sslmode=verify-full&sslrootcert=${RUNNER_TEMP}/rds-global-bundle.pem" |
| 70 | + if ! uv run --no-project scripts/fetch-benchmark-baseline.py "$PR_RECORDS" "$OUTPUT" \ |
| 71 | + --postgres "$DSN" --region "$AWS_REGION"; then |
| 72 | + echo "::warning::Could not read the baseline from the benchmarks database; reporting without a baseline." |
| 73 | + rm -f "$OUTPUT" |
| 74 | + fi |
0 commit comments