Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 25 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Release

on:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
BUILD_PROFILE: release
steps:
- uses: actions/checkout@v5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Pin actions/checkout to a commit SHA.

Apply the same immutability policy to first‑party actions.

-      - uses: actions/checkout@v5
+      - uses: actions/checkout@<COMMIT_SHA_FOR_V5>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: actions/checkout@v5
- uses: actions/checkout@<COMMIT_SHA_FOR_V5>
🤖 Prompt for AI Agents
In .github/workflows/release.yml at line 16, the workflow uses
actions/checkout@v5 which is a floating tag; replace it with an immutable commit
SHA for that action. Update the uses entry to the specific full commit SHA of
actions/checkout (e.g., actions/checkout@<commit-sha>) so the workflow is pinned
to a fixed version, ensuring immutability and reproducible runs.

- name: Setup Rust
uses: leynos/shared-actions/.github/actions/setup-rust@c6559452842af6a83b83429129dccaf910e34562
- name: Build
run: make release
- name: Upload release assets
uses: softprops/action-gh-release@v2

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Release' step
Uses Step
uses 'softprops/action-gh-release' with ref 'v2', not a pinned commit hash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha): An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.

Source: opengrep

with:
files: |
target/generated-man/wireframe.1
Comment on lines +19 to +25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Fail fast if the man page was not generated.

Add an existence check before the upload to surface build.rs or Makefile
issues early.

       - name: Build
         run: make release
+      - name: Verify generated man page exists
+        run: |
+          test -s target/generated-man/wireframe.1 \
+            || { echo "wireframe.1 missing"; exit 1; }
       - name: Upload release assets
         uses: softprops/action-gh-release@v2
         with:
           files: |
             target/generated-man/wireframe.1

#!/bin/bash
# Search for man page references
rg -n 'wireframe\.1' -n .
# Search for generated-man directory usage
rg -n 'generated-man' -n .
# Show Makefile rules for man page generation
fd '^Makefile$' -x sed -n '1,200p' Makefile
# Inspect build.rs if present for man page creation logic
fd 'build.rs' -x sed -n '1,200p' build.rs

🏁 Script executed:

#!/usr/bin/env bash
# Locate references to the generated man page
rg -n 'wireframe\.1' .
rg -n 'generated-man' .
# Inspect Makefile for man page generation rules
if [ -f Makefile ]; then
  sed -n '1,200p' Makefile
fi
# Inspect build.rs for man page creation logic
if [ -f build.rs ]; then
  sed -n '1,200p' build.rs
fi

Length of output: 2719


Fail fast if generated man page is missing
Add a check after the build step to abort if target/generated-man/wireframe.1 is absent or empty.

       - name: Build
         run: make release
+      - name: Verify generated man page exists
+        run: |
+          test -s target/generated-man/wireframe.1 \
+            || { echo "wireframe.1 missing"; exit 1; }
       - name: Upload release assets
         uses: softprops/action-gh-release@v2
         with:
           files: |
             target/generated-man/wireframe.1
🧰 Tools
🪛 GitHub Check: CodeQL

[warning] 22-22: Unpinned tag for a non-immutable Action in workflow
Unpinned 3rd party Action 'Release' step Uses Step uses 'softprops/action-gh-release' with ref 'v2', not a pinned commit hash

🤖 Prompt for AI Agents
.github/workflows/release.yml around lines 19 to 25: the workflow proceeds to
upload the generated man page without verifying it exists or is non-empty; add a
new step immediately after the Build step that runs a shell check to fail-fast
if target/generated-man/wireframe.1 is missing or zero-length (use test -s or
equivalent) and exit with a clear error message so the workflow aborts before
the upload step.

