Skip to content

Commit c5af5df

Browse files
committed
avoid git ls-remote
1 parent 24b4341 commit c5af5df

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

.github/workflows/check-vertexai-responses.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,23 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
name: Check Vertex AI Mock Responses Version
15+
name: Check Vertex AI Responses
1616

1717
on: pull_request
1818

1919
jobs:
20-
check-responses-version:
20+
check-version:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- uses: actions/checkout@v4
2424
- name: Clone mock responses
2525
run: scripts/update_vertexai_responses.sh
2626
- name: Find cloned and latest versions
2727
run: |
28-
echo "current_tag=$(git describe --tags)" >> $GITHUB_ENV
29-
# Fetch the latest tag matching the major version from the golden files repository
30-
echo "latest_tag=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' \
31-
https://github.com/FirebaseExtended/vertexai-sdk-test-data.git | tail -n1 \
32-
| awk -F'/' '{print $NF}')" >> $GITHUB_ENV
28+
CLONED=$(git describe --tags)
29+
LATEST=$(git tag --sort=v:refname | tail -n1)
30+
echo "cloned_tag=$CLONED" >> $GITHUB_ENV
31+
echo "latest_tag=$LATEST" >> $GITHUB_ENV
3332
working-directory: packages/vertexai/test-utils/vertexai-sdk-test-data
3433
- name: Find comment from previous run if exists
3534
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e
@@ -38,7 +37,7 @@ jobs:
3837
issue-number: ${{github.event.number}}
3938
body-includes: Vertex AI Mock Responses Check
4039
- name: Comment on PR if newer version is available
41-
if: ${{env.current_tag != env.latest_tag && !steps.fc.outputs.comment-id}}
40+
if: ${{env.cloned_tag != env.latest_tag && !steps.fc.outputs.comment-id}}
4241
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
4342
with:
4443
issue-number: ${{github.event.number}}
@@ -49,7 +48,7 @@ jobs:
4948
[update_vertexai_responses.sh](https://github.com/firebase/firebase-js-sdk/blob/main/scripts/update_vertexai_responses.sh)
5049
should be updated to clone the latest version of the responses.
5150
- name: Delete comment when version gets updated
52-
if: ${{env.current_tag == env.latest_tag && steps.fc.outputs.comment-id}}
51+
if: ${{env.cloned_tag == env.latest_tag && steps.fc.outputs.comment-id}}
5352
uses: detomarco/delete-comment@850734dd44d8b15fef55b45252613b903ceb06f0
5453
with:
5554
comment-id: ${{ steps.fc.outputs.comment-id }}

scripts/update_vertexai_responses.sh

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@
1818
# clone of the shared repository of Vertex AI test data.
1919

2020
RESPONSES_VERSION='v1.*' # The major version of mock responses to use
21-
REPO="https://github.com/FirebaseExtended/vertexai-sdk-test-data.git"
22-
# Fetch the latest tag matching the major version from the golden files repository
23-
TAG=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' "$REPO" \
24-
| grep "$RESPONSES_VERSION" \
25-
| tail -n1 \
26-
| awk -F'/' '{print $NF}')
21+
REPO_NAME="vertexai-sdk-test-data"
22+
REPO_LINK="https://github.com/FirebaseExtended/$REPO_NAME.git"
2723

2824
cd "$(dirname "$0")/../packages/vertexai/test-utils" || exit
29-
rm -rf vertexai-sdk-test-data
30-
git clone --quiet --config advice.detachedHead=false --depth 1 --branch "$TAG" "$REPO"
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 --sort=v:refname | grep "$RESPONSES_VERSION" | tail -n1)
31+
if [ -z "$TAG" ]; then
32+
echo "Error: No matching tag found in $REPO_NAME"
33+
exit
34+
fi
35+
git checkout "$TAG" --quiet

0 commit comments

Comments
 (0)