-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yml
More file actions
255 lines (230 loc) · 7.65 KB
/
Copy pathTaskfile.yml
File metadata and controls
255 lines (230 loc) · 7.65 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
version: '3'
vars:
SCHEMA_DIR: ./dcs-world-schema
DIST_DIR: ./dist
OUTPUT_SCHEMA_JSON: "{{.DIST_DIR}}/dcs-world-api-schema.json"
OUTPUT_SCHEMA_YAML: "{{.DIST_DIR}}/dcs-world-api-schema.yaml"
OUTPUT_LUA: "{{.DIST_DIR}}/dcs-world-api.lua"
OUTPUT_TS: "{{.DIST_DIR}}/dcs-world-api.d.ts"
OUTPUT_GO: "{{.DIST_DIR}}/dcs-world-api.go"
OUTPUT_PYTHON: "{{.DIST_DIR}}/dcs_world_api.py"
OUTPUT_SELENE_YAML: "{{.DIST_DIR}}/dcs-world-selene.yml"
DCS_API_DUMP: ./reference_data/dcs_world_api_dump_latest.json
LINT_TARGETS: "{{.SCHEMA_DIR}}/*.yaml"
SRC_PY: ./tools
tasks:
setup:
desc: "Install uv and sync dependencies"
cmds:
- task: setup:{{OS}}
- task: uv:sync
setup:windows:
internal: true
silent: true
platforms: [windows]
cmds:
- echo "Checking for uv installation..."
- |
powershell -Command "
if (-not (Get-Command uv -ErrorAction SilentlyContinue)) {
Write-Host 'Installing uv...'
try {
# Preferred method using irm
Write-Host 'Using Invoke-RestMethod to install uv...'
powershell -ExecutionPolicy ByPass -c 'irm https://astral.sh/uv/install.ps1 | iex'
} catch {
Write-Host 'Falling back to curl method...'
curl -LsSf https://astral.sh/uv/install.sh -o install.ps1
powershell -ExecutionPolicy ByPass -File install.ps1
Remove-Item install.ps1
}
} else {
Write-Host 'uv is already installed'
}"
- echo "Syncing dependencies with uv..."
- powershell -Command "uv sync"
- echo "✅ Dependencies installed successfully"
setup:darwin:
silent: true
internal: true
platforms: [darwin]
cmds:
- echo "Checking for uv installation..."
- |
if ! command -v uv &> /dev/null; then
echo "Installing uv..."
# Try Homebrew first
if command -v brew &> /dev/null; then
echo "Using Homebrew to install uv..."
brew install uv
else
# Fall back to the standalone installer
echo "Using curl to install uv..."
curl -LsSf https://astral.sh/uv/install.sh | sh
fi
else
echo "uv is already installed"
fi
- echo "Syncing dependencies with uv..."
- uv sync
- echo "✅ Dependencies installed successfully"
setup:linux:
silent: true
internal: true
platforms: [linux]
cmds:
- echo "Checking for uv installation..."
- |
if ! command -v uv &> /dev/null; then
echo "Installing uv..."
# Try curl first
if command -v curl &> /dev/null; then
echo "Using curl to install uv..."
curl -LsSf https://astral.sh/uv/install.sh | sh
elif command -v wget &> /dev/null; then
echo "Using wget to install uv..."
wget -qO- https://astral.sh/uv/install.sh | sh
else
# Fall back to pip or pipx if available
if command -v pipx &> /dev/null; then
echo "Using pipx to install uv..."
pipx install uv
elif command -v pip &> /dev/null; then
echo "Using pip to install uv..."
pip install uv
else
echo "Error: Could not find curl, wget, pipx, or pip to install uv"
exit 1
fi
fi
else
echo "uv is already installed"
fi
- echo "Syncing dependencies with uv..."
- uv sync
- echo "✅ Dependencies installed successfully"
uv:sync:
desc: "Install the tools"
cmds:
- uv sync
default:
desc: "Run the full validation pipeline"
cmds: []
silent: true
deps:
- ci
clean:
desc: "Remove generated artifacts for a fresh run"
cmds:
- task: clean:{{OS}}
clean:windows:
internal: true
platforms: [windows]
cmds:
- powershell -Command "if (Test-Path '{{.DIST_DIR}}') { Remove-Item -Recurse -Force '{{.DIST_DIR}}' }"
- powershell -Command "New-Item -ItemType Directory -Force -Path '{{.DIST_DIR}}'"
clean:linux:
internal: true
platforms: [linux, darwin]
cmds:
- rm -rf {{.DIST_DIR}}
- mkdir -p {{.DIST_DIR}}
merge:
desc: "Merge all source YAML into a single JSON and YAML schema"
deps:
- merge:json
- merge:yaml
merge:json:
desc: "Merge all source YAML into a single JSON schema"
cmds:
- echo "Merging YAML files from {{.SCHEMA_DIR}} into {{.OUTPUT_SCHEMA_JSON}}..."
- uv run ./tools/merge.py {{.OUTPUT_SCHEMA_JSON}} --root {{.SCHEMA_DIR}} -f json
merge:yaml:
desc: "Merge all source YAML into a single YAML schema"
cmds:
- echo "Merging YAML files from {{.SCHEMA_DIR}} into {{.OUTPUT_SCHEMA_YAML}}..."
- uv run ./tools/merge.py {{.OUTPUT_SCHEMA_YAML}} --root {{.SCHEMA_DIR}} -f yaml
validate:
desc: "Validate all YAML files in the schema directory"
cmds:
- echo "Validating files in {{.SCHEMA_DIR}}..."
- "uv run ./tools/validate.py {{.SCHEMA_DIR}}"
"validate:file":
desc: "Validate a single YAML file (usage: task validate:file -- <path>)"
cmds:
- |
[ -n "{{.CLI_ARGS}}" ] || (echo "Provide a file path after --, e.g. task validate:file -- ./foo.yaml" && exit 1)
- echo "Validating {{.CLI_ARGS}}..."
- "uv run ./tools/validate.py {{.CLI_ARGS}}"
validate-types:
desc: "Ensure all referenced types exist in the merged spec"
deps:
- merge
cmds:
- "uv run ./tools/validate_types.py {{.OUTPUT_SCHEMA_JSON}}"
verify:
desc: "Compare generated schema with the official DCS API dump"
deps:
- merge
cmds:
- "uv run ./tools/verify.py {{.OUTPUT_SCHEMA_JSON}} {{.DCS_API_DUMP}}"
"fmt:py":
desc: "Auto-format Python tool scripts"
cmds:
- "uv run ruff check --fix {{.SRC_PY}}"
- "uv run ruff format {{.SRC_PY}}"
build:lua:
desc: "Generate EmmyLua type definitions from the schema"
deps:
- merge:json
cmds:
- echo "Generating EmmyLua type definitions to {{.OUTPUT_LUA}}..."
- "uv run python ./tools/export_lua.py {{.OUTPUT_SCHEMA_JSON}} --output {{.OUTPUT_LUA}}"
build:typescript:
desc: "Generate TypeScript definitions from the schema"
deps:
- merge:json
cmds:
- echo "Generating TypeScript definitions to {{.OUTPUT_TS}}..."
- "uv run python ./tools/export_typescript.py {{.OUTPUT_SCHEMA_JSON}} --output {{.OUTPUT_TS}}"
build:golang:
desc: "Generate Go struct definitions from the schema"
deps:
- merge:json
cmds:
- echo "Generating Go struct definitions to {{.OUTPUT_GO}}..."
- "uv run python ./tools/export_golang.py {{.OUTPUT_SCHEMA_JSON}} --output {{.OUTPUT_GO}}"
build:python:
desc: "Generate Python definitions from the schema"
deps:
- merge:json
cmds:
- echo "Generating Python definitions to {{.OUTPUT_PYTHON}}..."
- "uv run python ./tools/export_python.py {{.OUTPUT_SCHEMA_JSON}} --output {{.OUTPUT_PYTHON}}"
build:selene:
desc: "Generate Selene standard library from the schema"
deps:
- merge:json
cmds:
- echo "Generating Selene YAML to {{.OUTPUT_SELENE_YAML}}..."
- "uv run python ./tools/export_selene_yaml.py {{.OUTPUT_SCHEMA_JSON}} --output {{.OUTPUT_SELENE_YAML}}"
build:
desc: "Generate all exportable formats"
deps:
- build:lua
- build:typescript
- build:golang
- build:python
- build:selene
cmds: []
ci:
desc: "Aggregate tasks suitable for CI pipeline"
deps:
- setup
- clean
- merge
- validate
- validate-types
- verify
- "fmt:py"
cmds: []