18 changes: 18 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ metrics = { version = "0.24.2", optional = true }
metrics-exporter-prometheus = { version = "0.17.2", optional = true, features = ["http-listener"] }
thiserror = "2.0.16"
static_assertions = "1"
clap = { version = "4.5", features = ["derive"] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Use caret requirements per dependency policy

Adopt caret SemVer ranges for new deps per repository rules.

Apply:

-clap = { version = "4.5", features = ["derive"] }
+clap = { version = "^4.5", features = ["derive"] }
-[build-dependencies]
-clap = { version = "4.5", features = ["derive"] }
-clap_mangen = "0.2"
+[build-dependencies]
+clap = { version = "^4.5", features = ["derive"] }
+clap_mangen = "^0.2"

Also applies to: 67-70

🤖 Prompt for AI Agents
In Cargo.toml around line 41 (and also lines 67-70), the dependency entries use
exact version strings; update them to use caret SemVer ranges per repo policy
(e.g., change version = "4.5" to version = "^4.5" or "^4.5.0" and apply the same
caret style to the dependencies on lines 67-70), keeping existing feature flags
intact.


[dev-dependencies]
rstest = "0.26.1"
Expand All @@ -63,6 +64,10 @@ tokio = { version = "1.47.1", default-features = false, features = [
"test-util",
] }

[build-dependencies]
clap = { version = "4.5", features = ["derive"] }
clap_mangen = "0.2"

[features]
default = ["metrics"]
metrics = ["dep:metrics", "dep:metrics-exporter-prometheus"]
Expand Down
24 changes: 24 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//! Build script generating manual pages from the CLI definition.
use std::{fs, path::PathBuf};

use clap::CommandFactory;
use clap_mangen::Man;

#[path = "src/cli.rs"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (complexity): Consider moving the CLI definition to the library and writing directly to the file to simplify build script logic.

Here’s one way to both remove the #[path] hack and simplify the write‐buffer dance, while keeping the exact same output:

  1. Move your CLI definition into your library (src/lib.rs) so it can be used by both main.rs and build.rs:
// src/lib.rs

use clap::CommandFactory;

mod cli;
pub use cli::Cli;

/// convenience constructor for build.rs
pub fn build_cli() -> clap::Command {
    Cli::command()
}
  1. In build.rs, import that function instead of shimming src/cli.rs, and write directly into the file:
// build.rs

use std::{fs, path::PathBuf};
use clap_mangen::Man;

// import your crate as a library
use mycrate::build_cli;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    println!("cargo:rerun-if-changed=src/cli.rs");

    let out_dir = PathBuf::from("target/generated-man");
    fs::create_dir_all(&out_dir)?;

    let mut file = fs::File::create(out_dir.join("wireframe.1"))?;
    Man::new(build_cli()).render(&mut file)?;

    Ok(())
}

Now you’ve

  • eliminated the #[path] shim
  • removed the intermediate Vec<u8>
  • kept all functionality intact and still auto‐regenerate on CLI changes.

mod cli;

fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("cargo:rerun-if-changed=src/cli.rs");

let out_dir = PathBuf::from("target/generated-man");
fs::create_dir_all(&out_dir)?;

let cmd = cli::Cli::command();
let man = Man::new(cmd);
let mut buf: Vec<u8> = Vec::new();
man.render(&mut buf)?;
Comment on lines +14 to +20

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Avoid writing build output into crate sources

The build script writes the generated man page to target/generated-man under the crate root. That path is writable in this repo, but build scripts also run when the crate is compiled as a dependency from crates.io, where the source directory is read-only. Creating or writing files there will fail and prevent dependent builds from succeeding. Build scripts should use the OUT_DIR provided by Cargo (and copy the resulting file in the release workflow if a stable path is required) so compilation works in all environments.

Useful? React with 👍 / 👎.

fs::write(out_dir.join("wireframe.1"), buf)?;

Comment on lines +14 to +22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Verify release workflow builds before upload

Ensure the release workflow compiles the crate (thus running build.rs) and uploads the expected artefact path.

Execute:

#!/bin/bash
set -euo pipefail

