| 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 |