Skip to content

Commit b10a034

Browse files
committed
configure vscode tasks
1 parent c0cda05 commit b10a034

File tree

5 files changed

+250
-32
lines changed

5 files changed

+250
-32
lines changed

.github/workflows/bump_version.py

+17-16
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,35 @@
55

66
VER_PATTERN = re.compile(r'^version = "(\d+)\.(\d+)\.(\d+)[^"]*" # auto', re.MULTILINE)
77
VER_REPLACE = 'version = "%d.%d.%d" # auto'
8-
COMPONENTS = ["major", "minor", "patch"]
8+
COMPONENTS = ("major", "minor", "patch")
99

1010

11-
class Args(argparse.Namespace):
11+
class Updater:
1212
component: str = "patch"
1313

14-
15-
def replace(match: re.Match | None) -> str:
16-
assert match is not None, "Could not find version in Cargo.toml"
17-
ver = [int(x) for x in match.groups()[:3]]
18-
assert len(ver) == 3
19-
print("old version:", ".".join([str(x) for x in ver]))
20-
index = COMPONENTS.index(Args.component)
21-
ver[index] += 1
22-
for i in range(index + 1, 3):
23-
ver[i] = 0
24-
print("new version:", ".".join([str(x) for x in ver]))
25-
return VER_REPLACE % tuple(ver)
14+
@staticmethod
15+
def replace(match: re.Match[str]) -> str:
16+
ver = [int(x) for x in match.groups()[: len(COMPONENTS)]]
17+
for _ in range(len(ver) - 1, len(COMPONENTS)):
18+
ver.append(0)
19+
print("old version:", ".".join([str(x) for x in ver]))
20+
index = COMPONENTS.index(Updater.component)
21+
ver[index] += 1
22+
for i in range(index + 1, 3):
23+
ver[i] = 0
24+
print("new version:", ".".join([str(x) for x in ver]))
25+
return VER_REPLACE % tuple(ver)
2626

2727

2828
def main():
2929
parser = argparse.ArgumentParser()
3030
parser.add_argument("component", default="patch", choices=COMPONENTS)
31-
parser.parse_args(namespace=Args)
31+
parser.parse_args(namespace=Updater)
3232
cargo_path = Path("Cargo.toml")
3333
doc = cargo_path.read_text(encoding="utf-8")
34-
doc = VER_PATTERN.sub(replace, doc)
34+
doc = VER_PATTERN.sub(Updater.replace, doc)
3535
cargo_path.write_text(doc, encoding="utf-8", newline="\n")
36+
print("Updated version in Cargo.toml")
3637
return 0
3738

3839

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ debug/
191191
# End of https://www.toptal.com/developers/gitignore/api/rust,python
192192

