Skip to content

Commit 5984a6d

Browse files
ci[patch]: fix unit-tests-integrations by implementing dynamic matrix strategy. (#5768)
* patch matrix strategy- run unit test cases of only changed * add clarification for job skip * add firestore int * check workflow * Revert "Google firestore vectorstore" --------- Co-authored-by: Brace Sproul <braceasproul@gmail.com>
1 parent e7c98c0 commit 5984a6d

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

.github/workflows/unit-tests-integrations.yml

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,47 @@ jobs:
4141
git diff --name-only -r HEAD^1 HEAD | while read line; do printf "%s\n" "$line"; done >> $GITHUB_OUTPUT
4242
echo "EOF" >> $GITHUB_OUTPUT
4343
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+
4477
unit-tests:
4578
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
4783
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) }}
6085
env:
6186
PUPPETEER_SKIP_DOWNLOAD: "true"
6287
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true"

0 commit comments

Comments
 (0)