Repository navigation
workflow steps separated to go or python - #16561
Conversation
📝 WalkthroughWalkthroughAdds a new GitHub Actions workflow (sep-tests.yml) defining CI triggers, a preflight job for change detection and test-level determination, and two parallel jobs running full test suites (Go, SDK, REST API, CLI) against Infinity and Elasticsearch document engines with coverage and port-conflict handling. ChangesSep-tests CI workflow
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant GitHubActions
participant Preflight
participant InfinityJob
participant ElasticsearchJob
participant Docker
GitHubActions->>Preflight: trigger on push/PR/schedule
Preflight->>Preflight: detect changes, determine test level
Preflight-->>InfinityJob: output flags and test level
Preflight-->>ElasticsearchJob: output flags and test level
par Infinity suite
InfinityJob->>Docker: build image, start compose stack
InfinityJob->>InfinityJob: run SDK, REST API, CLI tests
InfinityJob->>Docker: collect logs, cleanup
and Elasticsearch suite
ElasticsearchJob->>Docker: build image, start compose stack
ElasticsearchJob->>ElasticsearchJob: run SDK, REST API, CLI tests
ElasticsearchJob->>Docker: collect logs, cleanup
end
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
.github/workflows/sep-tests.yml (2)
62-62: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win
gh auth login --with-tokenpersists credentials to the runner's home directory.Using
gh auth loginwrites the token into~/.config/gh/hosts.ymlon the self-hosted runner rather than scoping it to the step. Prefer exportingGH_TOKEN/GITHUB_TOKENas an env var for theghinvocations in this step, which avoids leaving credentials on disk after the job completes.🔧 Suggested fix
- gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}" - PR_NUMBER=$(gh pr list --search ${HEAD} --state merged --json number --jq .[0].number) + PR_NUMBER=$(gh pr list --search ${HEAD} --state merged --json number --jq .[0].number)And add at the step level:
env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/sep-tests.yml at line 62, The auth setup in the workflow step is persisting credentials to disk via gh auth login; update the step that runs gh commands to use GH_TOKEN or GITHUB_TOKEN from the environment instead of logging in with --with-token. Locate the affected workflow step by the gh auth login usage in sep-tests.yml and remove the login command, then add a step-level env block so gh picks up the token only for that step.
160-193: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win
git diff HEAD~1 HEADcan fail on the first commit of a branch/shallow history edge case.For non-PR, non-schedule events, change detection uses
git diff --name-only HEAD~1 HEAD(Line 174). If the triggering commit has no parent reachable in this checkout (e.g., first commit after a force-push/rebase, or squash-merge edge cases), this fails and the whole preflight job errors instead of gracefully falling back to running both Go and Python tests as done in the "no changes detected" branch (Lines 185-188).🔧 Suggested fix
- CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD) + CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || true)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/sep-tests.yml around lines 160 - 193, The change-detection step in detect_changes can break on non-PR, non-schedule runs when git diff HEAD~1 HEAD has no valid parent, causing the job to fail instead of falling back cleanly. Update the shell logic in the “Detect changed file types” step to handle this edge case by checking whether the previous commit is available or by wrapping the diff command in a safe fallback that treats the failure as “unknown changes” and sets both has_go and has_python to true, consistent with the existing no-changes fallback.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/sep-tests.yml:
- Around line 49-54: The checkout step in the workflow is persisting credentials
on a self-hosted runner, which can leave the GITHUB_TOKEN available to later
jobs. Update the actions/checkout@v6 usage in the “Check out code” step to
explicitly disable credential persistence by setting persist-credentials to
false. Keep the existing ref, fetch-depth, and fetch-tags settings unchanged.
- Around line 1-3: The workflow’s top-level permissions currently remove the
token scopes needed by the duplicate-check logic, so update the sep-tests
workflow permissions to include the scopes used by the push-only duplicate
check. Specifically, adjust the workflow permissions near the sep-tests header
so the jobs using gh pr list and gh run cancel can run with pull-requests: read
and actions: write while keeping contents: read intact.
---
Nitpick comments:
In @.github/workflows/sep-tests.yml:
- Line 62: The auth setup in the workflow step is persisting credentials to disk
via gh auth login; update the step that runs gh commands to use GH_TOKEN or
GITHUB_TOKEN from the environment instead of logging in with --with-token.
Locate the affected workflow step by the gh auth login usage in sep-tests.yml
and remove the login command, then add a step-level env block so gh picks up the
token only for that step.
- Around line 160-193: The change-detection step in detect_changes can break on
non-PR, non-schedule runs when git diff HEAD~1 HEAD has no valid parent, causing
the job to fail instead of falling back cleanly. Update the shell logic in the
“Detect changed file types” step to handle this edge case by checking whether
the previous commit is available or by wrapping the diff command in a safe
fallback that treats the failure as “unknown changes” and sets both has_go and
has_python to true, consistent with the existing no-changes fallback.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7a6bf674-b93b-4c2e-aa55-77a9626291e4
📒 Files selected for processing (1)
.github/workflows/sep-tests.yml
| name: sep-tests | ||
| permissions: | ||
| contents: read |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the workflow and the relevant step that uses gh.
git ls-files .github/workflows/sep-tests.yml
wc -l .github/workflows/sep-tests.yml
cat -n .github/workflows/sep-tests.yml | sed -n '1,220p'Repository: infiniflow/ragflow
Length of output: 11275
🌐 Web query:
GitHub Actions permissions gh pr list pull-requests: read gh run cancel actions: write GITHUB_TOKEN permissions workflow
💡 Result:
To use the GitHub CLI (gh) within a GitHub Actions workflow with the GITHUB_TOKEN, you must configure the appropriate permissions. Based on the underlying REST API requirements for these commands, the following settings are required: 1. gh pr list: This command requires pull-requests: read permissions [1]. Depending on the specific data being retrieved, it may also require issues: read permissions if the CLI interacts with issue-related metadata for pull requests [1]. 2. gh run cancel: This command requires actions: write permissions [2][3]. This permission is necessary to perform the POST request to the cancel workflow run endpoint [2][4][3]. To implement these in your workflow, use the permissions key within your job or workflow configuration [5][6]. It is a security best practice to follow the principle of least privilege by setting default permissions to none or read-only and explicitly granting only what is required [7][8]. Example Configuration: permissions: pull-requests: read actions: write jobs: my-job: runs-on: ubuntu-latest steps: - name: List PRs run: gh pr list - name: Cancel run run: gh run cancel Note: If your workflow is triggered by a pull request from a forked repository, the GITHUB_TOKEN permissions may be restricted to read-only regardless of your configuration, unless the repository setting 'Send write tokens to workflows from pull requests' is enabled [9][6]. If you require write access in such scenarios without changing repository-wide settings, you may need to use a personal access token (PAT) or a GitHub App installation access token instead [9].
Citations:
- 1:
gh pr listdepends on the read permission for Issues cli/cli#5986 - 2: https://docs.github.com/en/rest/authentication/permissions-required-for-fine-grained-personal-access-tokens?apiVersion=2022-11-28
- 3: https://docs.github.com/en/rest/authentication/permissions-required-for-github-apps
- 4: https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2026-03-10
- 5: https://docs.github.com/actions/reference/authentication-in-a-workflow
- 6: https://docs.github.com/en/[email protected]/actions/reference/authentication-in-a-workflow
- 7: https://github.com/github/docs/blob/main/content/actions/tutorials/authenticate-with-github_token.md
- 8: https://secure-pipelines.com/ci-cd-security/github-actions-security-cheat-sheet/
- 9: https://docs.github.com/en/actions/concepts/security/github_token
🌐 Web query:
site:docs.github.com GitHub Actions workflow permissions pull-requests read actions write gh run cancel gh pr list
💡 Result:
To use GitHub CLI commands within a GitHub Actions workflow, the GITHUB_TOKEN must be configured with specific permissions corresponding to the actions being performed [1][2]. Permissions are defined in the workflow YAML file using the permissions key. If this key is omitted, GitHub defaults to permissive access (or the repository's configured default), but explicitly defining permissions follows the principle of least privilege: any permission not explicitly set to read or write defaults to none [1][3]. Required Permissions: 1. gh run cancel To cancel a workflow run using the GitHub CLI, the GITHUB_TOKEN requires actions: write permission [1][4]. This is because canceling a run modifies the state of the workflow [5][4]. 2. gh pr list To list pull requests using the GitHub CLI, the GITHUB_TOKEN requires pull-requests: read permission [1][6]. This allows the workflow to view pull request data without needing to modify it [1]. Example Configuration: To perform both actions in a single job, your workflow configuration should include: permissions: actions: write pull-requests: read If your workflow requires additional operations, ensure you include the necessary permissions for those as well, as specifying any permission automatically sets all unspecified permissions to none [1]. Note that write access implicitly includes read access for the same scope [1].
Citations:
- 1: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax
- 2: https://docs.github.com/actions/using-workflows/using-github-cli-in-workflows
- 3: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository
- 4: https://docs.github.com/en/rest/authentication/permissions-required-for-fine-grained-personal-access-tokens?apiVersion=2022-11-28
- 5: https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2026-03-10
- 6: https://docs.github.com/en/enterprise-cloud@latest/actions/reference/workflows-and-actions/workflow-syntax
Add the missing GITHUB_TOKEN scopes for the duplicate-check step
permissions: contents: read clears every other scope, so the gh pr list and gh run cancel calls in the push-only duplicate check will 403 unless this workflow also grants pull-requests: read and actions: write. This breaks the preflight job on push runs.
🔧 Suggested fix
permissions:
contents: read
+ actions: write
+ pull-requests: read📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| name: sep-tests | |
| permissions: | |
| contents: read | |
| name: sep-tests | |
| permissions: | |
| contents: read | |
| actions: write | |
| pull-requests: read |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/sep-tests.yml around lines 1 - 3, The workflow’s top-level
permissions currently remove the token scopes needed by the duplicate-check
logic, so update the sep-tests workflow permissions to include the scopes used
by the push-only duplicate check. Specifically, adjust the workflow permissions
near the sep-tests header so the jobs using gh pr list and gh run cancel can run
with pull-requests: read and actions: write while keeping contents: read intact.
| - name: Check out code | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.sha }} | ||
| fetch-depth: 0 | ||
| fetch-tags: true |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Missing persist-credentials: false on self-hosted runner checkout.
Static analysis flags credential persistence (artipacked). On a self-hosted runner where the workspace/.git config can outlive the job, a persisted GITHUB_TOKEN in the git credential store increases the risk of token reuse by subsequent code running on the same host.
🔒 Suggested fix
- name: Check out code
uses: actions/checkout@v6
with:
ref: ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.sha }}
fetch-depth: 0
fetch-tags: true
+ persist-credentials: false📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - name: Check out code | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.sha }} | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Check out code | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.sha }} | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| persist-credentials: false |
🧰 Tools
🪛 zizmor (1.26.1)
[warning] 49-54: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/sep-tests.yml around lines 49 - 54, The checkout step in
the workflow is persisting credentials on a self-hosted runner, which can leave
the GITHUB_TOKEN available to later jobs. Update the actions/checkout@v6 usage
in the “Check out code” step to explicitly disable credential persistence by
setting persist-credentials to false. Keep the existing ref, fetch-depth, and
fetch-tags settings unchanged.
Source: Linters/SAST tools
add new workflow yml, steps separated to go or python
add new workflow yml, steps separated to go or python
add new workflow yml, steps separated to go or python