Skip to content
Merged
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
88 changes: 66 additions & 22 deletions .github/workflows/perf-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -22,11 +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 [ "$COHORT_STREAMED_DIFF_ENABLED" = "true" ]; then
echo "cohort_streamed_diff_enabled=true" >> "$GITHUB_OUTPUT"
else
echo "cohort_streamed_diff_enabled=false" >> "$GITHUB_OUTPUT"
fi

Comment on lines +44 to +50

@semgrep-amplitude semgrep-amplitude Bot Jul 22, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using variable interpolation ${{...}} with github context data in a run: step could allow an attacker to inject their own code into the runner. This would allow them to steal secrets and code. github context data can have arbitrary user input and should be treated as untrusted. Instead, use an intermediate environment variable with env: to store the data and use the environment variable in the run: script. Be sure to use double-quotes the environment variable, like this: "$ENVVAR".

🎉 Fixed in commit 86010d6 🎉

- name: Generate GitHub App token
Expand All @@ -37,28 +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 }}"
}
}'
-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 "" >> $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"
Loading