mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-07-23 21:04:29 +00:00
Add version command with comprehensive unit tests and build integration
- Implement llama version command with table and JSON output formats - Add build-time git information capture via scripts/generate_build_info.py - Include comprehensive unit test suite (test_version.py, test_version_simple.py, test_version_integration.py) - Add build system integration with custom setup.py command - Update .gitignore to exclude generated build info file Features: - Display Llama Stack and client versions - Show Python version and build information (git commit, date, branch, tag) - Optional component/provider listing organized by API - Support for both table and JSON output formats - Build-time capture of git metadata for version tracking Testing: - 8 unit tests covering all functionality - Integration tests for CLI execution - Simple dependency-free validation tests - Documentation for test suite and build process Signed-off-by: Akram Ben Aissi <akram.benaissi@gmail.com>
This commit is contained in:
parent
dbdc811d16
commit
1da7714bab
11 changed files with 1431 additions and 1 deletions
47
scripts/README.md
Normal file
47
scripts/README.md
Normal file
|
@ -0,0 +1,47 @@
|
|||
# Build Scripts
|
||||
|
||||
This directory contains scripts used during the build process.
|
||||
|
||||
## generate_build_info.py
|
||||
|
||||
This script generates `llama_stack/cli/build_info.py` with hardcoded git information at build time. This ensures that version information is captured at build time rather than being read dynamically at runtime.
|
||||
|
||||
### Usage
|
||||
|
||||
The script is automatically run during the build process via the custom `BuildWithBuildInfo` class in `setup.py`. You can also run it manually:
|
||||
|
||||
```bash
|
||||
python scripts/generate_build_info.py
|
||||
```
|
||||
|
||||
### Generated Information
|
||||
|
||||
The script captures the following information:
|
||||
- Git commit hash (short form)
|
||||
- Git commit date
|
||||
- Git branch name
|
||||
- Git tag (latest)
|
||||
- Build timestamp
|
||||
|
||||
### CI/CD Integration
|
||||
|
||||
The script handles common CI/CD scenarios:
|
||||
- Detached HEAD state (common in CI environments)
|
||||
- Missing git information (fallback to environment variables)
|
||||
- Git not available (fallback to "unknown" values)
|
||||
|
||||
### Environment Variables
|
||||
|
||||
When running in CI/CD environments where the branch name might not be available via git (detached HEAD), the script checks these environment variables:
|
||||
- `GITHUB_REF_NAME` (GitHub Actions)
|
||||
- `CI_COMMIT_REF_NAME` (GitLab CI)
|
||||
- `BUILDKITE_BRANCH` (Buildkite)
|
||||
- `TRAVIS_BRANCH` (Travis CI)
|
||||
|
||||
### Build Integration
|
||||
|
||||
The build info generation is integrated into the build process via:
|
||||
1. `setup.py` - Custom build command that runs the script before building
|
||||
2. `pyproject.toml` - Standard Python package configuration
|
||||
|
||||
This ensures that every build includes up-to-date git information without requiring runtime git access.
|
Loading…
Add table
Add a link
Reference in a new issue