-
Notifications
You must be signed in to change notification settings - Fork 1
99 lines (81 loc) · 2.86 KB
/
lint.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Lint if snapshots change
on:
workflow_dispatch:
push:
branches:
- "**"
paths:
- ".github/workflows/lint.yaml"
- "test/aidbox_sdk/snapshots/**"
- "resources/sdk/**"
pull_request:
branches-ignore:
- "**"
jobs:
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
if: ${{ needs.detect-changes.outputs.typescript-changed }}
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 }}
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: 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: |
cd test/aidbox_sdk/snapshots/python && pip install --prefer-binary './[dev]'
- name: Run python lint
run: cd test/aidbox_sdk/snapshots/python && pylint **/*.py