-
Notifications
You must be signed in to change notification settings - Fork 511
fix: run E2E tests after i18n completes on release PRs #8111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
50ef83e
af69acd
821cf4a
7bc0161
187e364
4ae0773
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,10 +6,14 @@ on: | |
| branches: [main, master, core/*, desktop/*] | ||
| pull_request: | ||
| branches-ignore: | ||
| [wip/*, draft/*, temp/*, vue-nodes-migration, sno-playwright-*] | ||
| [wip/*, draft/*, temp/*, vue-nodes-migration, version-bump-*] | ||
| # Run after i18n workflow completes for version-bump PRs | ||
| workflow_run: | ||
| workflows: ['i18n: Update Core'] | ||
| types: [completed] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [architecture] medium Priority Issue: Potential race condition with workflow_run trigger
Comment on lines
+10
to
+13
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add branch filter and success check to The Add a workflow_run:
workflows: ['i18n: Update Core']
types: [completed]
+ branches:
+ - 'version-bump-*'Then add a conclusion check to the if: >
github.event_name != 'workflow_run' ||
github.event.workflow_run.conclusion == 'success'🤖 Prompt for AI Agents |
||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch || github.ref }} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [architecture] low Priority Issue: Concurrency group may cause unexpected cancellations across different event types |
||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
|
|
@@ -18,6 +22,8 @@ jobs: | |
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| ref: ${{ github.event.workflow_run.head_branch || github.ref }} | ||
| - name: Setup frontend | ||
| uses: ./.github/actions/setup-frontend | ||
| with: | ||
|
|
@@ -52,6 +58,8 @@ jobs: | |
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| ref: ${{ github.event.workflow_run.head_branch || github.ref }} | ||
| - name: Download built frontend | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
|
|
@@ -99,6 +107,8 @@ jobs: | |
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| ref: ${{ github.event.workflow_run.head_branch || github.ref }} | ||
| - name: Download built frontend | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
|
|
@@ -143,6 +153,8 @@ jobs: | |
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| ref: ${{ github.event.workflow_run.head_branch || github.ref }} | ||
|
|
||
| - name: Install pnpm | ||
| uses: pnpm/action-setup@v4 | ||
|
|
@@ -175,15 +187,43 @@ jobs: | |
| # when using pull_request event, we have permission to comment directly | ||
| # if its a forked repo, we need to use workflow_run event in a separate workflow (pr-playwright-deploy.yaml) | ||
|
|
||
| # Get PR info once for reuse by comment jobs | ||
| get-pr-info: | ||
| runs-on: ubuntu-latest | ||
Myestery marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if: | | ||
| (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false) || | ||
| (github.event_name == 'workflow_run') | ||
| outputs: | ||
| pr_number: ${{ steps.get-pr.outputs.number }} | ||
| branch: ${{ steps.get-pr.outputs.branch }} | ||
| steps: | ||
| - name: Get PR number | ||
| id: get-pr | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| PR_TARGET_REPO: ${{ github.repository }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| PR_BRANCH: ${{ github.head_ref || github.event.workflow_run.head_branch }} | ||
| run: | | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [quality] medium Priority Issue: Missing error handling for gh command failures |
||
| echo "branch=${PR_BRANCH}" >> $GITHUB_OUTPUT | ||
| if [ -n "$PR_NUMBER" ]; then | ||
| echo "number=${PR_NUMBER}" >> $GITHUB_OUTPUT | ||
| else | ||
| gh pr view --repo "${PR_TARGET_REPO}" "${PR_BRANCH}" \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [security] medium Priority Issue: Environment variables used in conditional logic without validation |
||
| --json 'number' --jq '"number=\(.number)"' >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
|
Comment on lines
+190
to
+215
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: Short answer: branch names (e.g. github.event.pull_request.head.ref / github.head_ref) and workflow_run triggers are untrusted inputs and have been used to inject shell/Actions expressions to execute arbitrary commands on runners. Treat them as attacker-controlled, avoid interpolating them directly into run: scripts, and apply the mitigations below. [1][2][3][7] What the risk looks like
Minimal, effective mitigations (apply all that make sense)
References (examples and guidance)
If you want, paste the specific workflow YAML you’re concerned about and I’ll point to exact lines that are vulnerable and show a fixed version. 🌐 Web query:
💡 Result: Quick summary — how GitHub Actions treats environment/context variables and what to do for security (trusted vs untrusted code): Key rules
Practical controls
References
If you want, I can produce a short example workflow pattern that separates trusted and untrusted jobs and demonstrates the safe handling above. 🏁 Script executed: # Check if there are other similar patterns in the workflow file that might indicate
# the project's current security practices
cd .github/workflows && cat ci-tests-e2e.yaml | grep -n "run:" | head -20Repository: Comfy-Org/ComfyUI_frontend Length of output: 681 Pass untrusted branch names safely to avoid shell injection.
Safer output write - name: Get branch name
id: get-branch
- run: echo "branch=${{ github.head_ref || github.event.workflow_run.head_branch }}" >> $GITHUB_OUTPUT
+ env:
+ BRANCH: ${{ github.head_ref || github.event.workflow_run.head_branch }}
+ run: |
+ printf 'branch=%s\n' "$BRANCH" >> "$GITHUB_OUTPUT"🧰 Tools🪛 actionlint (1.7.10)232-232: "github.head_ref" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/reference/security/secure-use#good-practices-for-mitigating-script-injection-attacks for more details (expression) 🤖 Prompt for AI Agents |
||
| # Post starting comment for non-forked PRs | ||
| comment-on-pr-start: | ||
| needs: get-pr-info | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false | ||
| permissions: | ||
| pull-requests: write | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| ref: ${{ github.event.workflow_run.head_branch || github.ref }} | ||
|
|
||
| - name: Get start time | ||
| id: start-time | ||
|
|
@@ -192,25 +232,30 @@ jobs: | |
| - name: Post starting comment | ||
| env: | ||
| GITHUB_TOKEN: ${{ github.token }} | ||
| PR_NUMBER: ${{ needs.get-pr-info.outputs.pr_number }} | ||
| BRANCH: ${{ needs.get-pr-info.outputs.branch }} | ||
| START_TIME: ${{ steps.start-time.outputs.time }} | ||
| run: | | ||
| chmod +x scripts/cicd/pr-playwright-deploy-and-comment.sh | ||
| ./scripts/cicd/pr-playwright-deploy-and-comment.sh \ | ||
| "${{ github.event.pull_request.number }}" \ | ||
| "${{ github.head_ref }}" \ | ||
| "$PR_NUMBER" \ | ||
| "$BRANCH" \ | ||
| "starting" \ | ||
| "${{ steps.start-time.outputs.time }}" | ||
| "$START_TIME" | ||
|
|
||
| # Deploy and comment for non-forked PRs only | ||
| deploy-and-comment: | ||
| needs: [playwright-tests, merge-reports] | ||
| needs: [playwright-tests, merge-reports, get-pr-info] | ||
| runs-on: ubuntu-latest | ||
| if: always() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false | ||
| if: always() | ||
|
Comment on lines
+248
to
+250
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n .github/workflows/ci-tests-e2e.yaml | head -300 | tail -100Repository: Comfy-Org/ComfyUI_frontend Length of output: 4286 🏁 Script executed: rg -n "deploy-and-comment|get-pr-info" .github/workflows/ci-tests-e2e.yaml -A 20Repository: Comfy-Org/ComfyUI_frontend Length of output: 3103 Guard deploy-and-comment job when PR info is missing (forks or non‑PR workflow_run). The ✅ Gate on a valid PR number deploy-and-comment:
- if: always()
+ if: ${{ always() && needs.get-pr-info.outputs.pr_number != '' }}🤖 Prompt for AI Agents |
||
| permissions: | ||
| pull-requests: write | ||
| contents: read | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| ref: ${{ github.event.workflow_run.head_branch || github.ref }} | ||
|
|
||
| - name: Download all playwright reports | ||
| uses: actions/download-artifact@v4 | ||
|
|
@@ -223,10 +268,12 @@ jobs: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
| GITHUB_TOKEN: ${{ github.token }} | ||
| GITHUB_SHA: ${{ github.event.pull_request.head.sha }} | ||
| GITHUB_SHA: ${{ github.event.pull_request.head.sha || github.event.workflow_run.head_sha }} | ||
| PR_NUMBER: ${{ needs.get-pr-info.outputs.pr_number }} | ||
| BRANCH: ${{ needs.get-pr-info.outputs.branch }} | ||
| run: | | ||
| bash ./scripts/cicd/pr-playwright-deploy-and-comment.sh \ | ||
| "${{ github.event.pull_request.number }}" \ | ||
| "${{ github.head_ref }}" \ | ||
| "$PR_NUMBER" \ | ||
| "$BRANCH" \ | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "completed" | ||
| #### END Deployment and commenting (non-forked PRs only) | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing branch filter on
workflow_runtrigger.The
workflow_runtrigger fires for any completion of the i18n workflow, not just version-bump PRs. This will cause E2E tests to run after every i18n update regardless of branch, which is not the intended behavior per the PR objectives.Add a condition to the
setupjob (or all jobs that should only run for version-bump PRs via workflow_run) to filter by branch:Alternatively, consider filtering earlier at the workflow level using a preliminary job that gates downstream jobs.
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#onworkflow_runbranchesbranches-ignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DrJKLGreat point! You can specify what branches the triggering workflow must run on using thebranchesorbranches-ignorefilters directly on theworkflow_runevent, which is much cleaner than adding job-level conditionals.The workflow can be updated to use native branch filtering:
This will ensure the E2E workflow only triggers via
workflow_runwhen the i18n workflow completes on version-bump branches, which is exactly the intended behavior described in the PR objectives.🧠 Learnings used