Changesets · Branches · Tags · Compare
| Changeset | 9875eaa07e45c8d5059aeac7e9a4e52a6957240fc7d31ddfc4d74eb5cfb7f3bb |
|---|---|
| Author | Nate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-08-29 15:21 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-08-29 15:21 -07:00 |
| Parents | 86e71fea71da |
3 files changed
added .github/actions/check-llm-changes/action.yml +55 −0
| @@ -0,0 +1,55 @@ | ||
| 1 | +name: "Check LLM Changes" | |
| 2 | +description: "Check if LLM-related files have changed and set environment variable to control API tests" | |
| 3 | +outputs: | |
| 4 | + llm_changed: | |
| 5 | + description: "Whether LLM-related files have changed" | |
| 6 | + value: ${{ steps.check-changes.outputs.llm_changed }} | |
| 7 | + ignore_api_tests: | |
| 8 | + description: "Whether to ignore API tests based on file changes and other conditions" | |
| 9 | + value: ${{ steps.check-changes.outputs.ignore_api_tests }} | |
| 10 | +inputs: | |
| 11 | + is_fork: | |
| 12 | + description: "Whether this is a fork PR" | |
| 13 | + required: false | |
| 14 | + default: "false" | |
| 15 | + is_dependabot: | |
| 16 | + description: "Whether this is a dependabot PR" | |
| 17 | + required: false | |
| 18 | + default: "false" | |
| 19 | + | |
| 20 | +runs: | |
| 21 | + using: "composite" | |
| 22 | + steps: | |
| 23 | + - name: Check if LLM-related files changed | |
| 24 | + id: check-changes | |
| 25 | + shell: bash | |
| 26 | + run: | | |
| 27 | + if [ "${{ github.event_name }}" = "push" ]; then | |
| 28 | + # For push events, compare against the previous commit | |
| 29 | + CHANGED_FILES=$(git diff --name-only HEAD~1...HEAD) | |
| 30 | + else | |
| 31 | + # For PR events, compare against the base branch | |
| 32 | + git fetch origin ${{ github.event.pull_request.base.ref }} | |
| 33 | + CHANGED_FILES=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD) | |
| 34 | + fi | |
| 35 | + | |
| 36 | + echo "Changed files:" | |
| 37 | + echo "$CHANGED_FILES" | |
| 38 | + | |
| 39 | + # Check if any LLM-related files were changed | |
| 40 | + LLM_CHANGED=false | |
| 41 | + if echo "$CHANGED_FILES" | grep -E "(^core/llm/|^core/index\.ts|^core/package\.json|^core/jest\.config\.js|^packages/.*/(.*llm.*|.*openai.*|.*anthropic.*)|\.github/workflows/pr-checks\.yaml|\.github/actions/check-llm-changes/)" > /dev/null; then | |
| 42 | + LLM_CHANGED=true | |
| 43 | + fi | |
| 44 | + | |
| 45 | + echo "LLM files changed: $LLM_CHANGED" | |
| 46 | + echo "llm_changed=$LLM_CHANGED" >> $GITHUB_OUTPUT | |
| 47 | + | |
| 48 | + # Determine whether to ignore API tests | |
| 49 | + IGNORE_API_TESTS=false | |
| 50 | + if [ "${{ inputs.is_fork }}" = "true" ] || [ "${{ inputs.is_dependabot }}" = "true" ] || [ "$LLM_CHANGED" = "false" ]; then | |
| 51 | + IGNORE_API_TESTS=true | |
| 52 | + fi | |
| 53 | + | |
| 54 | + echo "Ignore API tests: $IGNORE_API_TESTS" | |
| 55 | + echo "ignore_api_tests=$IGNORE_API_TESTS" >> $GITHUB_OUTPUT |
modified .github/workflows/pr-checks.yaml +20 −2
| @@ -44,6 +44,8 @@ | ||
| 44 | 44 | runs-on: ubuntu-latest |
| 45 | 45 | steps: |
| 46 | 46 | - uses: actions/checkout@v5 |
| 47 | + with: | |
| 48 | + fetch-depth: 0 # Needed for git diff to work | |
| 47 | 49 | - name: Setup packages |
| 48 | 50 | uses: ./.github/actions/setup-packages |
| 49 | 51 | - name: Setup core component |
| @@ -52,6 +54,13 @@ | ||
| 52 | 54 | component: core |
| 53 | 55 | include-root: true |
| 54 | 56 | |
| 57 | + - name: Check if LLM-related files changed | |
| 58 | + id: llm-changes | |
| 59 | + uses: ./.github/actions/check-llm-changes | |
| 60 | + with: | |
| 61 | + is_fork: ${{ github.event.pull_request.head.repo.fork == true }} | |
| 62 | + is_dependabot: ${{ github.actor == 'dependabot[bot]' }} | |
| 63 | + | |
| 55 | 64 | - name: Type check and lint |
| 56 | 65 | run: | |
| 57 | 66 | cd core |
| @@ -66,7 +75,7 @@ | ||
| 66 | 75 | npm test |
| 67 | 76 | npm run vitest |
| 68 | 77 | env: |
| 69 | - IGNORE_API_KEY_TESTS: ${{ github.event.pull_request.head.repo.fork == true || github.actor == 'dependabot[bot]' }} | |
| 78 | + IGNORE_API_KEY_TESTS: ${{ steps.llm-changes.outputs.ignore_api_tests }} | |
| 70 | 79 | OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
| 71 | 80 | ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} |
| 72 | 81 | GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} |
| @@ -180,16 +189,25 @@ | ||
| 180 | 189 | package: ${{ fromJson(needs.get-packages-matrix.outputs.packages) }} |
| 181 | 190 | steps: |
| 182 | 191 | - uses: actions/checkout@v5 |
| 192 | + with: | |
| 193 | + fetch-depth: 0 # Needed for git diff to work | |
| 183 | 194 | - name: Setup packages |
| 184 | 195 | uses: ./.github/actions/setup-packages |
| 185 | 196 | |
| 197 | + - name: Check if LLM-related files changed | |
| 198 | + id: llm-changes | |
| 199 | + uses: ./.github/actions/check-llm-changes | |
| 200 | + with: | |
| 201 | + is_fork: ${{ github.event.pull_request.head.repo.fork == true }} | |
| 202 | + is_dependabot: ${{ github.actor == 'dependabot[bot]' }} | |
| 203 | + | |
| 186 | 204 | - name: Test and check ${{ matrix.package }} |
| 187 | 205 | run: | |
| 188 | 206 | cd packages/${{ matrix.package }} |
| 189 | 207 | npm ci |
| 190 | 208 | npm test |
| 191 | 209 | env: |
| 192 | - IGNORE_API_KEY_TESTS: ${{ github.event.pull_request.head.repo.fork == true || github.actor == 'dependabot[bot]' }} | |
| 210 | + IGNORE_API_KEY_TESTS: ${{ steps.llm-changes.outputs.ignore_api_tests }} | |
| 193 | 211 | OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
| 194 | 212 | ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} |
| 195 | 213 | GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} |
modified core/indexing/docs/crawlers/DocsCrawler.test.ts +21 −3
| @@ -155,9 +155,27 @@ | ||
| 155 | 155 | test( |
| 156 | 156 | `Default crawler common site: ${url}`, |
| 157 | 157 | async () => { |
| 158 | - const { pages, crawler } = await runCrawl(url); | |
| 159 | - expect(pages.length).toBeGreaterThanOrEqual(1); | |
| 160 | - expect(crawler).toEqual("default"); | |
| 158 | + // Retry logic to handle flaky network requests to TRIAL_PROXY_URL | |
| 159 | + let lastError; | |
| 160 | + const maxRetries = 3; | |
| 161 | + | |
| 162 | + for (let attempt = 1; attempt <= maxRetries; attempt++) { | |
| 163 | + try { | |
| 164 | + const { pages, crawler } = await runCrawl(url); | |
| 165 | + expect(pages.length).toBeGreaterThanOrEqual(1); | |
| 166 | + expect(crawler).toEqual("default"); | |
| 167 | + return; // Test passed, exit retry loop | |
| 168 | + } catch (error) { | |
| 169 | + lastError = error; | |
| 170 | + if (attempt === maxRetries) { | |
| 171 | + throw error; // Final attempt failed, throw the error | |
| 172 | + } | |
| 173 | + // Wait before retrying (exponential backoff) | |
| 174 | + await new Promise((resolve) => | |
| 175 | + setTimeout(resolve, 1000 * attempt), | |
| 176 | + ); | |
| 177 | + } | |
| 178 | + } | |
| 161 | 179 | }, |
| 162 | 180 | TIMEOUT_MS, |
| 163 | 181 | ); |