forked from UiPath/uipath-python
-
Notifications
You must be signed in to change notification settings - Fork 0
215 lines (181 loc) · 6.43 KB
/
Copy pathlint-packages.yml
File metadata and controls
215 lines (181 loc) · 6.43 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: Lint Packages
on:
workflow_call:
permissions:
contents: read
jobs:
detect-changed-packages:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.detect.outputs.packages }}
count: ${{ steps.detect.outputs.count }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Detect changed packages
id: detect
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: python .github/scripts/detect_changed_packages.py
lint-uipath-core:
name: Lint uipath-core
needs: detect-changed-packages
runs-on: ubuntu-latest
steps:
- name: Check if package changed
id: check
run: |
if echo '${{ needs.detect-changed-packages.outputs.packages }}' | jq -e 'index("uipath-core")' > /dev/null; then
echo "skip=false" >> $GITHUB_OUTPUT
else
echo "skip=true" >> $GITHUB_OUTPUT
fi
- name: Skip
if: steps.check.outputs.skip == 'true'
run: echo "Skipping - no changes to uipath-core"
- name: Checkout
if: steps.check.outputs.skip != 'true'
uses: actions/checkout@v4
- name: Setup uv
if: steps.check.outputs.skip != 'true'
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Setup Python
if: steps.check.outputs.skip != 'true'
uses: actions/setup-python@v5
with:
python-version-file: "packages/uipath-core/.python-version"
- name: Install dependencies
if: steps.check.outputs.skip != 'true'
working-directory: packages/uipath-core
run: uv sync --locked --all-extras
- name: Check static types
if: steps.check.outputs.skip != 'true'
working-directory: packages/uipath-core
run: uv run mypy --config-file pyproject.toml .
- name: Check linting
if: steps.check.outputs.skip != 'true'
working-directory: packages/uipath-core
run: uv run ruff check .
- name: Check formatting
if: steps.check.outputs.skip != 'true'
working-directory: packages/uipath-core
run: uv run ruff format --check .
lint-uipath-platform:
name: Lint uipath-platform
needs: detect-changed-packages
runs-on: ubuntu-latest
steps:
- name: Check if package changed
id: check
run: |
if echo '${{ needs.detect-changed-packages.outputs.packages }}' | jq -e 'index("uipath-platform")' > /dev/null; then
echo "skip=false" >> $GITHUB_OUTPUT
else
echo "skip=true" >> $GITHUB_OUTPUT
fi
- name: Skip
if: steps.check.outputs.skip == 'true'
run: echo "Skipping - no changes to uipath-platform"
- name: Checkout
if: steps.check.outputs.skip != 'true'
uses: actions/checkout@v4
- name: Setup uv
if: steps.check.outputs.skip != 'true'
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Setup Python
if: steps.check.outputs.skip != 'true'
uses: actions/setup-python@v5
with:
python-version-file: "packages/uipath-platform/.python-version"
- name: Install dependencies
if: steps.check.outputs.skip != 'true'
working-directory: packages/uipath-platform
run: uv sync --locked --all-extras
- name: Check static types
if: steps.check.outputs.skip != 'true'
working-directory: packages/uipath-platform
run: uv run mypy --config-file pyproject.toml .
- name: Check linting
if: steps.check.outputs.skip != 'true'
working-directory: packages/uipath-platform
run: uv run ruff check .
- name: Check formatting
if: steps.check.outputs.skip != 'true'
working-directory: packages/uipath-platform
run: uv run ruff format --check .
lint-uipath:
name: Lint uipath
needs: detect-changed-packages
runs-on: ubuntu-latest
steps:
- name: Check if package changed
id: check
run: |
if echo '${{ needs.detect-changed-packages.outputs.packages }}' | jq -e 'index("uipath")' > /dev/null; then
echo "skip=false" >> $GITHUB_OUTPUT
else
echo "skip=true" >> $GITHUB_OUTPUT
fi
- name: Skip
if: steps.check.outputs.skip == 'true'
run: echo "Skipping - no changes to uipath"
- name: Checkout
if: steps.check.outputs.skip != 'true'
uses: actions/checkout@v4
- name: Setup uv
if: steps.check.outputs.skip != 'true'
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Setup Python
if: steps.check.outputs.skip != 'true'
uses: actions/setup-python@v5
with:
python-version-file: "packages/uipath/.python-version"
- name: Install dependencies
if: steps.check.outputs.skip != 'true'
working-directory: packages/uipath
run: uv sync --locked --all-extras
- name: Check static types
if: steps.check.outputs.skip != 'true'
working-directory: packages/uipath
run: uv run mypy --config-file pyproject.toml .
- name: Check linting
if: steps.check.outputs.skip != 'true'
working-directory: packages/uipath
run: uv run ruff check .
- name: Check formatting
if: steps.check.outputs.skip != 'true'
working-directory: packages/uipath
run: uv run ruff format --check .
- name: Check httpx.Client() usage
if: steps.check.outputs.skip != 'true'
working-directory: packages/uipath
run: uv run python scripts/lint_httpx_client.py
lint-gate:
name: Lint
needs: [lint-uipath-core, lint-uipath-platform, lint-uipath]
runs-on: ubuntu-latest
if: always()
steps:
- name: Check lint results
run: |
if [[ "${{ needs.lint-uipath-core.result }}" == "failure" || \
"${{ needs.lint-uipath-platform.result }}" == "failure" || \
"${{ needs.lint-uipath.result }}" == "failure" ]]; then
echo "Lint failed"
exit 1
fi
echo "All lint checks passed"