cargo-run 0.6.0

A powerful, fast, and developer-friendly CLI tool for managing project scripts in Rust. Workspace-aware, cargo-script ready, with hooks, parallel execution, watch mode, and CI/CD templates.
Documentation
//! GitHub Actions CI template.

use super::{Template, TemplateFile};

const SCRIPTS_TOML: &str = r#"# Generated by `cargo script init --template github-actions`
[global_env]
RUST_BACKTRACE = "1"

[scripts]
ci          = { include = ["fmt-check", "lint", "test", "build"], info = "Full CI pipeline" }
fmt-check   = { command = "cargo fmt --all -- --check", info = "Verify formatting" }
fmt         = { command = "cargo fmt --all", info = "Auto-format the project" }
lint        = { command = "cargo clippy --all-targets --all-features -- -D warnings", info = "Run clippy with warnings as errors" }
test        = { command = "cargo test --all-features", info = "Run the test suite" }
build       = { command = "cargo build --release", info = "Release build" }
doc         = { command = "cargo doc --no-deps --all-features", info = "Build documentation" }
audit       = { command = "cargo audit", requires = ["cargo-audit"], info = "Security audit (needs cargo-audit)" }
"#;

const CI_WORKFLOW: &str = r#"# Generated by `cargo script init --template github-actions`
name: CI
on:
  push:
    branches: [main, master]
  pull_request:

jobs:
  ci:
    name: CI (${{ matrix.os }} / ${{ matrix.toolchain }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        toolchain: [stable]
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.toolchain }}
          components: rustfmt, clippy
      - uses: Swatinem/rust-cache@v2
      - name: Install cargo-run
        run: cargo install cargo-run
      - name: Run CI pipeline
        run: cargo script ci
"#;

pub const TEMPLATE: Template = Template {
    name: "github-actions",
    description: "Scripts.toml + .github/workflows/ci.yml for a GitHub-hosted CI pipeline",
    files: &[
        TemplateFile { path: "Scripts.toml", contents: SCRIPTS_TOML },
        TemplateFile { path: ".github/workflows/ci.yml", contents: CI_WORKFLOW },
    ],
};