Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
bf19a9d
Update build_and_publish.yaml
cobycloud Jan 28, 2025
4b34c53
v0.1.1.dev17
cobycloud Jan 28, 2025
56db79f
v0.1.1.dev18
cobycloud Jan 28, 2025
d1f2e92
Update build_ops.py
cobycloud Jan 28, 2025
5017d5e
v0.1.1.dev19
cobycloud Jan 28, 2025
50b8889
v0.1.1.dev20
cobycloud Jan 28, 2025
f330d9c
v0.1.1.dev21
cobycloud Jan 28, 2025
e27c328
vv0.1.1.dev22
cobycloud Jan 28, 2025
3e9e6e1
v0.1.1.dev23
cobycloud Jan 28, 2025
f73b8db
v0.1.1.dev24
cobycloud Jan 28, 2025
e56ee71
v0.1.1.dev25
cobycloud Jan 28, 2025
cca3e5b
v0.1.1.dev26
cobycloud Jan 28, 2025
bc57582
v0.1.1.dev27
cobycloud Jan 28, 2025
44b3e45
v0.1.1.dev28
cobycloud Jan 28, 2025
b985963
v0.1.1.dev29
cobycloud Jan 28, 2025
00ea8d6
v0.1.1.dev30
cobycloud Jan 28, 2025
c2b2aaf
Update test_ops.py
cobycloud Jan 28, 2025
a3de3fd
v0.1.1.dev31
cobycloud Jan 28, 2025
ca2282e
v0.1.1.dev32
cobycloud Jan 28, 2025
607997b
v0.1.1.dev33
cobycloud Jan 28, 2025
7019463
Update validate.py
cobycloud Jan 28, 2025
90f8db4
v0.1.1.dev34
cobycloud Jan 28, 2025
0172c43
v0.1.1.dev35
cobycloud Jan 28, 2025
b4d37a9
v0.1.1.dev36
cobycloud Jan 28, 2025
0c86a2f
v0.1.1.dev37
cobycloud Jan 28, 2025
9332bce
v0.1.1.dev38
cobycloud Jan 28, 2025
ffb92e9
v0.1.1.dev39
cobycloud Jan 28, 2025
f427ec9
v0.1.1.dev40
cobycloud Jan 28, 2025
7060f5f
v0.1.1.dev41
cobycloud Jan 28, 2025
879dec7
v0.1.1.dev42
cobycloud Jan 28, 2025
b5a3aef
v0.1.1.dev43
cobycloud Jan 28, 2025
9da0c30
v0.1.1.dev44
cobycloud Jan 28, 2025
0968b93
v0.1.1.dev45
cobycloud Jan 28, 2025
38043d3
0.1.1.dev46
cobycloud Jan 28, 2025
85d0005
Update README.md
cobycloud Feb 3, 2025
01a2e6e
Update README.md
cobycloud Feb 3, 2025
67f9e3c
rm deprecated
cobycloud Feb 4, 2025
29ad45c
v0.1.1.dev47
cobycloud Feb 4, 2025
fa7771f
vv0.1.1.dev48
cobycloud Feb 4, 2025
14f1125
v0.1.1.dev49
cobycloud Feb 4, 2025
7700928
v0.1.1.dev50
cobycloud Feb 4, 2025
a70d35d
v0.1.1.dev51
cobycloud Feb 4, 2025
6ca62ec
v0.1.1.dev52
cobycloud Feb 4, 2025
e8c9440
v0.1.1.dev53
cobycloud Feb 4, 2025
ce1942e
Update pyproject.toml
cobycloud Feb 4, 2025
2d608e1
v0.1.1.dev54
cobycloud Feb 4, 2025
96c0c83
rm deprecated tests
cobycloud Feb 4, 2025
4f88755
v0.1.1.dev55
cobycloud Feb 4, 2025
3d50c2d
v0.1.1.dev56
cobycloud Feb 4, 2025
4d0d61a
v0.1.1.dev57
cobycloud Feb 4, 2025
882b589
v0.1.1.dev58
cobycloud Feb 4, 2025
7ebc8e3
v0.1.1.dev59
cobycloud Feb 4, 2025
551fca7
v0.1.1.dev60
cobycloud Feb 4, 2025
be5d2f5
remove asyncio
cobycloud Feb 4, 2025
972ecbf
add asyncio
cobycloud Feb 4, 2025
3459ada
v0.1.1.dev64
cobycloud Feb 4, 2025
265667d
v0.1.1
cobycloud Feb 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build_and_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
pull_request:
branches:
- master
- dev

jobs:
build:
Expand All @@ -32,6 +33,7 @@ jobs:
- name: Install dependencies
run: |
cd ${{ matrix.pkg-dir }}
poetry lock
poetry install --no-cache -vv

