Skip to content

Commit

Permalink
chore: add python lint in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
spicyfalafel committed Sep 23, 2024
1 parent d0962d1 commit a73768d
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 14 deletions.
82 changes: 71 additions & 11 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,39 @@ on:
- "resources/sdk/**"

jobs:
lint:
detect-changes:
runs-on: ubuntu-latest
outputs:
typescript-changed: ${{ steps.detect-changes.outputs.typescript-changed }}
python-changed: ${{ steps.detect-changes.outputs.python-changed }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Detect file changes
id: detect-changes
run: |
# Fetch all changes between commits
git fetch --prune --unshallow || true
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
echo "Changed files: $CHANGED_FILES"
# Check if TypeScript or Python files have changed
if echo "$CHANGED_FILES" | grep -qE '^test/aidbox_sdk/snapshots/typescript/|^resources/sdk/typescript/'; then
echo "typescript-changed=true" >> $GITHUB_OUTPUT
fi
if echo "$CHANGED_FILES" | grep -qE '^test/aidbox_sdk/snapshots/python/|^resources/sdk/python/'; then
echo "python-changed=true" >> $GITHUB_OUTPUT
fi
lint-typescript:
needs: detect-changes
# env:
# CHANGED: ${{ needs.detect-changes.outputs.typescript-changed }}
if: ${{ needs.detect-changes.outputs.typescript-changed }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

Expand All @@ -28,20 +58,50 @@ jobs:
cache: "npm"
cache-dependency-path: test/aidbox_sdk/snapshots/typescript/package-lock.json

# - name: Cache Node modules
# uses: actions/cache@v3
# with:
# path: |
# ~/.npm
# **/node_modules
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-node-

- name: Install system and client dependencies
run: |
sudo apt -y update
cd test/aidbox_sdk/snapshots/typescript && npm ci
- name: Run ESLint
run: cd test/aidbox_sdk/snapshots/typescript && npm run lint

lint-python:
needs: detect-changes
if: ${{ needs.detect-changes.outputs.python-changed == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Merge Python SDK files
run: |
cp -r -u resources/sdk/python/* test/aidbox_sdk/snapshots/python/
- name: Clear pip cache
run: rm -rf $HOME/.cache/pip

- name: install rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. "$HOME/.cargo/env"
- name: Install build dependencies
run: sudo apt-get install -y build-essential

- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.x

- name: Install system
run: |
sudo apt -y update
python -m pip install --upgrade pip
- name: Install python dependencies
run: |
export RUST_BACKTRACE=1
cd test/aidbox_sdk/snapshots/python && pip install --prefer-binary './[dev]'
- name: Run python lint
run: cd test/aidbox_sdk/snapshots/python && pylint **/*.py
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ META/*
!META/.gitkeep

resources/sdk/typescript/node_modules/
resources/sdk/python/aidbox.egg-info/
15 changes: 12 additions & 3 deletions resources/sdk/python/setup.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
"""
setup.py
"""

from setuptools import setup

setup(
name="aidbox",
version="0.0.1",
description="",
python_requires=">=3.7",
python_requires=">=3.8",
package_data={"": ["py.typed"]},
include_package_data=True,
install_requires=[
"requests>=2.31.0",
"types-requests==2.31.0.8",
"pydantic[email]==2.0.0",
"pydantic_core==2.0.1",
"pydantic[email]==2.9.2",
# "pydantic_core==2.24.0",
],
extras_require={
'dev': [
'pylint'
],
},
classifiers=[
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
Expand Down

0 comments on commit a73768d

Please sign in to comment.