Skip to content

Commit fa09129

Browse files
authored
Use task runner just (or VSCode "tasks") (#14)
* use `just`. See https://just.systems * configure vscode tasks
1 parent d746a94 commit fa09129

14 files changed

+382
-80
lines changed

.github/workflows/binary-builds.yml

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,8 @@ on:
1212
branches: [main]
1313

1414
env:
15-
CARGO_INCREMENTAL: 0
16-
CARGO_NET_GIT_FETCH_WITH_CLI: true
17-
CARGO_NET_RETRY: 10
1815
CARGO_TERM_COLOR: always
1916
RUST_BACKTRACE: 1
20-
RUSTFLAGS: -D warnings
21-
RUSTUP_MAX_RETRIES: 10
2217

2318
defaults:
2419
run:
@@ -99,15 +94,6 @@ jobs:
9994
- name: Checkout
10095
uses: actions/checkout@v4
10196

102-
- uses: actions/setup-python@v5
103-
if: startsWith(github.ref, 'refs/tags/')
104-
with:
105-
python-version: '3.x'
106-
107-
- name: Increment version
108-
if: startsWith(github.ref, 'refs/tags/')
109-
run: python .github/workflows/replace_version_spec.py --new-version=${{ github.ref_name }}
110-
11197
- name: Setup Rust
11298
uses: dtolnay/rust-toolchain@stable
11399
with:
@@ -119,13 +105,15 @@ jobs:
119105
with:
120106
tool: cross
121107

122-
- name: Build (native)
123-
if: ${{ !matrix.cross }}
124-
run: cargo build --manifest-path cpp-linter-lib/Cargo.toml --release --bin cpp-linter --target ${{ matrix.target }} ${{ matrix.vendered && '--features openssl-vendored' || '' }}
125-
126-
- name: Build (cross)
127-
if: matrix.cross
128-
run: cross build --manifest-path cpp-linter-lib/Cargo.toml --release --bin cpp-linter --target ${{ matrix.target }} ${{ matrix.vendered && '--features openssl-vendored' || '' }}
108+
- name: Build
109+
run: >-
110+
${{ matrix.cross && 'cross' || 'cargo '}}
111+
build
112+
--manifest-path cpp-linter-lib/Cargo.toml
113+
--bin cpp-linter
114+
--release
115+
--target ${{ matrix.target }}
116+
${{ matrix.vendered && '--features openssl-vendored' || '' }}
129117
130118
- name: Prepare artifacts
131119
run: mv target/${{ matrix.target }}/release/cpp-linter${{ runner.os == 'Windows' && '.exe' || '' }} ./cpp-linter-${{ matrix.target }}${{ runner.os == 'Windows' && '.exe' || '' }}

.github/workflows/build-docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on: [push, workflow_dispatch]
44

55
env:
66
CARGO_TERM_COLOR: always
7+
RUST_BACKTRACE: 1
78

89
jobs:
910
cache-deps:

.github/workflows/bump_version.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import argparse
2+
from pathlib import Path
3+
import sys
4+
import re
5+
6+
VER_PATTERN = re.compile(r'^version = "(\d+)\.(\d+)\.(\d+)[^"]*" # auto', re.MULTILINE)
7+
VER_REPLACE = 'version = "%d.%d.%d" # auto'
8+
COMPONENTS = ("major", "minor", "patch")
9+
10+
11+
class Updater:
12+
component: str = "patch"
13+
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)
26+
27+
28+
def main():
29+
parser = argparse.ArgumentParser()
30+
parser.add_argument("component", default="patch", choices=COMPONENTS)
31+
parser.parse_args(namespace=Updater)
32+
cargo_path = Path("Cargo.toml")
33+
doc = cargo_path.read_text(encoding="utf-8")
34+
doc = VER_PATTERN.sub(Updater.replace, doc)
35+
cargo_path.write_text(doc, encoding="utf-8", newline="\n")
36+
print("Updated version in Cargo.toml")
37+
return 0
38+
39+
40+
if __name__ == "__main__":
41+
sys.exit(main())

.github/workflows/pre-commit-hooks.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ jobs:
1212

1313
cargo-tools:
1414
runs-on: ubuntu-latest
15+
16+
env:
17+
CARGO_TERM_COLOR: always
18+
RUST_BACKTRACE: 1
19+
1520
steps:
1621
- uses: actions/checkout@v4
1722
- run: rustup update

.github/workflows/python-packaging.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ on:
1616
permissions:
1717
contents: read
1818

19+
env:
20+
CARGO_TERM_COLOR: always
21+
RUST_BACKTRACE: 1
22+
1923
jobs:
2024
linux:
2125
runs-on: ubuntu-latest
@@ -35,10 +39,6 @@ jobs:
3539
with:
3640
python-version: '3.x'
3741

38-
- name: Increment version
39-
if: startsWith(github.ref, 'refs/tags/')
40-
run: python .github/workflows/replace_version_spec.py --new-version=${{ github.ref_name }}
41-
4242
- name: Calculate openssl-vendored
4343
shell: bash
4444
id: is-openssl-vendored

.github/workflows/replace_version_spec.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/run-dev-tests.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ on:
1919

2020
env:
2121
CARGO_TERM_COLOR: always
22+
RUST_BACKTRACE: 1
2223

2324
jobs:
2425
cache-deps:
@@ -63,10 +64,10 @@ jobs:
6364
# if: runner.os == 'Windows'
6465
# run: vcpkg install openssl
6566

66-
- name: Install cargo-nextest and cargo-llvm-cov
67+
- name: Install third-party binaries
6768
uses: taiki-e/install-action@v2
6869
with:
69-
tool: cargo-nextest,cargo-llvm-cov,cargo-binstall
70+
tool: cargo-nextest,cargo-llvm-cov,cargo-binstall,just
7071

7172
- name: Install llvm-cov-pretty (HTML report generator)
7273
run: cargo binstall -y llvm-cov-pretty
@@ -116,15 +117,13 @@ jobs:
116117
working-directory: cpp-linter-lib
117118
env:
118119
CLANG_VERSION: ${{ matrix.version }}
119-
run: cargo llvm-cov --lib --no-report nextest
120+
run: just test
120121

121122
- name: Generate Coverage HTML report
122123
working-directory: cpp-linter-lib
123124
env:
124125
CLANG_VERSION: ${{ matrix.version }}
125-
run: |
126-
cargo llvm-cov report --json --output-path .coverage.json
127-
llvm-cov-pretty .coverage.json
126+
run: just pretty-cov
128127

129128
- name: Upload coverage data
130129
uses: actions/upload-artifact@v4

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,15 @@ 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
198200

199201
# ignore generated files
200202
.cpp-linter_cache/
201203
cpp-linter-py/docs/cli_args.rst
204+
lcov.info
205+
coverage.json

.vscode/extensions.json

Lines changed: 8 additions & 0 deletions
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+
}

0 commit comments

Comments
 (0)