mirror of
https://github.com/bahdotsh/wrkflw.git
synced 2025-12-16 19:57:44 +01:00
Merge pull request #33 from bahdotsh/docs/add-crate-readmes
docs(readme): add per-crate READMEs and enhance wrkflw crate README
This commit is contained in:
29
crates/evaluator/README.md
Normal file
29
crates/evaluator/README.md
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
## wrkflw-evaluator
|
||||||
|
|
||||||
|
Small, focused helper for statically evaluating GitHub Actions workflow files.
|
||||||
|
|
||||||
|
- **Purpose**: Fast structural checks (e.g., `name`, `on`, `jobs`) before deeper validation/execution
|
||||||
|
- **Used by**: `wrkflw` CLI and TUI during validation flows
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
let result = wrkflw_evaluator::evaluate_workflow_file(
|
||||||
|
Path::new(".github/workflows/ci.yml"),
|
||||||
|
/* verbose */ true,
|
||||||
|
).expect("evaluation failed");
|
||||||
|
|
||||||
|
if result.is_valid {
|
||||||
|
println!("Workflow looks structurally sound");
|
||||||
|
} else {
|
||||||
|
for issue in result.issues {
|
||||||
|
println!("- {}", issue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Notes
|
||||||
|
- This crate focuses on structural checks; deeper rules live in `wrkflw-validators`.
|
||||||
|
- Most consumers should prefer the top-level `wrkflw` CLI for end-to-end UX.
|
||||||
29
crates/executor/README.md
Normal file
29
crates/executor/README.md
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
## wrkflw-executor
|
||||||
|
|
||||||
|
The execution engine that runs GitHub Actions workflows locally (Docker, Podman, or emulation).
|
||||||
|
|
||||||
|
- **Features**:
|
||||||
|
- Job graph execution with `needs` ordering and parallelism
|
||||||
|
- Docker/Podman container steps and emulation mode
|
||||||
|
- Basic environment/context wiring compatible with Actions
|
||||||
|
- **Used by**: `wrkflw` CLI and TUI
|
||||||
|
|
||||||
|
### API sketch
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use wrkflw_executor::{execute_workflow, ExecutionConfig, RuntimeType};
|
||||||
|
|
||||||
|
let cfg = ExecutionConfig {
|
||||||
|
runtime: RuntimeType::Docker,
|
||||||
|
verbose: true,
|
||||||
|
preserve_containers_on_failure: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Path to a workflow YAML
|
||||||
|
let workflow_path = std::path::Path::new(".github/workflows/ci.yml");
|
||||||
|
|
||||||
|
let result = execute_workflow(workflow_path, cfg).await?;
|
||||||
|
println!("workflow status: {:?}", result.summary_status);
|
||||||
|
```
|
||||||
|
|
||||||
|
Prefer using the `wrkflw` binary for a complete UX across validation, execution, and logs.
|
||||||
23
crates/github/README.md
Normal file
23
crates/github/README.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
## wrkflw-github
|
||||||
|
|
||||||
|
GitHub integration helpers used by `wrkflw` to list/trigger workflows.
|
||||||
|
|
||||||
|
- **List workflows** in `.github/workflows`
|
||||||
|
- **Trigger workflow_dispatch** events over the GitHub API
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use wrkflw_github::{get_repo_info, trigger_workflow};
|
||||||
|
|
||||||
|
# tokio_test::block_on(async {
|
||||||
|
let info = get_repo_info()?;
|
||||||
|
println!("{}/{} (default branch: {})", info.owner, info.repo, info.default_branch);
|
||||||
|
|
||||||
|
// Requires GITHUB_TOKEN in env
|
||||||
|
trigger_workflow("ci", Some("main"), None).await?;
|
||||||
|
# Ok::<_, Box<dyn std::error::Error>>(())
|
||||||
|
# })?;
|
||||||
|
```
|
||||||
|
|
||||||
|
Notes: set `GITHUB_TOKEN` with the `workflow` scope; only public repos are supported out-of-the-box.
|
||||||
23
crates/gitlab/README.md
Normal file
23
crates/gitlab/README.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
## wrkflw-gitlab
|
||||||
|
|
||||||
|
GitLab integration helpers used by `wrkflw` to trigger pipelines.
|
||||||
|
|
||||||
|
- Reads repo info from local git remote
|
||||||
|
- Triggers pipelines via GitLab API
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use wrkflw_gitlab::{get_repo_info, trigger_pipeline};
|
||||||
|
|
||||||
|
# tokio_test::block_on(async {
|
||||||
|
let info = get_repo_info()?;
|
||||||
|
println!("{}/{} (default branch: {})", info.namespace, info.project, info.default_branch);
|
||||||
|
|
||||||
|
// Requires GITLAB_TOKEN in env (api scope)
|
||||||
|
trigger_pipeline(Some("main"), None).await?;
|
||||||
|
# Ok::<_, Box<dyn std::error::Error>>(())
|
||||||
|
# })?;
|
||||||
|
```
|
||||||
|
|
||||||
|
Notes: looks for `.gitlab-ci.yml` in the repo root when listing pipelines.
|
||||||
22
crates/logging/README.md
Normal file
22
crates/logging/README.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
## wrkflw-logging
|
||||||
|
|
||||||
|
Lightweight in-memory logging with simple levels for TUI/CLI output.
|
||||||
|
|
||||||
|
- Thread-safe, timestamped messages
|
||||||
|
- Level filtering (Debug/Info/Warning/Error)
|
||||||
|
- Pluggable into UI for live log views
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use wrkflw_logging::{info, warning, error, LogLevel, set_log_level, get_logs};
|
||||||
|
|
||||||
|
set_log_level(LogLevel::Info);
|
||||||
|
info("starting");
|
||||||
|
warning("be careful");
|
||||||
|
error("boom");
|
||||||
|
|
||||||
|
for line in get_logs() {
|
||||||
|
println!("{}", line);
|
||||||
|
}
|
||||||
|
```
|
||||||
20
crates/matrix/README.md
Normal file
20
crates/matrix/README.md
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
## wrkflw-matrix
|
||||||
|
|
||||||
|
Matrix expansion utilities used to compute all job combinations and format labels.
|
||||||
|
|
||||||
|
- Supports `include`, `exclude`, `max-parallel`, and `fail-fast`
|
||||||
|
- Provides display helpers for UI/CLI
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use wrkflw_matrix::{MatrixConfig, expand_matrix};
|
||||||
|
use serde_yaml::Value;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
let mut cfg = MatrixConfig::default();
|
||||||
|
cfg.parameters.insert("os".into(), Value::from(vec!["ubuntu", "alpine"])) ;
|
||||||
|
|
||||||
|
let combos = expand_matrix(&cfg).expect("expand");
|
||||||
|
assert!(!combos.is_empty());
|
||||||
|
```
|
||||||
16
crates/models/README.md
Normal file
16
crates/models/README.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
## wrkflw-models
|
||||||
|
|
||||||
|
Common data structures shared across crates.
|
||||||
|
|
||||||
|
- `ValidationResult` for structural/semantic checks
|
||||||
|
- GitLab pipeline models (serde types)
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use wrkflw_models::ValidationResult;
|
||||||
|
|
||||||
|
let mut res = ValidationResult::new();
|
||||||
|
res.add_issue("missing jobs".into());
|
||||||
|
assert!(!res.is_valid);
|
||||||
|
```
|
||||||
13
crates/parser/README.md
Normal file
13
crates/parser/README.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
## wrkflw-parser
|
||||||
|
|
||||||
|
Parsers and schema helpers for GitHub/GitLab workflow files.
|
||||||
|
|
||||||
|
- GitHub Actions workflow parsing and JSON Schema validation
|
||||||
|
- GitLab CI parsing helpers
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```rust
|
||||||
|
// High-level crates (`wrkflw` and `wrkflw-executor`) wrap parser usage.
|
||||||
|
// Use those unless you are extending parsing behavior directly.
|
||||||
|
```
|
||||||
13
crates/runtime/README.md
Normal file
13
crates/runtime/README.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
## wrkflw-runtime
|
||||||
|
|
||||||
|
Runtime abstractions for executing steps in containers or emulation.
|
||||||
|
|
||||||
|
- Container management primitives used by the executor
|
||||||
|
- Emulation mode helpers (run on host without containers)
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```rust
|
||||||
|
// This crate is primarily consumed by `wrkflw-executor`.
|
||||||
|
// Prefer using the executor API instead of calling runtime directly.
|
||||||
|
```
|
||||||
23
crates/ui/README.md
Normal file
23
crates/ui/README.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
## wrkflw-ui
|
||||||
|
|
||||||
|
Terminal user interface for browsing workflows, running them, and viewing logs.
|
||||||
|
|
||||||
|
- Tabs: Workflows, Execution, Logs, Help
|
||||||
|
- Hotkeys: `1-4`, `Tab`, `Enter`, `r`, `R`, `t`, `v`, `e`, `q`, etc.
|
||||||
|
- Integrates with `wrkflw-executor` and `wrkflw-logging`
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use wrkflw_executor::RuntimeType;
|
||||||
|
use wrkflw_ui::run_wrkflw_tui;
|
||||||
|
|
||||||
|
# tokio_test::block_on(async {
|
||||||
|
let path = PathBuf::from(".github/workflows");
|
||||||
|
run_wrkflw_tui(Some(&path), RuntimeType::Docker, true, false).await?;
|
||||||
|
# Ok::<_, Box<dyn std::error::Error>>(())
|
||||||
|
# })?;
|
||||||
|
```
|
||||||
|
|
||||||
|
Most users should run the `wrkflw` binary and select TUI mode: `wrkflw tui`.
|
||||||
21
crates/utils/README.md
Normal file
21
crates/utils/README.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
## wrkflw-utils
|
||||||
|
|
||||||
|
Shared helpers used across crates.
|
||||||
|
|
||||||
|
- Workflow file detection (`.github/workflows/*.yml`, `.gitlab-ci.yml`)
|
||||||
|
- File-descriptor redirection utilities for silencing noisy subprocess output
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use std::path::Path;
|
||||||
|
use wrkflw_utils::{is_workflow_file, fd::with_stderr_to_null};
|
||||||
|
|
||||||
|
assert!(is_workflow_file(Path::new(".github/workflows/ci.yml")));
|
||||||
|
|
||||||
|
let value = with_stderr_to_null(|| {
|
||||||
|
eprintln!("this is hidden");
|
||||||
|
42
|
||||||
|
}).unwrap();
|
||||||
|
assert_eq!(value, 42);
|
||||||
|
```
|
||||||
29
crates/validators/README.md
Normal file
29
crates/validators/README.md
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
## wrkflw-validators
|
||||||
|
|
||||||
|
Validation utilities for workflows and steps.
|
||||||
|
|
||||||
|
- Validates GitHub Actions sections: jobs, steps, actions references, triggers
|
||||||
|
- GitLab pipeline validation helpers
|
||||||
|
- Matrix-specific validation
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use serde_yaml::Value;
|
||||||
|
use wrkflw_models::ValidationResult;
|
||||||
|
use wrkflw_validators::{validate_jobs, validate_triggers};
|
||||||
|
|
||||||
|
let yaml: Value = serde_yaml::from_str(r#"name: demo
|
||||||
|
on: [workflow_dispatch]
|
||||||
|
jobs: { build: { runs-on: ubuntu-latest, steps: [] } }
|
||||||
|
"#).unwrap();
|
||||||
|
|
||||||
|
let mut res = ValidationResult::new();
|
||||||
|
if let Some(on) = yaml.get("on") {
|
||||||
|
validate_triggers(on, &mut res);
|
||||||
|
}
|
||||||
|
if let Some(jobs) = yaml.get("jobs") {
|
||||||
|
validate_jobs(jobs, &mut res);
|
||||||
|
}
|
||||||
|
assert!(res.is_valid);
|
||||||
|
```
|
||||||
108
crates/wrkflw/README.md
Normal file
108
crates/wrkflw/README.md
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
## WRKFLW (CLI and Library)
|
||||||
|
|
||||||
|
This crate provides the `wrkflw` command-line interface and a thin library surface that ties together all WRKFLW subcrates. It lets you validate and execute GitHub Actions workflows and GitLab CI pipelines locally, with a built-in TUI for an interactive experience.
|
||||||
|
|
||||||
|
- **Validate**: Lints structure and common mistakes in workflow/pipeline files
|
||||||
|
- **Run**: Executes jobs locally using Docker, Podman, or emulation (no containers)
|
||||||
|
- **TUI**: Interactive terminal UI for browsing workflows, running, and viewing logs
|
||||||
|
- **Trigger**: Manually trigger remote runs on GitHub/GitLab
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo install wrkflw
|
||||||
|
```
|
||||||
|
|
||||||
|
### Quick start
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Launch the TUI (auto-loads .github/workflows)
|
||||||
|
wrkflw
|
||||||
|
|
||||||
|
# Validate all workflows in the default directory
|
||||||
|
wrkflw validate
|
||||||
|
|
||||||
|
# Validate a specific file or directory
|
||||||
|
wrkflw validate .github/workflows/ci.yml
|
||||||
|
wrkflw validate path/to/workflows
|
||||||
|
|
||||||
|
# Run a workflow (Docker by default)
|
||||||
|
wrkflw run .github/workflows/ci.yml
|
||||||
|
|
||||||
|
# Use Podman or emulation instead of Docker
|
||||||
|
wrkflw run --runtime podman .github/workflows/ci.yml
|
||||||
|
wrkflw run --runtime emulation .github/workflows/ci.yml
|
||||||
|
|
||||||
|
# Open the TUI explicitly
|
||||||
|
wrkflw tui
|
||||||
|
wrkflw tui --runtime podman
|
||||||
|
```
|
||||||
|
|
||||||
|
### Commands
|
||||||
|
|
||||||
|
- **validate**: Validate a workflow/pipeline file or directory
|
||||||
|
- GitHub (default): `.github/workflows/*.yml`
|
||||||
|
- GitLab: `.gitlab-ci.yml` or files ending with `gitlab-ci.yml`
|
||||||
|
- Exit code behavior (by default): `1` when validation failures are detected
|
||||||
|
- Flags: `--gitlab`, `--exit-code`, `--no-exit-code`, `--verbose`
|
||||||
|
|
||||||
|
- **run**: Execute a workflow or pipeline locally
|
||||||
|
- Runtimes: `docker` (default), `podman`, `emulation`
|
||||||
|
- Flags: `--runtime`, `--preserve-containers-on-failure`, `--gitlab`, `--verbose`
|
||||||
|
|
||||||
|
- **tui**: Interactive terminal interface
|
||||||
|
- Browse workflows, execute, and inspect logs and job details
|
||||||
|
|
||||||
|
- **trigger**: Trigger a GitHub workflow (requires `GITHUB_TOKEN`)
|
||||||
|
- **trigger-gitlab**: Trigger a GitLab pipeline (requires `GITLAB_TOKEN`)
|
||||||
|
- **list**: Show detected workflows and pipelines in the repo
|
||||||
|
|
||||||
|
### Environment variables
|
||||||
|
|
||||||
|
- **GITHUB_TOKEN**: Required for `trigger` when calling GitHub
|
||||||
|
- **GITLAB_TOKEN**: Required for `trigger-gitlab` (api scope)
|
||||||
|
|
||||||
|
### Exit codes
|
||||||
|
|
||||||
|
- `validate`: `0` if all pass; `1` if any fail (unless `--no-exit-code`)
|
||||||
|
- `run`: `0` on success, `1` if execution fails
|
||||||
|
|
||||||
|
### Library usage
|
||||||
|
|
||||||
|
This crate re-exports subcrates for convenience if you want to embed functionality:
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use std::path::Path;
|
||||||
|
use wrkflw::executor::{execute_workflow, ExecutionConfig, RuntimeType};
|
||||||
|
|
||||||
|
# tokio_test::block_on(async {
|
||||||
|
let cfg = ExecutionConfig {
|
||||||
|
runtime_type: RuntimeType::Docker,
|
||||||
|
verbose: true,
|
||||||
|
preserve_containers_on_failure: false,
|
||||||
|
};
|
||||||
|
let result = execute_workflow(Path::new(".github/workflows/ci.yml"), cfg).await?;
|
||||||
|
println!("status: {:?}", result.summary_status);
|
||||||
|
# Ok::<_, Box<dyn std::error::Error>>(())
|
||||||
|
# })?;
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also run the TUI programmatically:
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use wrkflw::executor::RuntimeType;
|
||||||
|
use wrkflw::ui::run_wrkflw_tui;
|
||||||
|
|
||||||
|
# tokio_test::block_on(async {
|
||||||
|
let path = PathBuf::from(".github/workflows");
|
||||||
|
run_wrkflw_tui(Some(&path), RuntimeType::Docker, true, false).await?;
|
||||||
|
# Ok::<_, Box<dyn std::error::Error>>(())
|
||||||
|
# })?;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Notes
|
||||||
|
|
||||||
|
- See the repository root README for feature details, limitations, and a full walkthrough.
|
||||||
|
- Service containers and advanced Actions features are best supported in Docker/Podman modes.
|
||||||
|
- Emulation mode skips containerized steps and runs commands on the host.
|
||||||
Reference in New Issue
Block a user