# Find release workflows
fd -t f -g ".github/workflows/*.yml" -x sh -c '
  echo "== {} ==";
  rg -n "cargo build" {} || true;
  rg -n "files:\s*target/generated-man/wireframe\.1" {} || true;
  rg -n "permissions:\s*[\r\n]+(\s*)contents:\s*write" {} || true
'

If the upload happens in a matrix or multi‑job workflow, gate the upload with needs: build and a path existence check to fail fast when the man page is missing.

🤖 Prompt for AI Agents
In build.rs around lines 14 to 22 the build script writes a generated man page
to target/generated-man/wireframe.1 but the release workflow may not run cargo
build (so build.rs won't execute) or may upload the wrong artifact path; update
the release workflow(s) to run cargo build (or cargo build --release) before the
upload step, ensure the upload 'files:' entry references
target/generated-man/wireframe.1 exactly, grant the workflow job
permissions.contents: write if using the actions/upload-release-asset action,
and if uploads run in a matrix or separate job, add needs: build and a
pre-upload check (fail-fast) that the file exists at
target/generated-man/wireframe.1 so the release job is skipped/failed if the man
page is missing.

Ok(())
}
9 changes: 9 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Command line interface

Wireframe includes a small command line interface for demonstration. The CLI
uses `clap` to parse arguments. An optional `--name` flag allows customising
the greeting printed by the `wireframe` binary.
Comment on lines +3 to +5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Adopt Oxford -ize spelling and wrap to 80 columns.

Replace -ise with -ize and reflow to respect the docs wrapping rule.

- Wireframe includes a small command line interface for demonstration. The CLI
- uses `clap` to parse arguments. An optional `--name` flag allows customising
- the greeting printed by the `wireframe` binary.
+ Wireframe includes a small command line interface for demonstration. The
+ CLI uses `clap` to parse arguments. An optional `--name` flag allows
+ customizing the greeting printed by the `wireframe` binary.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Wireframe includes a small command line interface for demonstration. The CLI
uses `clap` to parse arguments. An optional `--name` flag allows customising
the greeting printed by the `wireframe` binary.
Wireframe includes a small command line interface for demonstration. The
CLI uses `clap` to parse arguments. An optional `--name` flag allows
customizing the greeting printed by the `wireframe` binary.
🧰 Tools
🪛 LanguageTool

[style] ~4-~4: Would you like to use the Oxford spelling “customizing”? The spelling ‘customising’ is also correct.
Context: ...ments. An optional --name flag allows customising the greeting printed by the wireframe...

(OXFORD_SPELLING_Z_NOT_S)

🤖 Prompt for AI Agents
In docs/cli.md around lines 3 to 5, the text uses British -ise spelling and
exceeds the 80-column docs wrap rule; update occurrences of "-ise" to "-ize"
(e.g., "customising" → "customizing") and reflow the paragraph so no line
exceeds 80 characters while preserving sentence structure and punctuation.


Manual pages are generated during the build via `clap_mangen`. The `build.rs`
script writes `wireframe.1` to `target/generated-man`, and the `release` GitHub
workflow uploads this file.
Comment on lines +7 to +9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Link libraries inline and keep lines ≤80 chars.

Add inline links and reflow.

