rust-template 0.1.23__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,152 @@
1
+ Metadata-Version: 2.3
2
+ Name: rust-template
3
+ Version: 0.1.23
4
+ Summary: A production-ready Rust project template to bootstrap new projects fast. It includes a clean Cargo layout, Docker, and a complete CI/CD suite.
5
+ Keywords: cli,ai,coding-assistant,telemetry,claude,codex,gemini,usage-tracker,analytics
6
+ Author: Wei Lee
7
+ Author-email: Wei Lee <mai@mai0313.com>
8
+ License: MIT
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.8
22
+ Project-URL: Bug Tracker, https://github.com/Mai0313/rust_template/issues
23
+ Project-URL: Homepage, https://github.com/Mai0313/rust_template
24
+ Project-URL: Repository, https://github.com/Mai0313/rust_template
25
+ Description-Content-Type: text/markdown
26
+
27
+ <center>
28
+
29
+ # Rust Project Template
30
+
31
+ [![Crates.io](https://img.shields.io/crates/v/rust_template?logo=rust&style=flat-square&color=E05D44)](https://crates.io/crates/rust_template)
32
+ [![Crates.io Downloads](https://img.shields.io/crates/d/rust_template?logo=rust&style=flat-square)](https://crates.io/crates/rust_template)
33
+ [![npm version](https://img.shields.io/npm/v/rust_template?logo=npm&style=flat-square&color=CB3837)](https://www.npmjs.com/package/rust_template)
34
+ [![npm downloads](https://img.shields.io/npm/dt/rust_template?logo=npm&style=flat-square)](https://www.npmjs.com/package/rust_template)
35
+ [![rust](https://img.shields.io/badge/Rust-stable-orange?logo=rust&logoColor=white&style=flat-square)](https://www.rust-lang.org/)
36
+ [![tests](https://img.shields.io/github/actions/workflow/status/Mai0313/rust_template/test.yml?label=tests&logo=github&style=flat-square)](https://github.com/Mai0313/rust_template/actions/workflows/test.yml)
37
+ [![code-quality](https://img.shields.io/github/actions/workflow/status/Mai0313/rust_template/code-quality-check.yml?label=code-quality&logo=github&style=flat-square)](https://github.com/Mai0313/rust_template/actions/workflows/code-quality-check.yml)
38
+ [![license](https://img.shields.io/badge/License-MIT-green.svg?labelColor=gray&style=flat-square)](https://github.com/Mai0313/rust_template/tree/master?tab=License-1-ov-file)
39
+ [![PRs](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/Mai0313/rust_template/pulls)
40
+
41
+ </center>
42
+
43
+ 🚀 A production‑ready Rust project template to bootstrap new projects fast. It includes a clean Cargo layout, Docker, and a complete CI/CD suite.
44
+
45
+ Click [Use this template](https://github.com/Mai0313/rust_template/generate) to start a new repository from this scaffold.
46
+
47
+ Other Languages: [English](README.md) | [繁體中文](README.zh-TW.md) | [简体中文](README.zh-CN.md)
48
+
49
+ ## ✨ Highlights
50
+
51
+ - Modern Cargo layout (`src/lib.rs`, `src/main.rs`, `tests/`)
52
+ - Lint & format with clippy and rustfmt
53
+ - GitHub Actions: tests, quality, package build, Docker publish, release drafter, Rust-aware labeler, secret scans, semantic PR, weekly dependency update
54
+ - Multi-stage Dockerfile producing a minimal runtime image
55
+
56
+ ## 🚀 Quick Start
57
+
58
+ Prerequisites: Rust toolchain (`rustup`), Docker (optional)
59
+
60
+ ```bash
61
+ make fmt # rustfmt + clippy
62
+ make test # cargo test (all targets)
63
+ make test-verbose # cargo test (all targets with verbose output)
64
+ make coverage # generate LCOV coverage report
65
+ make build # cargo build (release mode)
66
+ make build-release # cargo build --release
67
+ make run # run the release binary
68
+ make clean # clean build artifacts and caches
69
+ make package # build crate package (allow dirty)
70
+ make help # list targets
71
+ ```
72
+
73
+ ## 🐳 Docker
74
+
75
+ ```bash
76
+ docker build -f docker/Dockerfile --target prod -t ghcr.io/<owner>/<repo>:latest .
77
+ docker run --rm ghcr.io/<owner>/<repo>:latest
78
+ ```
79
+
80
+ Or using the actual binary name:
81
+
82
+ ```bash
83
+ docker build -f docker/Dockerfile --target prod -t rust_template:latest .
84
+ docker run --rm rust_template:latest
85
+ ```
86
+
87
+ ## 📦 Packaging
88
+
89
+ ```bash
90
+ make package # build crate package (allow dirty)
91
+ # or use cargo directly:
92
+ cargo package --locked --allow-dirty
93
+ # CARGO_REGISTRY_TOKEN=... cargo publish
94
+ ```
95
+
96
+ CI builds run automatically on tags matching `v*` and upload the `.crate` file. Uncomment the publish step in `build_package.yml` to automate crates.io releases.
97
+
98
+ ## 🧩 Cross Builds
99
+
100
+ This template does not ship cross-compile tooling by default. If you need cross or zig-based builds locally, install and configure them per your environment.
101
+
102
+ GitHub Actions `build_release.yml` builds multi-platform release binaries on tags matching `v*` and uploads them to the GitHub Release assets.
103
+
104
+ Targets:
105
+
106
+ - x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl
107
+ - aarch64-unknown-linux-gnu, aarch64-unknown-linux-musl
108
+ - x86_64-apple-darwin, aarch64-apple-darwin
109
+ - x86_64-pc-windows-msvc, aarch64-pc-windows-msvc
110
+
111
+ Assets naming:
112
+
113
+ - `<bin>-v<version>-<target>.tar.gz` (all platforms)
114
+ - `<bin>-v<version>-<target>.zip` (Windows additionally)
115
+
116
+ ## 🔁 CI/CD Workflows
117
+
118
+ ### Main Workflows
119
+
120
+ - Tests (`test.yml`): cargo build/test + generate LCOV coverage report and upload artifact
121
+ - Code Quality (`code-quality-check.yml`): rustfmt check + clippy (deny warnings)
122
+ - Build Package (`build_package.yml`): package on tag `v*`, optional crates.io publish
123
+ - Publish Docker Image (`build_image.yml`): push to GHCR on `main/master` and tags `v*`
124
+ - Build Release (`build_release.yml`): Linux release binaries uploaded on tags `v*`
125
+
126
+ ### Additional Automation
127
+
128
+ - Auto Labeler (`auto_labeler.yml`): automatically label PRs based on branch names and file changes
129
+ - Code Scan (`code_scan.yml`): multi-layer security scanning (GitLeaks, Trufflehog secret scanning, CodeQL code analysis, Trivy vulnerability scanning)
130
+ - Release Drafter (`release_drafter.yml`): auto-generate release notes
131
+ - Semantic PR (`semantic-pull-request.yml`): enforce PR title format
132
+ - Dependabot weekly dependency updates
133
+
134
+ ## 🤝 Contributing
135
+
136
+ - Open issues/PRs
137
+
138
+ - Use Conventional Commits for PR titles
139
+
140
+ - Keep code formatted and clippy‑clean
141
+
142
+ - After every edit, run `cargo build` to confirm compilation is successful
143
+
144
+ - Before opening a PR, please run locally:
145
+
146
+ - `cargo fmt --all -- --check`
147
+ - `cargo clippy --all-targets --all-features -- -D warnings`
148
+ - `cargo test`
149
+
150
+ ## 📄 License
151
+
152
+ MIT — see `LICENSE`.
@@ -0,0 +1,126 @@
1
+ <center>
2
+
3
+ # Rust Project Template
4
+
5
+ [![Crates.io](https://img.shields.io/crates/v/rust_template?logo=rust&style=flat-square&color=E05D44)](https://crates.io/crates/rust_template)
6
+ [![Crates.io Downloads](https://img.shields.io/crates/d/rust_template?logo=rust&style=flat-square)](https://crates.io/crates/rust_template)
7
+ [![npm version](https://img.shields.io/npm/v/rust_template?logo=npm&style=flat-square&color=CB3837)](https://www.npmjs.com/package/rust_template)
8
+ [![npm downloads](https://img.shields.io/npm/dt/rust_template?logo=npm&style=flat-square)](https://www.npmjs.com/package/rust_template)
9
+ [![rust](https://img.shields.io/badge/Rust-stable-orange?logo=rust&logoColor=white&style=flat-square)](https://www.rust-lang.org/)
10
+ [![tests](https://img.shields.io/github/actions/workflow/status/Mai0313/rust_template/test.yml?label=tests&logo=github&style=flat-square)](https://github.com/Mai0313/rust_template/actions/workflows/test.yml)
11
+ [![code-quality](https://img.shields.io/github/actions/workflow/status/Mai0313/rust_template/code-quality-check.yml?label=code-quality&logo=github&style=flat-square)](https://github.com/Mai0313/rust_template/actions/workflows/code-quality-check.yml)
12
+ [![license](https://img.shields.io/badge/License-MIT-green.svg?labelColor=gray&style=flat-square)](https://github.com/Mai0313/rust_template/tree/master?tab=License-1-ov-file)
13
+ [![PRs](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/Mai0313/rust_template/pulls)
14
+
15
+ </center>
16
+
17
+ 🚀 A production‑ready Rust project template to bootstrap new projects fast. It includes a clean Cargo layout, Docker, and a complete CI/CD suite.
18
+
19
+ Click [Use this template](https://github.com/Mai0313/rust_template/generate) to start a new repository from this scaffold.
20
+
21
+ Other Languages: [English](README.md) | [繁體中文](README.zh-TW.md) | [简体中文](README.zh-CN.md)
22
+
23
+ ## ✨ Highlights
24
+
25
+ - Modern Cargo layout (`src/lib.rs`, `src/main.rs`, `tests/`)
26
+ - Lint & format with clippy and rustfmt
27
+ - GitHub Actions: tests, quality, package build, Docker publish, release drafter, Rust-aware labeler, secret scans, semantic PR, weekly dependency update
28
+ - Multi-stage Dockerfile producing a minimal runtime image
29
+
30
+ ## 🚀 Quick Start
31
+
32
+ Prerequisites: Rust toolchain (`rustup`), Docker (optional)
33
+
34
+ ```bash
35
+ make fmt # rustfmt + clippy
36
+ make test # cargo test (all targets)
37
+ make test-verbose # cargo test (all targets with verbose output)
38
+ make coverage # generate LCOV coverage report
39
+ make build # cargo build (release mode)
40
+ make build-release # cargo build --release
41
+ make run # run the release binary
42
+ make clean # clean build artifacts and caches
43
+ make package # build crate package (allow dirty)
44
+ make help # list targets
45
+ ```
46
+
47
+ ## 🐳 Docker
48
+
49
+ ```bash
50
+ docker build -f docker/Dockerfile --target prod -t ghcr.io/<owner>/<repo>:latest .
51
+ docker run --rm ghcr.io/<owner>/<repo>:latest
52
+ ```
53
+
54
+ Or using the actual binary name:
55
+
56
+ ```bash
57
+ docker build -f docker/Dockerfile --target prod -t rust_template:latest .
58
+ docker run --rm rust_template:latest
59
+ ```
60
+
61
+ ## 📦 Packaging
62
+
63
+ ```bash
64
+ make package # build crate package (allow dirty)
65
+ # or use cargo directly:
66
+ cargo package --locked --allow-dirty
67
+ # CARGO_REGISTRY_TOKEN=... cargo publish
68
+ ```
69
+
70
+ CI builds run automatically on tags matching `v*` and upload the `.crate` file. Uncomment the publish step in `build_package.yml` to automate crates.io releases.
71
+
72
+ ## 🧩 Cross Builds
73
+
74
+ This template does not ship cross-compile tooling by default. If you need cross or zig-based builds locally, install and configure them per your environment.
75
+
76
+ GitHub Actions `build_release.yml` builds multi-platform release binaries on tags matching `v*` and uploads them to the GitHub Release assets.
77
+
78
+ Targets:
79
+
80
+ - x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl
81
+ - aarch64-unknown-linux-gnu, aarch64-unknown-linux-musl
82
+ - x86_64-apple-darwin, aarch64-apple-darwin
83
+ - x86_64-pc-windows-msvc, aarch64-pc-windows-msvc
84
+
85
+ Assets naming:
86
+
87
+ - `<bin>-v<version>-<target>.tar.gz` (all platforms)
88
+ - `<bin>-v<version>-<target>.zip` (Windows additionally)
89
+
90
+ ## 🔁 CI/CD Workflows
91
+
92
+ ### Main Workflows
93
+
94
+ - Tests (`test.yml`): cargo build/test + generate LCOV coverage report and upload artifact
95
+ - Code Quality (`code-quality-check.yml`): rustfmt check + clippy (deny warnings)
96
+ - Build Package (`build_package.yml`): package on tag `v*`, optional crates.io publish
97
+ - Publish Docker Image (`build_image.yml`): push to GHCR on `main/master` and tags `v*`
98
+ - Build Release (`build_release.yml`): Linux release binaries uploaded on tags `v*`
99
+
100
+ ### Additional Automation
101
+
102
+ - Auto Labeler (`auto_labeler.yml`): automatically label PRs based on branch names and file changes
103
+ - Code Scan (`code_scan.yml`): multi-layer security scanning (GitLeaks, Trufflehog secret scanning, CodeQL code analysis, Trivy vulnerability scanning)
104
+ - Release Drafter (`release_drafter.yml`): auto-generate release notes
105
+ - Semantic PR (`semantic-pull-request.yml`): enforce PR title format
106
+ - Dependabot weekly dependency updates
107
+
108
+ ## 🤝 Contributing
109
+
110
+ - Open issues/PRs
111
+
112
+ - Use Conventional Commits for PR titles
113
+
114
+ - Keep code formatted and clippy‑clean
115
+
116
+ - After every edit, run `cargo build` to confirm compilation is successful
117
+
118
+ - Before opening a PR, please run locally:
119
+
120
+ - `cargo fmt --all -- --check`
121
+ - `cargo clippy --all-targets --all-features -- -D warnings`
122
+ - `cargo test`
123
+
124
+ ## 📄 License
125
+
126
+ MIT — see `LICENSE`.
@@ -0,0 +1,39 @@
1
+ [project]
2
+ name = "rust_template"
3
+ version = "0.1.23"
4
+ description = "A production-ready Rust project template to bootstrap new projects fast. It includes a clean Cargo layout, Docker, and a complete CI/CD suite."
5
+ authors = [
6
+ { name = "Wei Lee", email = "mai@mai0313.com" }
7
+ ]
8
+ readme = "README.md"
9
+ license = { text = "MIT" }
10
+ requires-python = ">=3.8"
11
+ dependencies = []
12
+ keywords = ["cli", "ai", "coding-assistant", "telemetry", "claude", "codex", "gemini", "usage-tracker", "analytics"]
13
+ classifiers = [
14
+ "Development Status :: 4 - Beta",
15
+ "Intended Audience :: Developers",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.8",
19
+ "Programming Language :: Python :: 3.9",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Operating System :: OS Independent",
25
+ "Topic :: Software Development :: Libraries :: Python Modules",
26
+ ]
27
+
28
+ [project.urls]
29
+ Homepage = "https://github.com/Mai0313/rust_template"
30
+ Repository = "https://github.com/Mai0313/rust_template"
31
+ "Bug Tracker" = "https://github.com/Mai0313/rust_template/issues"
32
+
33
+ [project.scripts]
34
+ vct = "rust_template:main"
35
+ rust_template = "rust_template:main"
36
+
37
+ [build-system]
38
+ requires = ["uv_build>=0.8.18,<0.9.0"]
39
+ build-backend = "uv_build"
@@ -0,0 +1,100 @@
1
+ import os
2
+ import platform
3
+ import subprocess
4
+ import sys
5
+ from pathlib import Path
6
+
7
+
8
+ def get_platform_info():
9
+ """Determine platform-specific directory and binary name."""
10
+ system = platform.system().lower()
11
+ machine = platform.machine().lower()
12
+
13
+ # Normalize architecture names
14
+ if machine in ("x86_64", "amd64"):
15
+ arch = "x64"
16
+ elif machine in ("aarch64", "arm64"):
17
+ arch = "arm64"
18
+ else:
19
+ print(f"Unsupported architecture: {machine}", file=sys.stderr)
20
+ sys.exit(1)
21
+
22
+ # Map to platform-specific directory and binary name
23
+ platform_map = {
24
+ "darwin": {
25
+ "x64": {"dir": "macos-x64", "binary": "rust_template"},
26
+ "arm64": {"dir": "macos-arm64", "binary": "rust_template"},
27
+ },
28
+ "linux": {
29
+ "x64": {"dir": "linux-x64-gnu", "binary": "rust_template"},
30
+ "arm64": {"dir": "linux-arm64-gnu", "binary": "rust_template"},
31
+ },
32
+ "windows": {
33
+ "x64": {"dir": "windows-x64", "binary": "rust_template.exe"},
34
+ "arm64": {"dir": "windows-arm64", "binary": "rust_template.exe"},
35
+ },
36
+ }
37
+
38
+ if system not in platform_map or arch not in platform_map[system]:
39
+ print(f"Unsupported platform: {system}-{arch}", file=sys.stderr)
40
+ sys.exit(1)
41
+
42
+ return platform_map[system][arch]
43
+
44
+
45
+ def find_binary():
46
+ """Find the binary for current platform."""
47
+ platform_info = get_platform_info()
48
+
49
+ # Get package root directory
50
+ package_root = Path(__file__).parent
51
+ binaries_dir = package_root / "binaries"
52
+
53
+ if not binaries_dir.exists():
54
+ print("Error: Binaries directory not found.", file=sys.stderr)
55
+ print("Please reinstall the package.", file=sys.stderr)
56
+ sys.exit(1)
57
+
58
+ # Look for the binary in platform-specific subdirectory
59
+ platform_dir = binaries_dir / platform_info["dir"]
60
+ binary_path = platform_dir / platform_info["binary"]
61
+
62
+ if not binary_path.exists():
63
+ print(
64
+ f"Error: Binary not found for your platform: {platform_info['dir']}/{platform_info['binary']}",
65
+ file=sys.stderr,
66
+ )
67
+ print("Please reinstall the package.", file=sys.stderr)
68
+ sys.exit(1)
69
+
70
+ # Make binary executable on Unix-like systems
71
+ if platform.system() != "Windows":
72
+ try:
73
+ os.chmod(binary_path, 0o755)
74
+ except OSError:
75
+ # Ignore error if already executable
76
+ pass
77
+
78
+ return binary_path
79
+
80
+
81
+ def main():
82
+ """Main entry point that forwards all arguments to the binary."""
83
+ binary_path = find_binary()
84
+
85
+ # Forward all arguments to the binary
86
+ args = sys.argv[1:]
87
+
88
+ try:
89
+ result = subprocess.run(
90
+ [str(binary_path)] + args,
91
+ check=False,
92
+ )
93
+ sys.exit(result.returncode)
94
+ except Exception as err:
95
+ print(f"Failed to start binary: {err}", file=sys.stderr)
96
+ sys.exit(1)
97
+
98
+
99
+ if __name__ == "__main__":
100
+ main()