Skip to content

Commit f1c1268

Browse files
authored
Merge pull request #435 from DefangLabs/eric/add-python-linting
2 parents e86b457 + af48436 commit f1c1268

File tree

1 file changed

+82
-2
lines changed

1 file changed

+82
-2
lines changed

.github/workflows/build-samples-json.yml

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,95 @@
11
name: Trigger Docs Samples Rebuild
2+
permissions:
3+
contents: read
4+
pull-requests: read
25

36
on:
4-
push:
7+
pull_request:
8+
types: [opened, synchronize, reopened]
59
branches:
6-
- main
10+
- "**"
711
paths:
812
- "samples/**"
913

1014
jobs:
15+
python-lint:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Get list of changed files
22+
id: changed
23+
run: |
24+
files=$(git diff --name-only origin/${{ github.base_ref }}...${{ github.head_ref }} | grep '\.py$' || true)
25+
echo "files=$files" >> "$GITHUB_OUTPUT"
26+
27+
- name: Run Ruff linter
28+
uses: astral-sh/ruff-action@v1
29+
with:
30+
args: check
31+
src: ${{ steps.changed.outputs.files }}
32+
33+
- name: Run Ruff formatter check
34+
uses: astral-sh/ruff-action@v1
35+
with:
36+
args: "format --check"
37+
src: ${{ steps.changed.outputs.files }}
38+
39+
js-ts-lint:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v4
44+
45+
- name: Set up Node.js
46+
uses: actions/setup-node@v4
47+
with:
48+
node-version: "20"
49+
50+
- name: Get list of changed JS/TS files
51+
id: changed_js
52+
run: |
53+
files=$(git diff --name-only origin/${{ github.base_ref }}...${{ github.head_ref }} | grep -E '\.(js|ts|jsx|tsx)$' || true)
54+
echo "files=$files" >> "$GITHUB_OUTPUT"
55+
56+
- name: Run ESLint (JS/TS only)
57+
run: |
58+
if [ -n "${{ steps.changed_js.outputs.files }}" ]; then
59+
npx eslint ${{ steps.changed_js.outputs.files }}
60+
else
61+
echo "No JS/TS files to lint."
62+
fi
63+
64+
- name: Run Prettier check (JS/TS only)
65+
run: |
66+
if [ -n "${{ steps.changed_js.outputs.files }}" ]; then
67+
npx prettier --check ${{ steps.changed_js.outputs.files }}
68+
else
69+
echo "No JS/TS files to format check."
70+
fi
71+
72+
go-lint:
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: Checkout code
76+
uses: actions/checkout@v4
77+
78+
- name: Set up Golang
79+
uses: actions/setup-go@v5
80+
with:
81+
go-version: stable
82+
83+
- name: Run golangci-lint
84+
uses: golangci/golangci-lint-action@v8
85+
with:
86+
args: --enable gofmt --enable goimports
87+
only-new-issues: true
88+
version: latest
89+
1190
build-json:
1291
runs-on: ubuntu-latest
92+
needs: [python-lint, js-ts-lint, go-lint]
1393
steps:
1494
- name: Trigger CLI Autodoc
1595
uses: peter-evans/repository-dispatch@v1

0 commit comments

Comments
 (0)