From 1fec67bf29fb58650bf7ec13d1e2ec9daf3f6c68 Mon Sep 17 00:00:00 2001 From: Diwank Singh Tomer Date: Tue, 16 Apr 2024 08:35:51 +0530 Subject: [PATCH] fix(.github): Fix github action Signed-off-by: Diwank Singh Tomer --- .github/workflows/lint-and-format.yml | 132 ++++++++++++++------------ agents-api/pyproject.toml | 4 +- model-serving/pyproject.toml | 2 +- sdks/python/pyproject.toml | 2 +- 4 files changed, 74 insertions(+), 66 deletions(-) diff --git a/.github/workflows/lint-and-format.yml b/.github/workflows/lint-and-format.yml index a72aa77bb..f78776c5c 100644 --- a/.github/workflows/lint-and-format.yml +++ b/.github/workflows/lint-and-format.yml @@ -12,70 +12,78 @@ jobs: directory: [agents-api, model-serving, sdks/python] steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - - name: Install and configure Poetry - uses: snok/install-poetry@v1 - - - name: Configure Poetry to use .venv - run: | - cd ${{ matrix.directory }} - poetry config virtualenvs.in-project true - - - name: Cache Poetry virtualenv - uses: actions/cache@v3 - with: - path: ${{ matrix.directory }}/.venv - key: ${{ runner.os }}-poetry-${{ matrix.directory }}-${{ hashFiles(format('{0}/poetry.lock', matrix.directory)) }} - restore-keys: | - ${{ runner.os }}-poetry-${{ matrix.directory }}- - - - name: Install dependencies - run: | - cd ${{ matrix.directory }} - poetry install - - - name: Lint and format - run: | - cd ${{ matrix.directory }} - poetry run poe check - - - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: "refactor: Lint ${{ matrix.directory }} (CI)" - branch: ${{ github.head_ref }} + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install and configure Poetry + uses: snok/install-poetry@v1 + + - name: Configure Poetry to use .venv + run: | + cd ${{ matrix.directory }} + poetry config virtualenvs.in-project true + + - name: Cache Poetry virtualenv + uses: actions/cache@v3 + with: + path: ${{ matrix.directory }}/.venv + key: ${{ runner.os }}-poetry-${{ matrix.directory }}-${{ hashFiles(format('{0}/poetry.lock', matrix.directory)) }} + restore-keys: | + ${{ runner.os }}-poetry-${{ matrix.directory }}- + + - name: Cache pytype + uses: actions/cache@v3 + with: + path: ${{ matrix.directory }}/.pytype + key: ${{ runner.os }}-pytype-${{ matrix.directory }}-${{ hashFiles(format('{0}/**/*.py', matrix.directory)) }} + restore-keys: | + ${{ runner.os }}-pytype-${{ matrix.directory }}- + + - name: Install dependencies + run: | + cd ${{ matrix.directory }} + poetry install + + - name: Lint and format + run: | + cd ${{ matrix.directory }} + poetry run poe check + + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "refactor: Lint ${{ matrix.directory }} (CI)" + branch: ${{ github.head_ref }} Lint-And-Format-TS-SDK: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: '14.x' - - - name: Cache npm dependencies - uses: actions/cache@v3 - with: - path: sdks/ts/node_modules - key: ${{ runner.os }}-npm-${{ hashFiles('sdks/ts/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-npm- - - - name: Lint and format TypeScript SDK - run: | - cd sdks/ts - # npm ci - # npm run format - # npm run lint - - - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: "refactor: Lint sdks/ts (CI)" - branch: ${{ github.head_ref }} \ No newline at end of file + - uses: actions/checkout@v4 + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: "20.x" + + - name: Cache npm dependencies + uses: actions/cache@v3 + with: + path: sdks/ts/node_modules + key: ${{ runner.os }}-npm-${{ hashFiles('sdks/ts/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-npm- + + - name: Lint and format TypeScript SDK + run: | + cd sdks/ts + npm ci + # npm run format + # npm run lint + + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "refactor: Lint sdks/ts (CI)" + branch: ${{ github.head_ref }} diff --git a/agents-api/pyproject.toml b/agents-api/pyproject.toml index e0a6a406c..48bcd3637 100644 --- a/agents-api/pyproject.toml +++ b/agents-api/pyproject.toml @@ -40,7 +40,7 @@ build-backend = "poetry.core.masonry.api" [tool.poe.tasks] format = "black ." -lint = "ruff **/*.py --fix --unsafe-fixes" +lint = "ruff agents_api/**/*.py migrations/**/*.py tests/**/*.py --fix --unsafe-fixes" typecheck = "pytype agents_api" check = [ "format", @@ -48,4 +48,4 @@ check = [ "typecheck", ] test = "ward" -codegen = "datamodel-codegen --input ../openapi.yaml --input-file-type openapi --output agents_api/autogen/openapi_model.py --use-operation-id-as-name --use-double-quotes --use-schema-description --target-python-version 3.10 --reuse-model --collapse-root-models --use-field-description --field-include-all-keys --use-unique-items-as-set --use-subclass-enum --use-union-operator --use-one-literal-as-default --use-annotated --enum-field-as-literal one --output-model-type pydantic_v2.BaseModel" \ No newline at end of file +codegen = "datamodel-codegen --input ../openapi.yaml --input-file-type openapi --output agents_api/autogen/openapi_model.py --use-operation-id-as-name --use-double-quotes --use-schema-description --target-python-version 3.10 --reuse-model --collapse-root-models --use-field-description --field-include-all-keys --use-unique-items-as-set --use-subclass-enum --use-union-operator --use-one-literal-as-default --use-annotated --enum-field-as-literal one --output-model-type pydantic_v2.BaseModel" diff --git a/model-serving/pyproject.toml b/model-serving/pyproject.toml index 8d54a9c1d..7db1bfbb5 100644 --- a/model-serving/pyproject.toml +++ b/model-serving/pyproject.toml @@ -50,7 +50,7 @@ build-backend = "poetry.core.masonry.api" [tool.poe.tasks] prettify = "black ." -lint = "ruff **/*.py --fix --unsafe-fixes" +lint = "ruff model_api/**/*.py tests/**/*.py --fix --unsafe-fixes" typecheck = "pytype model_api" check = [ "prettify", diff --git a/sdks/python/pyproject.toml b/sdks/python/pyproject.toml index 6f14fb2d2..a6fc4aa87 100644 --- a/sdks/python/pyproject.toml +++ b/sdks/python/pyproject.toml @@ -34,7 +34,7 @@ build-backend = "poetry.core.masonry.api" [tool.poe.tasks] format = "black ." -lint = "ruff **/*.py --fix --unsafe-fixes" +lint = "ruff julep/**/*.py tests/**/*.py --fix --unsafe-fixes" typecheck = "pytype --config=pytype.toml julep" check = [ "format",