- name: Lint with flake8
Expand Down
304 changes: 136 additions & 168 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,245 +1,213 @@
<p align="center">
<a href="https://github.com/swarmauri/swarmauri-sdk/"><img src="https://res.cloudinary.com/dbjmpekvl/image/upload/v1730099724/Swarmauri-logo-lockup-2048x757_hww01w.png" alt="Swamauri Logo"/></a>
<br />
<a href="https://hits.sh/github.com/swarmauri/soliloquy/"><img src="https://hits.sh/github.com/swarmauri/soliloquy.svg" alt="Hits"/></a>
<a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache_2.0-blue.svg" alt="License"/></a>
<a href="https://pypi.org/project/soliloquy/"><img src="https://img.shields.io/pypi/v/soliloquy?label=soliloquy" alt="PyPI - soliloquy Version"/></a>
<a href="https://pypi.org/project/soliloquy/"><img src="https://img.shields.io/pypi/dm/soliloquy?label=soliloquy%20Downloads" alt="PyPI - soliloquy Downloads"/></a>
<br />
<img src="https://img.shields.io/badge/Python-3776AB?style=for-the-badge&logo=python&labelColor=black" alt="Python"/>
<a href="https://github.com/swarmauri/swarmauri-sdk/">
<img src="https://res.cloudinary.com/dbjmpekvl/image/upload/v1730099724/Swarmauri-logo-lockup-2048x757_hww01w.png" alt="Swamauri Logo"/>
</a>
<br />
<a href="https://hits.sh/github.com/swarmauri/soliloquy/">
<img src="https://hits.sh/github.com/swarmauri/soliloquy.svg" alt="Hits"/>
</a>
<a href="https://opensource.org/licenses/Apache-2.0">
<img src="https://img.shields.io/badge/License-Apache_2.0-blue.svg" alt="License"/>
</a>
<a href="https://pypi.org/project/soliloquy/">
<img src="https://img.shields.io/pypi/v/soliloquy?label=soliloquy" alt="PyPI - soliloquy Version"/>
</a>
<a href="https://pypi.org/project/soliloquy/">
<img src="https://img.shields.io/pypi/dm/soliloquy?label=soliloquy%20Downloads" alt="PyPI - soliloquy Downloads"/>
</a>
<br />
<img src="https://img.shields.io/badge/Python-3776AB?style=for-the-badge&logo=python&labelColor=black" alt="Python"/>
</p>


# Soliloquy

**Soliloquy** is a unified command-line tool for managing a Python monorepo that contains multiple standalone packages—each with its own `pyproject.toml`. It consolidates common tasks such as dependency management, version bumping, remote dependency resolution, test execution and analysis, and project configuration updates into one robust CLI.

## Features

- **Dependency Management**
- **Lock:** Generate a `poetry.lock` file.
- **Install:** Install dependencies with options for extras and development dependencies.
- **Show Freeze:** (Available as an internal command) Display installed packages using `pip freeze`.

- **Build Operations**
- **Build:** Recursively build packages based on local (path) dependencies as specified in your `pyproject.toml` files.

- **Version Management**
- **Version:** Bump (major, minor, patch, finalize) or explicitly set package versions in `pyproject.toml`.

- **Remote Operations**
- **Remote Fetch:** Fetch the version from a remote GitHub repository’s `pyproject.toml`.
- **Remote Update:** Update a local `pyproject.toml` file with version information fetched from remote Git dependencies.
## Table of Contents

- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Commands](#commands)
- [Prepare](#prepare)
- [Install](#install)
- [Validate](#validate)
- [Release](#release)
- [Configuration](#configuration)
- [Examples](#examples)
- [Contributing](#contributing)
- [License](#license)
- [Contact](#contact)

- **Testing and Analysis**
- **Test:** Run your tests using pytest. Optionally, run tests in parallel (supports [pytest‑xdist](https://pypi.org/project/pytest-xdist/)).
- **Analyze:** Analyze test results provided in a JSON file by displaying summary statistics and evaluating threshold conditions for passed/skipped tests.
## Features

- **Pyproject Operations**
- **Pyproject:** Extract both local (path) and Git-based dependencies from a `pyproject.toml` file and, optionally, update dependency versions.
- **Version Management:** Automatically bump or set versions (major, minor, patch, or finalize) across projects.
- **Dependency Management:** Lock and install dependencies from single or multiple `pyproject.toml` files.
- **Validation:** Build, test, and analyze code with configurable test modes and parallel execution support.
- **Release Workflow:** Validate, update remote dependencies, and publish to PyPI with a single command.
- **Recursive Discovery:** Automatically scan directories (and subdirectories) to find `pyproject.toml` files.

## Installation

Install via pip:
Install Soliloquy directly from PyPI:

```bash
pip install soliloquy
```

_This command installs the `soliloquy` CLI, which is provided via the entry point `soliloquy`, into your system PATH._
Alternatively, install from source:

```bash
git clone https://github.com/swarmauri/soliloquy.git
cd soliloquy
pip install .
```

## Usage

After installation, run the following command to see a list of available commands:
After installation, you can run Soliloquy from the command line:

```bash
soliloquy --help
```

### Command Examples
This command displays the available commands and options.

#### 1. Lock Dependencies
### Commands

Generate a `poetry.lock` file by specifying either a directory or a file path containing a `pyproject.toml`:
Soliloquy includes several commands for different stages of your workflow:

```bash
# Lock using a directory:
soliloquy lock --directory ./packages/package1
#### Prepare

# Lock using an explicit pyproject.toml file:
soliloquy lock --file ./packages/package1/pyproject.toml
```
Bump or set version numbers, lint your code, and commit changes.

#### 2. Install Dependencies
**Options:**

Install dependencies with options for extras and including development dependencies:
- `-f`, `--file`: Specify a single `pyproject.toml` file.
- `-d`, `--directory`: Specify a directory containing one or more `pyproject.toml` files.
- `-R`, `--recursive`: Recursively find `pyproject.toml` files.
- `--bump`: Select the type of version bump (`major`, `minor`, `patch`, or `finalize`).
- `--set-ver`: Explicitly set a version (e.g., `2.0.0.dev1`).
- `--commit-msg`: Set the Git commit message (default: `"chore: prepare changes"`).

```bash
# Basic installation:
soliloquy install --directory ./packages/package1
**Example:**

# Using an explicit pyproject.toml file:
soliloquy install --file ./packages/package1/pyproject.toml
```bash
soliloquy prepare --bump patch -d ./packages
```

# Install including development dependencies:
soliloquy install --directory ./packages/package1 --dev
#### Install

# Install including extras (e.g., extras named "full"):
soliloquy install --directory ./packages/package2 --extras full
Lock dependencies and install packages across your projects.

# Install including all extras:
soliloquy install --directory ./packages/package2 --all-extras
```
**Options:**

#### 3. Build Packages
- `-f`, `--file`: Specify a single `pyproject.toml` file.
- `-d`, `--directory`: Specify a directory with multiple projects or an aggregator.
- `-R`, `--recursive`: Recursively find `pyproject.toml` files.

Recursively build packages based on their local dependency paths defined in their `pyproject.toml` files:
**Example:**

```bash
# Build packages using a directory containing a master pyproject.toml:
soliloquy build --directory .

# Build packages using an explicit pyproject.toml file:
soliloquy build --file ./packages/package1/pyproject.toml
soliloquy install -d ./projects --recursive
```

#### 4. Version Management

Bump or explicitly set the version in a package's `pyproject.toml`:
#### Validate

```bash
# Bump the patch version (e.g., from 1.2.3.dev1 to 1.2.3.dev2):
soliloquy version ./packages/package1/pyproject.toml --bump patch

# Finalize a development version (remove the .dev suffix):
soliloquy version ./packages/package1/pyproject.toml --bump finalize
Build, test, and analyze your code.

# Set an explicit version:
soliloquy version ./packages/package1/pyproject.toml --set 2.0.0.dev1
```
**Options:**

#### 5. Remote Operations
- `-f`, `--file`: Specify a single `pyproject.toml` file.
- `-d`, `--directory`: Specify a directory with multiple projects.
- `-R`, `--recursive`: Recursively find `pyproject.toml` files.
- `--test-mode`: Choose the test mode (`single`, `monorepo`, or `each`; default: `single`).
- `--num-workers`: Number of parallel pytest workers (default: `1`).
- `--results-json`: Path to a JSON file with test results for analysis.
- `--required-passed`: Set a requirement for passed tests (e.g., `ge:80`).
- `--required-skipped`: Set a requirement for skipped tests (e.g., `lt:10`).
- `--no-cleanup`: Prevent cleanup of temporary test directories for Git-based dependencies.

Fetch remote version information and update your local dependency configuration:
**Example:**

```bash
# Fetch the version from a remote GitHub repository's pyproject.toml:
soliloquy remote fetch --git-url https://github.com/YourOrg/YourRepo.git --branch main --subdir "src/"

# Update a local pyproject.toml with remote-resolved versions:
# (If --output is omitted, the input file is overwritten.)
soliloquy remote update --input ./packages/package1/pyproject.toml --output ./packages/package1/pyproject.updated.toml
soliloquy validate -d ./src --test-mode monorepo --num-workers 4
```

#### 6. Testing and Analysis

Run your tests using pytest and analyze test results from a JSON report:

- **Run Tests:**
Execute tests within a specified directory. Use the `--num-workers` flag for parallel execution (requires pytest‑xdist):
#### Release

```bash
# Run tests sequentially:
soliloquy test --directory ./tests

# Run tests in parallel using 4 workers:
soliloquy test --directory ./tests --num-workers 4
```

- **Analyze Test Results:**
Analyze a JSON test report and enforce thresholds for passed and skipped tests:
Validate, update remote dependencies, and publish your package to PyPI.

```bash
# Analyze test results without thresholds:
soliloquy analyze test-results.json

# Analyze test results with thresholds (e.g., passed tests > 75% and skipped tests < 20%):
soliloquy analyze test-results.json --required-passed gt:75 --required-skipped lt:20
```
**Options:**

#### 7. Pyproject Operations
- `-f`, `--file`: Specify a single `pyproject.toml` file.
- `-d`, `--directory`: Specify a directory with multiple projects.
- `-R`, `--recursive`: Recursively find `pyproject.toml` files.
- `--test-mode`: Choose the test mode (default: `single`).
- `--num-workers`: Number of parallel pytest workers (default: `1`).
- `--results-json`: Path to a JSON file with test results.
- `--required-passed`: Set a requirement for passed tests.
- `--required-skipped`: Set a requirement for skipped tests.
- `--publish-password`: Provide your PyPI password for publishing.
- `--no-cleanup`: Prevent cleanup of temporary test directories.

Extract and update dependency information from a `pyproject.toml` file:
**Example:**

```bash
# Extract local (path) and Git-based dependencies:
soliloquy pyproject --pyproject ./packages/package1/pyproject.toml

# Update local dependency versions to 2.0.0 (updates the parent file and, if possible, each dependency's own pyproject.toml):
soliloquy pyproject --pyproject ./packages/package1/pyproject.toml --update-version 2.0.0
soliloquy release -d ./myproject --publish-password YOUR_PYPI_PASSWORD
```

## Workflow Example in GitHub Actions
## Configuration

Soliloquy leverages the configuration defined in your `pyproject.toml` files. To get the most out of Soliloquy, ensure that each project within your monorepo is correctly configured. For more details on configuration options and best practices, please refer to the [official documentation](https://github.com/swarmauri/soliloquy).

## Examples

Here's an example GitHub Actions workflow that uses **soliloquy** to lock, build, install, test, bump the patch version, and publish:
Here are some practical use cases:

```yaml
name: Release Workflow
- **Prepare a release by bumping the patch version:**

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
```bash
soliloquy prepare --bump patch -d ./packages
```

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- **Install dependencies across all projects recursively:**

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
```bash
soliloquy install -d ./monorepo --recursive
```

- name: Install soliloquy Tools
run: pip install "soliloquy@git+https://github.com/swarmauri/soliloquy.git@master"
- **Run tests in monorepo mode with multiple workers:**

- name: Lock Dependencies
run: soliloquy lock --directory .
```bash
soliloquy validate -d ./src --test-mode monorepo --num-workers 4
```

- name: Build Packages
run: soliloquy build --directory .
- **Release your package after validation:**

- name: Install Dependencies
run: soliloquy install --directory .
```bash
soliloquy release -d ./myproject --publish-password YOUR_PYPI_PASSWORD
```

- name: Run Tests
run: soliloquy test --directory ./tests --num-workers 4
## Contributing

- name: Bump Patch Version
run: soliloquy version ./packages/package1/pyproject.toml --bump patch
Contributions are welcome! If you’d like to contribute:

- name: Publish Packages
env:
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: soliloquy publish --directory . --username "$PYPI_USERNAME" --password "$PYPI_PASSWORD"
```
1. **Fork the Repository:** Create your own fork on GitHub.
2. **Create a Branch:** Work on a new feature or bugfix.
3. **Write Tests:** Ensure your changes are covered by tests.
4. **Submit a Pull Request:** Provide a detailed description of your changes.

## Development
Please review our [CONTRIBUTING.md](CONTRIBUTING.md) for more details on our contribution process.

### Project Structure
## License

```
soliloquy/
├── __init__.py
├── cli.py # Main CLI entry point
├── poetry_ops.py # Poetry operations (lock, install, build, publish, run tests, etc.)
├── version_ops.py # Version bumping and setting operations
├── remote_ops.py # Remote Git dependency version fetching/updating
├── test_ops.py # Test result analysis operations
└── pyproject_ops.py # pyproject.toml dependency extraction and updates
pyproject.toml # Package configuration file containing metadata
README.md # This file
```
This project is licensed under the [Apache 2.0 License](https://opensource.org/licenses/Apache-2.0).

## Contributing
## Contact

Contributions are welcome! Please open issues or submit pull requests for improvements or bug fixes.
For questions, suggestions, or further information, please open an issue on [GitHub](https://github.com/swarmauri/soliloquy) or reach out directly.

## License
---

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
Happy coding with Soliloquy! 🚀
Loading
Loading