-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
170 lines (142 loc) · 4.7 KB
/
Taskfile.yml
File metadata and controls
170 lines (142 loc) · 4.7 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
# Taskfile.yml for yini-parser-python.
# Setup new file on Windows:
# winget install Task.Task
# task --init
version: '3'
vars:
GRAMMAR_BASE: ./grammar/v1.0.0-rc.5xxxx
PARSER_FILE: "{{.GRAMMAR_BASE}}/YiniParser.g4"
LEXER_FILE: "{{.GRAMMAR_BASE}}/YiniLexer.g4"
ANTLR_JAR: ./libs/antlr4/antlr4-4.13.2-complete.jar
DIR_OUTPUT: ./src/yini_parser/grammar/generated
START_RULE: yini
tasks:
default:
cmds:
- task --list
antlr-help:
desc: Show ANTLR help
cmds:
- java -jar {{.ANTLR_JAR}} -help
run-sample:
desc: Start the project.
cmds:
- python src/main.py sample/basic.yini
dev:
desc: Run development entrypoint
cmds:
- python src/dev.py
install:
desc: Install yini-parser-python in editable mode
cmds:
- python -m pip install -e .
install-dev:
desc: Install yini-parser-python with development dependencies
cmds:
- python -m pip install -e ".[dev]"
antlr:
desc: Generate sources for the grammar (Windows only)
platforms: [windows]
cmds:
- echo Generate sources for the grammar...
# - mkdir {{.DIR_OUTPUT}}/base
# - cp {{.GRAMMAR_BASE}}/base/{{.BASE_FILE}} {{.DIR_OUTPUT}}/base
- >
java -jar {{.ANTLR_JAR}}
-Dlanguage=Python3
-no-listener -visitor
-o {{.DIR_OUTPUT}}
{{.LEXER_FILE}}
{{.PARSER_FILE}}
- echo Done.
check:
desc: Run tests, linting, formatting checks, and type checks.
cmds:
- task test
- task lint
- task format-check
- task typecheck
test-relaxed:
desc: Run tests without promoting warnings to errors.
cmds:
- python -m pytest -v
test:
desc: Run tests
cmds:
- python -m pytest -v -W error
test-adapter:
desc: Run the yini-test adapter against the sample basic YINI file
cmds:
- python tools/yini_parser_adapter.py --input sample/basic.yini
test-adapter-strict:
desc: Run the yini-test adapter in strict mode against a strict sample file
cmds:
- python tools/yini_parser_adapter.py --input sample/basic.strict.yini --mode strict
lint:
desc: Run Ruff lint checks.
cmds:
- python -m ruff check .
format-check:
desc: Check code formatting with Ruff.
cmds:
- python -m ruff format --check .
format:
desc: Format code with Ruff.
cmds:
- python -m ruff format .
typecheck:
desc: Run mypy type checks.
cmds:
- python -m mypy
build:
desc: Build source distribution and wheel
cmds:
- python -m build
release-check:
desc: Run full checks before publishing
cmds:
- task check
- task clean-build
- task build
- task check-dist
check-dist:
desc: Check built distribution metadata
cmds:
- python -m twine check dist/*
clean-gen:
desc: Delete generated ANTLR output directory contents (Windows only)
platforms: [windows]
cmds:
#- rmdir /s /q "{{.DIR_OUTPUT}}"
#- cmd /c rmdir /s /q "{{.DIR_OUTPUT}}"
- powershell -NoProfile -Command "if (Test-Path '{{.DIR_OUTPUT}}') { Remove-Item -Recurse -Force '{{.DIR_OUTPUT}}' }"
# Deletes Python caches under src:
# - __pycache__ directories
# - .pyc files
# - .pyo files, if any
clean-cache:
desc: Delete Python cache files and __pycache__ directories under src and tests
platforms: [windows]
cmds:
- powershell -NoProfile -Command "Get-ChildItem 'src','tests' -Recurse -Directory -Filter '__pycache__' -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force"
- powershell -NoProfile -Command "Get-ChildItem 'src','tests' -Recurse -File -Include *.pyc,*.pyo -ErrorAction SilentlyContinue | Remove-Item -Force"
- powershell -NoProfile -Command "if (Test-Path '.pytest_cache') { Remove-Item -Recurse -Force '.pytest_cache' }"
- powershell -NoProfile -Command "if (Test-Path '.mypy_cache') { Remove-Item -Recurse -Force '.mypy_cache' }"
- powershell -NoProfile -Command "if (Test-Path '.ruff_cache') { Remove-Item -Recurse -Force '.ruff_cache' }"
clean-build:
desc: Delete Python build artifacts
platforms: [windows]
cmds:
- powershell -NoProfile -Command "if (Test-Path 'build') { Remove-Item -Recurse -Force 'build' }"
- powershell -NoProfile -Command "if (Test-Path 'dist') { Remove-Item -Recurse -Force 'dist' }"
- powershell -NoProfile -Command "Get-ChildItem 'src' -Directory -Filter '*.egg-info' -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force"
clean:
desc: Delete caches only
deps:
- clean-cache
clean-all:
desc: Delete caches, build artifacts, and generated ANTLR output
deps:
- clean-cache
- clean-build
- clean-gen