-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
139 lines (116 loc) · 3.8 KB
/
Taskfile.yml
File metadata and controls
139 lines (116 loc) · 3.8 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
# 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.5xx
# BASE_FILE: YiniLexerBase.py # Target/language specific base file.
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
start:
desc: Start the project.
cmds:
# - python src/main.py ./sample/basic.yini
- 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 all project checks.
cmds:
- task lint
- task typecheck
- task test
test:
desc: Run tests
cmds:
- python -m pytest -v
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 linter
cmds:
- python -m ruff check src
typecheck:
desc: Run mypy type checking
cmds:
- python -m mypy
build:
desc: Build source distribution and wheel
cmds:
- python -m build
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:
desc: Delete caches only
deps:
- clean-cache
clean-all:
desc: Delete caches and generated ANTLR output
deps:
- clean-cache
- clean-gen