Skip to content

Commit a41af7d

Browse files
authored
VertexAI: add support for mock responses versioning system (#6103)
1 parent 4495cc9 commit a41af7d

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Check Vertex AI Responses
2+
3+
on: pull_request
4+
5+
jobs:
6+
check-version:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- name: Clone mock responses
11+
run: firebase-vertexai/update_responses.sh
12+
- name: Find cloned and latest versions
13+
run: |
14+
CLONED=$(git describe --tags)
15+
LATEST=$(git tag --sort=v:refname | tail -n1)
16+
echo "cloned_tag=$CLONED" >> $GITHUB_ENV
17+
echo "latest_tag=$LATEST" >> $GITHUB_ENV
18+
working-directory: firebase-vertexai/src/test/resources/vertexai-sdk-test-data
19+
- name: Find comment from previous run if exists
20+
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e
21+
id: fc
22+
with:
23+
issue-number: ${{github.event.number}}
24+
body-includes: Vertex AI Mock Responses Check
25+
- name: Comment on PR if newer version is available
26+
if: ${{env.cloned_tag != env.latest_tag && !steps.fc.outputs.comment-id}}
27+
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
28+
with:
29+
issue-number: ${{github.event.number}}
30+
body: >
31+
### Vertex AI Mock Responses Check :warning:
32+
33+
A newer major version of the mock responses for Vertex AI unit tests is available.
34+
[update_responses.sh](https://github.com/firebase/firebase-android-sdk/blob/main/firebase-vertexai/update_responses.sh)
35+
should be updated to clone the latest version of the responses: `${{env.latest_tag}}`
36+
- name: Delete comment when version gets updated
37+
if: ${{env.cloned_tag == env.latest_tag && steps.fc.outputs.comment-id}}
38+
uses: detomarco/delete-comment@850734dd44d8b15fef55b45252613b903ceb06f0
39+
with:
40+
comment-id: ${{ steps.fc.outputs.comment-id }}

firebase-vertexai/update_responses.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@
1717
# This script replaces mock response files for Vertex AI unit tests with a fresh
1818
# clone of the shared repository of Vertex AI test data.
1919

20+
RESPONSES_VERSION='v1.*' # The major version of mock responses to use
21+
REPO_NAME="vertexai-sdk-test-data"
22+
REPO_LINK="https://github.com/FirebaseExtended/$REPO_NAME.git"
23+
2024
cd "$(dirname "$0")/src/test/resources" || exit
21-
rm -rf vertexai-sdk-test-data
22-
git clone --depth 1 https://github.com/FirebaseExtended/vertexai-sdk-test-data.git
25+
rm -rf "$REPO_NAME"
26+
git clone "$REPO_LINK" --quiet || exit
27+
cd "$REPO_NAME" || exit
28+
29+
# Find and checkout latest tag matching major version
30+
TAG=$(git tag -l "$RESPONSES_VERSION" --sort=v:refname | tail -n1)
31+
if [ -z "$TAG" ]; then
32+
echo "Error: No tag matching '$RESPONSES_VERSION' found in $REPO_NAME"
33+
exit
34+
fi
35+
git checkout "$TAG" --quiet

0 commit comments

Comments
 (0)