- Manual pages are generated during the build via `clap_mangen`. The `build.rs`
- script writes `wireframe.1` to `target/generated-man`, and the `release` GitHub
- workflow uploads this file.
+ Manual pages are generated during the build via
+ [`clap_mangen`](https://crates.io/crates/clap_mangen). The `build.rs` script
+ writes `wireframe.1` to `target/generated-man`, and the `release` GitHub
+ workflow uploads this file.

Add a minimal usage block after this paragraph:

```sh
# Run the CLI
cargo run -- -n Alice

# View the generated man page locally
man -l target/generated-man/wireframe.1

<details>
<summary>🤖 Prompt for AI Agents</summary>

In docs/cli.md around lines 7-9, the paragraph about manual page generation
needs inline links and reflow to 80 chars or less; replace bare clap_mangen
and release references with inline Markdown links to their respective
docs/repos, rewrap the sentence to keep each line ≤80 chars, and then insert a
minimal usage block immediately after the paragraph containing the
two-shell-command example that shows running the CLI (cargo run -- -n Alice) and
viewing the generated man page (man -l target/generated-man/wireframe.1).


</details>

<!-- fingerprinting:phantom:triton:chinchilla -->

<!-- This is an auto-generated comment by CodeRabbit -->

2 changes: 2 additions & 0 deletions docs/contents.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@ the-road-to-wireframe-1-0-feature-set-philosophy-and-capability-maturity.md
writing project documentation.
- [Server configuration](server/configuration.md) Tuning accept loop backoff
behaviour and builder options.
- [Command line interface](cli.md) Overview of CLI usage and man page
generation.
28 changes: 28 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//! Command line interface for the wireframe example binary.
//!
//! Provides a tiny CLI to demonstrate argument parsing and man page
//! generation.
Comment on lines +1 to +5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Tighten module docs to en‑GB hyphenation

Hyphenate “command‑line” in line with house style.

-//! Command line interface for the wireframe example binary.
+//! Command‑line interface for the Wireframe example binary.
 //!
-//! Provides a tiny CLI to demonstrate argument parsing and man page
-//! generation.
+//! Provides a tiny CLI to demonstrate argument parsing and man‑page generation.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
//! Command line interface for the wireframe example binary.
//!
//! Provides a tiny CLI to demonstrate argument parsing and man page
//! generation.
//! Command-line interface for the Wireframe example binary.
//
//! Provides a tiny CLI to demonstrate argument parsing and man-page generation.
🤖 Prompt for AI Agents
In src/cli.rs around lines 1 to 5, the module doc comment uses "Command line"
but our house style requires the en‑GB hyphenated form "Command-line"; update
the top doc line to read "Command-line interface for the wireframe example
binary." and ensure any other instances in this doc block follow the same
hyphenation.

use clap::Parser;

/// Command line arguments for the `wireframe` binary.
#[derive(Debug, Parser)]
#[command(name = "wireframe", version, about = "Example Wireframe binary")]
pub struct Cli {
/// Name to greet.
#[arg(short, long)]
pub name: Option<String>,
}
Comment on lines +8 to +15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Document a usage example in Rustdoc

Add a minimal example to aid cargo doc readers.

 /// Command line arguments for the `wireframe` binary.
 #[derive(Debug, Parser)]
 #[command(name = "wireframe", version, about = "Example Wireframe binary")]
 pub struct Cli {
@@
     pub name: Option<String>,
 }
+
+/// # Examples
+/// Run with a name:
+/// ```shell
+/// wireframe --name Sam
+/// ```
🤖 Prompt for AI Agents
In src/cli.rs around lines 8 to 15, add a Rustdoc usage example above the Cli
struct: include a short Examples section with a fenced shell code block showing
the command invocation (e.g., wireframe --name Sam) so cargo doc renders a
minimal usage example; ensure the example is in Rustdoc comment form (///) and
uses a ```sh fenced block.


#[cfg(test)]
mod tests {
use clap::Parser;

use super::Cli;

#[test]
fn parses_name_option() {
let cli = Cli::parse_from(["wireframe", "--name", "Sam"]);
assert_eq!(cli.name.as_deref(), Some("Sam"));
}
}
14 changes: 12 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
//! Minimal binary demonstrating `wireframe` usage.
//!
//! Currently prints a greeting and exits.
//! Parses CLI arguments and prints a greeting.

mod cli;

use clap::Parser;

fn main() {
// Enable structured logging for examples and integration tests.
// Applications embedding the library should install their own subscriber.
tracing_subscriber::fmt::init();
println!("Hello from Wireframe!");

let cli = cli::Cli::parse();
if let Some(name) = cli.name {
println!("Hello, {name} from Wireframe!");
} else {
println!("Hello from Wireframe!");
}
}
Loading