From f607d94cc0f8afcf282894d0a2a842c8fefc961b Mon Sep 17 00:00:00 2001 From: Vaibhav Jain Date: Tue, 21 Jul 2026 16:41:38 -0700 Subject: [PATCH 1/2] Add cohort_streamed_diff_enabled input to perf test workflow Adds a workflow_dispatch input that is forwarded to the sdk-tests repository_dispatch payload so a manual perf test run can enable AMPLITUDE_COHORT_STREAMED_DIFF_ENABLED (default false, added in #40) on the perf-test deployment. Push-triggered runs always send false. Co-Authored-By: Claude Fable 5 --- .github/workflows/perf-test.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/perf-test.yml b/.github/workflows/perf-test.yml index 1aee585..1315420 100644 --- a/.github/workflows/perf-test.yml +++ b/.github/workflows/perf-test.yml @@ -10,6 +10,11 @@ on: description: 'Git SHA to build (defaults to current HEAD)' required: false type: string + cohort_streamed_diff_enabled: + description: 'Set AMPLITUDE_COHORT_STREAMED_DIFF_ENABLED=true on the perf-test deployment' + required: false + default: false + type: boolean jobs: trigger-sdk-tests: @@ -29,6 +34,15 @@ jobs: echo "sha=${{ github.sha }}" >> $GITHUB_OUTPUT fi + - name: Get cohort streamed diff flag + id: get-flag + run: | + if [ "${{ github.event.inputs.cohort_streamed_diff_enabled }}" = "true" ]; then + echo "cohort_streamed_diff_enabled=true" >> $GITHUB_OUTPUT + else + echo "cohort_streamed_diff_enabled=false" >> $GITHUB_OUTPUT + fi + - name: Generate GitHub App token id: generate-token uses: peter-murray/workflow-application-token-action@8e1ba3bf1619726336414f1014e37f17fbadf1db # v2 @@ -49,7 +63,8 @@ jobs: "ref": "${{ github.ref }}", "repo_url": "${{ github.repositoryUrl }}", "triggered_by": "${{ github.actor }}", - "workflow_run_id": "${{ github.run_id }}" + "workflow_run_id": "${{ github.run_id }}", + "cohort_streamed_diff_enabled": "${{ steps.get-flag.outputs.cohort_streamed_diff_enabled }}" } }' @@ -60,5 +75,6 @@ jobs: echo "- **SHA**: ${{ steps.get-sha.outputs.sha }}" >> $GITHUB_STEP_SUMMARY echo "- **Ref**: ${{ github.ref }}" >> $GITHUB_STEP_SUMMARY echo "- **Triggered by**: ${{ github.actor }}" >> $GITHUB_STEP_SUMMARY + echo "- **Cohort streamed diff enabled**: ${{ steps.get-flag.outputs.cohort_streamed_diff_enabled }}" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "Check the [sdk-tests workflow runs](https://github.com/amplitude/sdk-tests/actions) for build progress." >> $GITHUB_STEP_SUMMARY From 86010d66ae61e45d36c9751713a205a62aaf1e4f Mon Sep 17 00:00:00 2001 From: Vaibhav Jain Date: Wed, 22 Jul 2026 10:04:49 -0700 Subject: [PATCH 2/2] Pass workflow inputs to run scripts via env to fix semgrep shell-injection findings Co-Authored-By: Claude Fable 5 --- .github/workflows/perf-test.yml | 82 ++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 27 deletions(-) diff --git a/.github/workflows/perf-test.yml b/.github/workflows/perf-test.yml index 1315420..4b223a4 100644 --- a/.github/workflows/perf-test.yml +++ b/.github/workflows/perf-test.yml @@ -27,20 +27,25 @@ jobs: - name: Get commit SHA id: get-sha + env: + INPUT_SHA: ${{ github.event.inputs.sha }} + HEAD_SHA: ${{ github.sha }} run: | - if [ -n "${{ github.event.inputs.sha }}" ]; then - echo "sha=${{ github.event.inputs.sha }}" >> $GITHUB_OUTPUT + if [ -n "$INPUT_SHA" ]; then + echo "sha=$INPUT_SHA" >> "$GITHUB_OUTPUT" else - echo "sha=${{ github.sha }}" >> $GITHUB_OUTPUT + echo "sha=$HEAD_SHA" >> "$GITHUB_OUTPUT" fi - name: Get cohort streamed diff flag id: get-flag + env: + COHORT_STREAMED_DIFF_ENABLED: ${{ github.event.inputs.cohort_streamed_diff_enabled }} run: | - if [ "${{ github.event.inputs.cohort_streamed_diff_enabled }}" = "true" ]; then - echo "cohort_streamed_diff_enabled=true" >> $GITHUB_OUTPUT + if [ "$COHORT_STREAMED_DIFF_ENABLED" = "true" ]; then + echo "cohort_streamed_diff_enabled=true" >> "$GITHUB_OUTPUT" else - echo "cohort_streamed_diff_enabled=false" >> $GITHUB_OUTPUT + echo "cohort_streamed_diff_enabled=false" >> "$GITHUB_OUTPUT" fi - name: Generate GitHub App token @@ -51,30 +56,53 @@ jobs: application_private_key: ${{ secrets.EVALUATION_PROXY_INTEGRATION_KEY }} - name: Trigger sdk-tests workflow + env: + GH_TOKEN: ${{ steps.generate-token.outputs.token }} + SHA: ${{ steps.get-sha.outputs.sha }} + REF: ${{ github.ref }} + REPO_URL: ${{ github.repositoryUrl }} + TRIGGERED_BY: ${{ github.actor }} + WORKFLOW_RUN_ID: ${{ github.run_id }} + COHORT_STREAMED_DIFF_ENABLED: ${{ steps.get-flag.outputs.cohort_streamed_diff_enabled }} run: | - curl -X POST \ + jq -n \ + --arg sha "$SHA" \ + --arg ref "$REF" \ + --arg repo_url "$REPO_URL" \ + --arg triggered_by "$TRIGGERED_BY" \ + --arg workflow_run_id "$WORKFLOW_RUN_ID" \ + --arg cohort_streamed_diff_enabled "$COHORT_STREAMED_DIFF_ENABLED" \ + '{ + event_type: "evaluation-proxy-tests", + client_payload: { + sha: $sha, + ref: $ref, + repo_url: $repo_url, + triggered_by: $triggered_by, + workflow_run_id: $workflow_run_id, + cohort_streamed_diff_enabled: $cohort_streamed_diff_enabled + } + }' \ + | curl -X POST \ -H "Accept: application/vnd.github.v3+json" \ - -H "Authorization: token ${{ steps.generate-token.outputs.token }}" \ + -H "Authorization: token ${GH_TOKEN}" \ https://api.github.com/repos/amplitude/sdk-tests/dispatches \ - -d '{ - "event_type": "evaluation-proxy-tests", - "client_payload": { - "sha": "${{ steps.get-sha.outputs.sha }}", - "ref": "${{ github.ref }}", - "repo_url": "${{ github.repositoryUrl }}", - "triggered_by": "${{ github.actor }}", - "workflow_run_id": "${{ github.run_id }}", - "cohort_streamed_diff_enabled": "${{ steps.get-flag.outputs.cohort_streamed_diff_enabled }}" - } - }' + -d @- - name: Output summary + env: + SHA: ${{ steps.get-sha.outputs.sha }} + REF: ${{ github.ref }} + TRIGGERED_BY: ${{ github.actor }} + COHORT_STREAMED_DIFF_ENABLED: ${{ steps.get-flag.outputs.cohort_streamed_diff_enabled }} run: | - echo "## Triggered SDK Tests" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "- **SHA**: ${{ steps.get-sha.outputs.sha }}" >> $GITHUB_STEP_SUMMARY - echo "- **Ref**: ${{ github.ref }}" >> $GITHUB_STEP_SUMMARY - echo "- **Triggered by**: ${{ github.actor }}" >> $GITHUB_STEP_SUMMARY - echo "- **Cohort streamed diff enabled**: ${{ steps.get-flag.outputs.cohort_streamed_diff_enabled }}" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "Check the [sdk-tests workflow runs](https://github.com/amplitude/sdk-tests/actions) for build progress." >> $GITHUB_STEP_SUMMARY + { + echo "## Triggered SDK Tests" + echo "" + echo "- **SHA**: $SHA" + echo "- **Ref**: $REF" + echo "- **Triggered by**: $TRIGGERED_BY" + echo "- **Cohort streamed diff enabled**: $COHORT_STREAMED_DIFF_ENABLED" + echo "" + echo "Check the [sdk-tests workflow runs](https://github.com/amplitude/sdk-tests/actions) for build progress." + } >> "$GITHUB_STEP_SUMMARY"