From 084725ee0560e4a9726299f1aa76f430314d52bd Mon Sep 17 00:00:00 2001 From: Twisha Bansal <58483338+twishabansal@users.noreply.github.com> Date: Wed, 27 Nov 2024 22:59:24 +0530 Subject: [PATCH] ci(llamaindex): Added auto lint and integration test config (#72) This PR adds CI workflows for linting and integration tests to the Llamaindex SDK. Linting is failing due to type checking errors in the SDK (to be fixed separately). Integration tests are failing since there are no existing tests. --- .../workflows/lint-llamaindex-fallback.yaml | 28 ++++++++++ .github/workflows/lint-llamaindex.yaml | 52 +++++++++++++++++++ sdks/llamaindex/integration.cloudbuild.yaml | 43 +++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 .github/workflows/lint-llamaindex-fallback.yaml create mode 100644 .github/workflows/lint-llamaindex.yaml create mode 100644 sdks/llamaindex/integration.cloudbuild.yaml diff --git a/.github/workflows/lint-llamaindex-fallback.yaml b/.github/workflows/lint-llamaindex-fallback.yaml new file mode 100644 index 0000000000..87a230770a --- /dev/null +++ b/.github/workflows/lint-llamaindex-fallback.yaml @@ -0,0 +1,28 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: llamaindex +on: + pull_request: + paths: # These paths are the inverse of lint.yml + - "sdks/llamaindex/**/*.md" + +jobs: + lint: + runs-on: ubuntu-latest + permissions: + contents: none + + steps: + - run: echo "No tests required." \ No newline at end of file diff --git a/.github/workflows/lint-llamaindex.yaml b/.github/workflows/lint-llamaindex.yaml new file mode 100644 index 0000000000..c4414fb33e --- /dev/null +++ b/.github/workflows/lint-llamaindex.yaml @@ -0,0 +1,52 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: llamaindex +on: + pull_request: + paths: + - 'sdks/llamaindex/**' + - '!sdks/llamaindex/**/*.md' + +# Declare default permissions as read only. +permissions: read-all + +jobs: + lint: + runs-on: ubuntu-latest + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + steps: + - name: Checkout Repository + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + + - name: Setup Python + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 + with: + python-version: "3.13" + + - name: Install library requirements + run: pip install -r sdks/llamaindex/requirements.txt + + - name: Install test requirements + run: pip install sdks/llamaindex[test] + + - name: Run linters + run: | + black --check . + isort --check . + + - name: Run type-check + run: mypy --install-types --non-interactive --explicit-package-bases sdks/llamaindex \ No newline at end of file diff --git a/sdks/llamaindex/integration.cloudbuild.yaml b/sdks/llamaindex/integration.cloudbuild.yaml new file mode 100644 index 0000000000..0669527d21 --- /dev/null +++ b/sdks/llamaindex/integration.cloudbuild.yaml @@ -0,0 +1,43 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +steps: + - id: Install library requirements + name: 'python:${_VERSION}' + args: + - install + - '-r' + - 'sdks/llamaindex/requirements.txt' + - '--user' + entrypoint: pip + - id: Install test requirements + name: 'python:${_VERSION}' + args: + - install + - 'sdks/llamaindex[test]' + - '--user' + entrypoint: pip + - id: Run integration tests + name: 'python:${_VERSION}' + env: + - TOOLBOX_URL=$_TOOLBOX_URL + args: + - '-c' + - >- + python -m pytest sdks/llamaindex/tests/ + entrypoint: /bin/bash +options: + logging: CLOUD_LOGGING_ONLY +substitutions: + _VERSION: '3.13' \ No newline at end of file