193193
# ignore vscode stuff
194-
.vscode/
194+
.vscode/**
195+
!.vscode/tasks.json
196+
!.vscode/extensions.json
195197

196198
# mdbook builds
197199
book

.vscode/extensions.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"rust-lang.rust-analyzer",
4+
"streetsidesoftware.code-spell-checker",
5+
"fill-labs.dependi",
6+
"wolfmah-vscode.just-syntax"
7+
]
8+
}

.vscode/tasks.json

+222
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "cargo",
6+
"command": "run",
7+
"problemMatcher": [
8+
"$rustc"
9+
],
10+
"label": "rust: cargo run cpp-linter",
11+
"args": [
12+
"--bin",
13+
"cpp-linter",
14+
"--manifest-path",
15+
"cpp-linter-lib/Cargo.toml",
16+
"--",
17+
"${input:binArgs}"
18+
],
19+
"group": "build"
20+
},
21+
{
22+
"type": "cargo",
23+
"command": "clippy",
24+
"problemMatcher": [
25+
"$rustc"
26+
],
27+
"label": "rust: cargo clippy",
28+
"args": [
29+
"--fix",
30+
"--allow-dirty",
31+
"--allow-staged"
32+
],
33+
"presentation": {
34+
"close": true,
35+
"revealProblems": "onProblem",
36+
"clear": true
37+
},
38+
"group": {
39+
"kind": "build",
40+
"isDefault": true
41+
}
42+
},
43+
{
44+
"type": "cargo",
45+
"command": "fmt",
46+
"problemMatcher": [
47+
"$rustc"
48+
],
49+
"label": "rust: cargo fmt",
50+
"args": [],
51+
"presentation": {
52+
"close": true,
53+
"revealProblems": "onProblem",
54+
"clear": true
55+
},
56+
"group": "build"
57+
},
58+
{
59+
"type": "cargo",
60+
"command": "llvm-cov",
61+
"problemMatcher": [
62+
"$rustc"
63+
],
64+
"label": "rust: cargo llvm-cov nextest",
65+
"args": [
66+
"--no-report",
67+
"nextest",
68+
"--lib",
69+
"--manifest-path",
70+
"cpp-linter-lib/Cargo.toml"
71+
],
72+
"group": {
73+
"kind": "test",
74+
"isDefault": true
75+
}
76+
},
77+
{
78+
"type": "cargo",
79+
"command": "llvm-cov",
80+
"problemMatcher": [],
81+
"label": "rust: cargo llvm-cov report json",
82+
"args": [
83+
"report",
84+
"--json",
85+
"--output-path",
86+
"coverage.json"
87+
],
88+
"presentation": {
89+
"close": true,
90+
"revealProblems": "onProblem",
91+
"clear": true
92+
},
93+
"group": "test"
94+
},
95+
{
96+
"type": "shell",
97+
"command": "llvm-cov-pretty",
98+
"problemMatcher": [],
99+
"label": "rust: cargo llvm-cov-pretty html",
100+
"args": [
101+
"coverage.json",
102+
"--open"
103+
],
104+
"presentation": {
105+
"close": true,
106+
"revealProblems": "onProblem",
107+
"clear": true
108+
},
109+
"group": "test"
110+
},
111+
{
112+
"type": "cargo",
113+
"command": "llvm-cov",
114+
"problemMatcher": [],
115+
"label": "rust: cargo llvm-cov report html",
116+
"args": [
117+
"report",
118+
"--html",
119+
"--open"
120+
],
121+
"presentation": {
122+
"close": true,
123+
"revealProblems": "onProblem",
124+
"clear": true
125+
},
126+
"group": "test"
127+
},
128+
{
129+
"type": "cargo",
130+
"command": "llvm-cov",
131+
"problemMatcher": [],
132+
"label": "rust: cargo llvm-cov report lcov",
133+
"args": [
134+
"report",
135+
"--lcov",
136+
"--output-path",
137+
"lcov.info"
138+
],
139+
"presentation": {
140+
"close": true,
141+
"revealProblems": "onProblem",
142+
"clear": true
143+
},
144+
"group": "test"
145+
},
146+
{
147+
"type": "cargo",
148+
"command": "doc",
149+
"problemMatcher": [
150+
"$rustc"
151+
],
152+
"label": "rust: cargo doc",
153+
"args": [
154+
"--no-deps",
155+
"--lib",
156+
"--manifest-path",
157+
"cpp-linter-lib/Cargo.toml",
158+
"--open"
159+
],
160+
"group": "build"
161+
},
162+
{
163+
"type": "shell",
164+
"command": "mdbook",
165+
"label": "mdbook: serve",
166+
"args": [
167+
"serve",
168+
"docs",
169+
"--open"
170+
],
171+
"problemMatcher": [],
172+
"group": "build"
173+
},
174+
{
175+
"type": "shell",
176+
"command": "mdbook",
177+
"label": "mdbook: build",
178+
"args": [
179+
"build",
180+
"docs",
181+
"--open"
182+
],
183+
"presentation": {
184+
"close": true,
185+
"revealProblems": "onProblem",
186+
"clear": true
187+
},
188+
"problemMatcher": [],
189+
"group": "build"
190+
},
191+
{
192+
"type": "shell",
193+
"command": "python",
194+
"label": "workspace: bump version",
195+
"args": [
196+
".github/workflows/bump_version.py",
197+
"${input:bumpComponent}"
198+
],
199+
"problemMatcher": [],
200+
"group": "none"
201+
}
202+
],
203+
"inputs": [
204+
{
205+
"type": "promptString",
206+
"id": "binArgs",
207+
"description": "Arguments for the cpp-linter binary executable",
208+
"default": "-h"
209+
},
210+
{
211+
"type": "pickString",
212+
"id": "bumpComponent",
213+
"description": "Which version component to bump?",
214+
"default": "patch",
215+
"options": [
216+
"major",
217+
"minor",
218+
"patch"
219+
]
220+
}
221+
]
222+
}

cpp_linter_rs.code-workspace

-15
This file was deleted.

0 commit comments

Comments
 (0)