chore: fix lint #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Lint if snapshots change | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- "**" | |
paths: | |
- ".github/workflows/lint.yaml" | |
- "test/aidbox_sdk/snapshots/**" | |
- "resources/sdk/**" | |
jobs: | |
detect-changes: | |
runs-on: ubuntu-latest | |
outputs: | |
typescript-changed: ${{ steps.detect.outputs.typescript-changed }} | |
python-changed: ${{ steps.detect.outputs.python-changed }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Detect file changes | |
id: detect | |
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_ENV | |
else | |
echo "typescript-changed=false" >> $GITHUB_ENV | |
fi | |
if echo "$CHANGED_FILES" | grep -qE '^test/aidbox_sdk/snapshots/python/|^resources/sdk/python/'; then | |
echo "python-changed=true" >> $GITHUB_ENV | |
else | |
echo "python-changed=false" >> $GITHUB_ENV | |
fi | |
- name: Set outputs | |
id: set-outputs | |
run: | | |
echo "typescript-changed=${{ env.typescript-changed }}" >> $GITHUB_ENV | |
echo "python-changed=${{ env.python-changed }}" >> $GITHUB_ENV | |
lint-typescript: | |
needs: detect-changes | |
if: ${{ needs.detect-changes.outputs.typescript-changed == 'true' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Merge TypeScript SDK files | |
run: | | |
cp -r -u resources/sdk/typescript/* test/aidbox_sdk/snapshots/typescript/ | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "npm" | |
cache-dependency-path: test/aidbox_sdk/snapshots/typescript/package-lock.json | |
- 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: Setup python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.x | |
- name: Install system and client dependencies | |
run: | | |
cd test/aidbox_sdk/snapshots/python && pip install './[dev]' | |
- name: Run python lint | |
run: cd test/aidbox_sdk/snapshots/python && pylint **/*.py |