-
Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy pathTaskfile.yml
More file actions
337 lines (335 loc) · 10.4 KB
/
Taskfile.yml
File metadata and controls
337 lines (335 loc) · 10.4 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
---
# see https://taskfile.dev/#/
# cspell: ignore unshallow rimraf
version: "3"
includes:
base:
taskfile: ./Taskfile.base.yml
flatten: true
als:
taskfile: ./packages/ansible-language-server
dir: ./packages/ansible-language-server
mcp:
taskfile: ./packages/ansible-mcp-server
dir: ./packages/ansible-mcp-server
output: prefixed # do not use "group" due to impact on CI
env:
# Overridden by some specific jobs
CODE_VERSION: max
vars:
VIRTUAL_ENV:
sh: echo "${HOME}/.local/share/virtualenvs/vsa"
XVFB:
# prefix to add to allow execution of test in headless machines (CI)
# keep the space after log filename as it is needed.
sh: bash -c 'if [[ "$OSTYPE" == "linux-gnu"* ]] && command -v xvfb-run >/dev/null; then echo "$(command -v xvfb-run) --auto-servernum -e out/log/xvfb.log "; fi'
tasks:
default:
desc: Run most commands
cmds:
- task: setup
- task: lint
- task: package
- task: docs
- echo {{.TASK}}
version:
cmds:
- ./tools/helper --version
clean:
desc: Clean up all files that not tracked by git
cmds:
- echo "Cleaning up... <disabled>"
- yarn workspaces foreach --all -tv run clean
- git clean -dxf
finish:
desc: Commands to run at the end of build and test processes
dir: "{{ .TASKFILE_DIR }}"
cmds:
# clean up uv cache, important for CI especially for caching size reduction
# - task: ci_clean_cache
# we also need to be sure that at the end of build and test we do not produce undesired side effects
- ./tools/precheck.sh
# ensure that `vitest list` works and does not display any warnings (stderr)
- vitest list 1>out/log/vitest-list-stdout.txt 2>out/log/vitest-list-stderr.txt && test ! -s out/log/vitest-list-stderr.txt || { echo "Failing because 'vitest list' should not produce any warnings:"; cat out/log/vitest-list-stderr.txt; exit 5; }
- tools/dirty.sh
build:
desc: Build the project
deps:
- setup
cmds:
# - for: sources
# cmd: echo {{ .ITEM }}
- task: yarn
- yarn run build
- yarn workspace @ansible/ansible-language-server run build:dist
- yarn run vite-build
sources:
- package.json
- "{src,test}/**/*"
- tsconfig*.json
- yarn.lock
- vite.config.mts
- exclude: "**/.ansible/**/*"
- exclude: "**/None/**/*"
- exclude: "src/vscode_ansible.egg-info/**/*"
- exclude: "test/**/__pycache__/**/*"
- exclude: "test/ui/**/*"
- exclude: "test/testFixtures/.vscode/**/*"
- exclude: "test/testFixtures/common/collections/ansible_collections/**/*"
- exclude: "test/testFixtures/hover/with_ee/collections/ansible_collections/**/*"
- exclude: "test/testFixtures/hover/without_ee/collections/ansible_collections/**/*"
generates:
- lib/**/*
- packages/ansible-language-server/lib/**/*
- packages/ansible-language-server/dist/**/*
code:
env:
# https://github.com/microsoft/vscode/issues/82524#issuecomment-1150315756
NODE_OPTIONS: "--no-deprecation"
desc: Forced install of extension in your code instance and restarts it
deps:
- package
cmds:
- pkill -9 -f "Visual Studio Code" || true
- code --force --install-extension out/*.vsix
- code examples/
deps:
desc: Update dependencies
env:
VSCODE_VERSION:
sh: node -p "require('./package.json').engines.vscode"
cmds:
- task: "deps:python"
- task: setup
# upgrade yarn itself
- yarn set version latest
# bumps some developments dependencies
- task: "deps:node"
# disabled because it does not work recursively
# - yarn upgrade-interactive
# restores a potential update of @types/vscode
- yarn up "@types/vscode@${VSCODE_VERSION}"
- yarn dedupe
# running install after upgrade is needed in order to update the lock file
- task: shared:install
- "{{.VIRTUAL_ENV}}/bin/python3 -m pre_commit autoupdate"
- task: lint
- task: build
interactive: true
"deps:node":
desc: Update node dependencies
interactive: true # needed for ncu prompts
cmds:
- yarn ncu -u --workspaces -i
- task: knip
"deps:python":
desc: Update python dependencies
cmds:
- uv sync --upgrade
# should prevent increasing cache size significantly on CI
- task: ci_clean_cache
- "{{.VIRTUAL_ENV}}/bin/python3 -m pre_commit autoupdate"
- task: lint
- task: build
docs:
dir: "{{ .TASKFILE_DIR }}"
desc: Build the documentation
deps:
- setup
sources:
- docs/**/*
- media/**/*
- mkdocs.yml
- pyproject.toml
generates:
- out/html/**/*
cmds:
# Retrieve possibly missing commits:
- $(git rev-parse --is-shallow-repository) && git fetch --unshallow > /dev/null || true
- git fetch --tags || git fetch --tags --force
- bash -c '. "${VIRTUAL_ENV}/bin/activate" && mkdocs build --strict --site-dir=${READTHEDOCS_OUTPUT:-out}/html/'
- defer: { task: finish }
lint:
desc: Lint the project
interactive: true
cmds:
- "{{.VIRTUAL_ENV}}/bin/prek run -a -v --color=always"
- defer: { task: finish }
silent: true
sources:
- "*.*"
- .config
- .github
- .vscode
- doc
- examples
- images
- src
- syntaxes
- test
- tools
- exclude: out
- exclude: node_modules
- exclude: site
- exclude: packages/*/out
- exclude: .cache
test:
# cspell: disable-next-line
desc: "Run all tests: unit, ui, e2e, als, mcp"
cmds:
- task: setup
# keep test types ordered by their durations, faster tests first
- task: unit # 10s
- task: mcp:test # 13s
- task: als:test # 20s
- task: e2e # 1min
- task: ui # 10min
# .vsix file is no longer needed for executing tests.
# This is just for making sure that the package step works w/o issues.
- task: package
- defer: { task: finish }
interactive: true
e2e:
dir: "{{ .TASKFILE_DIR }}"
vars:
TEST_PREFIX: "{{ .TASK }}"
desc: Run e2e tests with vscode-test {{.XVFB}}
deps:
- package
env:
NODE_NO_WARNINGS: "1"
DONT_PROMPT_WSL_INSTALL: "1"
# Possible workaround for: https://github.com/microsoft/vscode-test-cli/issues/555
TMP: "{{ .TASKFILE_DIR }}/out/e2e/tmp"
generates:
- out/junit/e2e-test-results.xml
- out/coverage/e2e/cobertura-coverage.xml
- out/coverage/e2e/lcov.info
- out/log/e2e/e2e.log
sources:
- "{src,test}/**/*"
- .vscode-test.mjs
- exclude: "**/.ansible/**/*"
- exclude: test/testFixtures/.vscode/settings.json
- exclude: test/testFixtures/diagnostics/yaml/invalid_yaml.yml
- exclude: test/unit/lightspeed/utils/samples/collections/ansible_collections/community/broken_MANIFEST/MANIFEST.json
cmds:
- rimraf .vscode-test/user-data/logs/*
- mkdir -p out/e2e/tmp
# cannot put coverage option inside .vscode-test.mjs
- "{{.XVFB}}vscode-test --install-extensions out/ansible-*.vsix --coverage --coverage-output ./out/coverage/e2e --coverage-reporter text --coverage-reporter cobertura --coverage-reporter lcovonly"
- defer: { task: collect-logs, vars: { TEST_PREFIX: "{{.TEST_PREFIX}}" } }
interactive: true
ui:
desc: Run UI tests (Selenium)
deps:
- package
sources:
- "*.vsix"
- pyproject.toml
- test/ui/**/*
- uv.lock
- "out/data/ansible-latest.vsix"
generates:
- out/junit/ui-test-results.xml
cmds:
- >
pytest
-v
--cov-branch
--cov-context=test
--cov-report=term-missing:skip-covered
--cov-report=xml:out/coverage/ui/coverage.xml
--cov=test
--junit-xml=out/junit/ui-test-results.xml
--no-cov-on-fail
{{.CLI_ARGS}}
# --reruns-delay=120
# --reruns=3
- defer: podman-compose down
interactive: true
unit:
desc: Run unit tests with coverage report
deps:
- build
sources:
- "{src,test}/**/*"
# - test/**/*
- vitest.config.ts
- packages/*/{src,test}/**.*
generates:
- out/coverage/unit/lcov.info
- out/junit/unit-test-results.xml
cmds:
- vitest run
interactive: true
package:
desc: Package extension
deps:
- als:package
- mcp:package
- build
sources:
- "{src,media,webviews}/**/*" # do not include 'test' as they do not get into the package
- .vscodeignore
- CHANGELOG.md
- README.md
- exclude: "**/.ansible/**/*"
- exclude: "test/ui/**/*"
- package*.json
- tools/helper
- yarn.lock
- dist/**/*
generates:
- "out/*.vsix"
- "out/data/ansible-latest.vsix"
cmds:
# we want to build both all the time:
- ./tools/helper --package
- packages/ansible-language-server/tools/can-release.sh
- task: knip
- defer: { task: finish }
silent: true
pr:
desc: Opens a pull request using gh
deps:
- setup
cmds:
- task: lint
- gh pr create
interactive: true
release:
desc: Create a new release (used by CI)
cmds:
- ./tools/release.sh
interactive: true
builder:
desc: Build container image used for building the extension
cmds:
- ./tools/builder.sh
ci_clean_cache:
desc: Clean up caches (only runs when CI=true)
status:
- '[ "$CI" != "true" ]'
cmds:
- uv cache prune --ci
- find `python3 -m pip cache dir`/wheels -type f -atime +30 -delete || true
flush:
desc: Cleans cached files that sometimes can affect the build negatively, not a full clean
cmds:
- rm -rf .vscode-test/ || true
dry:
desc: Pretend it does run tests, used to validate configuration of the test frameworks
deps:
- package
cmds:
- vitest list >> /dev/null
# checks for a bug that prevented calling vitest from subdirectories
- cd packages/ansible-language-server && vitest list >> /dev/null
- "{{.XVFB}}vscode-test --dry-run --fail-zero || echo 'Ignored failure to run vscode-test as e2e tests do not yet run inside a containers.'"
collect-logs:
requires:
vars: [TEST_PREFIX]
cmds:
- find .vscode-test/user-data/logs -name "*.log" -type f -exec cp -v {} out/{{.TEST_PREFIX}}/ \; 2>/dev/null || true
- defer: tools/sanitize-logs.py out/{{.TEST_PREFIX}}/*.log