@@ -41,22 +41,47 @@ jobs:
41
41
git diff --name-only -r HEAD^1 HEAD | while read line; do printf "%s\n" "$line"; done >> $GITHUB_OUTPUT
42
42
echo "EOF" >> $GITHUB_OUTPUT
43
43
44
+ prepare-matrix :
45
+ needs : get-changed-files
46
+ runs-on : ubuntu-latest
47
+ env :
48
+ PACKAGES : " anthropic,azure-openai,cloudflare,cohere,core,community,exa,google-common,google-gauth,google-genai,google-vertexai,google-vertexai-web,google-webauth,groq,mistralai,mongo,nomic,openai,pinecone,qdrant,redis,textsplitters,weaviate,yandex"
49
+ outputs :
50
+ matrix : ${{ steps.set-matrix.outputs.matrix }}
51
+ steps :
52
+ - id : set-matrix
53
+ run : |
54
+ changed_files="${{ needs.get-changed-files.outputs.changed_files }}"
55
+ echo "Changed files: $changed_files"
56
+ # Convert PACKAGES environment variable into an array
57
+ IFS=',' read -r -a packages <<< "$PACKAGES"
58
+ echo "Packages: ${packages[*]}"
59
+ matrix="{\"include\": ["
60
+ first_entry=true
61
+ for package in "${packages[@]}"; do
62
+ echo "Checking package: $package"
63
+ if echo "$changed_files" | grep -q "$package"; then
64
+ echo "Package $package found in changed files."
65
+ if [ "$first_entry" = true ]; then
66
+ matrix="$matrix{\"os\": \"ubuntu-latest\", \"node-version\": \"18\", \"package\": \"$package\"},{\"os\": \"ubuntu-latest\", \"node-version\": \"20\", \"package\": \"$package\"}"
67
+ first_entry=false
68
+ else
69
+ matrix="$matrix, {\"os\": \"ubuntu-latest\", \"node-version\": \"18\", \"package\": \"$package\"},{\"os\": \"ubuntu-latest\", \"node-version\": \"20\", \"package\": \"$package\"}"
70
+ fi
71
+ fi
72
+ done
73
+ matrix="$matrix]}"
74
+ echo "Matrix: $matrix"
75
+ echo "matrix=$matrix" >> $GITHUB_OUTPUT
76
+
44
77
unit-tests :
45
78
name : Unit Tests
46
- needs : get-changed-files
79
+ needs : prepare-matrix
80
+ # Only run this job if there are packages to test
81
+ if : ${{ fromJson(needs.prepare-matrix.outputs.matrix).include.length != 0 }}
82
+ runs-on : ubuntu-latest
47
83
strategy :
48
- matrix :
49
- os : [ubuntu-latest]
50
- node-version : [18.x, 20.x]
51
- package : [anthropic, azure-openai, cloudflare, cohere, community, exa, google-common, google-gauth, google-genai, google-vertexai, google-vertexai-web, google-webauth, groq, mistralai, mongo, nomic, openai, pinecone, qdrant, redis, textsplitters, weaviate, yandex]
52
- # See Node.js release schedule at https://nodejs.org/en/about/releases/
53
- # include:
54
- # - os: windows-latest
55
- # node-version: 20.x
56
- # - os: macos-latest
57
- # node-version: 20.x
58
- runs-on : ${{ matrix.os }}
59
- if : contains(needs.get-changed-files.outputs.changed_files, 'langchain-core/') || contains(needs.get-changed-files.outputs.changed_files, 'libs/langchain-${{ matrix.package }}/')
84
+ matrix : ${{ fromJson(needs.prepare-matrix.outputs.matrix) }}
60
85
env :
61
86
PUPPETEER_SKIP_DOWNLOAD : " true"
62
87
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD : " true"
0 commit comments