agentsclimarketplace

Rust ci deploy

Skill dawidpereira/rust-skills/skills/rust-ci-deploy

Curated Rust skill files for Claude Code: ownership, async, errors, types, architecture, DDD, and more

Install
npx -y skills add dawidpereira/rust-skills --skill rust-ci-deploy

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

CI pipelines, GitHub Actions, caching, cross-compilation, Docker builds, release automation, cargo-dist, cargo-audit, cargo-deny, static linking, musl. Trigger for CI/CD, deployment, and release tasks.

SKILL.md

6.4 KB, as published. Nobody here has run it

CI, Docker & Release

Core Question

How does this code get from a passing commit to a production artifact that users can trust?

Every merge should produce a verified, reproducible artifact. CI proves correctness, Docker packages the artifact, and release automation delivers it. If any stage is manual, it will eventually be skipped.


Error → Design Question

SymptomDon't Just SayAsk Instead
CI takes 15+ minutes"Use a faster runner"Are you caching the target directory and registry?
"linking failed" in CI"Install the library"Is the target platform's linker/libs installed?
Docker image is 1GB+"Use a smaller base"Are you using multi-stage builds with scratch/distroless?
Binary doesn't run on target"Recompile it"Are you compiling for the right target triple?
Vulnerability in dependency"Ignore the advisory"Is cargo-audit in CI, and is the advisory ignorable?
Release artifacts missing"Run the workflow again"Is the release workflow triggered on tags?

Quick Decisions

SituationReach ForWhy
Rust CI pipelinefmt check + clippy + test + auditOrdered by speed: fast failures first
Caching in GitHub ActionsSwatinem/rust-cache actionCaches target/ and registry automatically
Caching in GitLab CICache target/ and ~/.cargo/registryAvoids recompilation on every push
Testing all feature comboscargo hack check --feature-powersetCatches feature-gated compile errors
Cross-compiling CLI toolcross (Docker-based, multi-target)No manual toolchain setup per target
Static binary for Linuxx86_64-unknown-linux-musl targetNo glibc dependency, runs anywhere
Minimal Docker imageMulti-stage: rust:slim + scratch/distrolessBuilder compiles, runtime has only the binary
Automated releasescargo-dist for GitHub releasesBuilds binaries, generates installers
Changelog generationgit-cliff with conventional commitsDeterministic changelogs from git history
Crate publishingcargo publish with --dry-run in CICatches packaging errors before release
Dependency auditcargo audit in CI, fail on vulnsBlocks merges with known vulnerabilities
License compliancecargo deny check licensesPrevents accidental copyleft inclusion
Supply chain securitycargo deny check advisories + bansBlocks yanked or banned crates
MSRV verificationcargo hack check --rust-versionProves the declared MSRV actually works
Binary size optimizationstrip, LTO, opt-level = "z"Smaller downloads, faster cold starts

The CI Pipeline

Order matters. Each stage gates the next, and fast checks run first to minimize wasted compute:

  1. Format (cargo fmt --check) — instant, catches style drift before anything compiles.
  2. Lint (cargo clippy -- -D warnings) — catches logic issues and anti-patterns early.
  3. Test (cargo test) — proves correctness.
  4. Audit (cargo audit, cargo deny) — checks dependencies for vulnerabilities and license issues.
  5. Build (cargo build --release) — produces the artifact only after all checks pass.

If format fails, there is no point running tests. If tests fail, there is no point building a release.


Docker Multi-Stage Build

Separate compilation from runtime. The builder stage has the full toolchain; the runtime stage has only the binary:

FROM rust:1-slim AS builder
WORKDIR /app
COPY Cargo.toml Cargo.lock ./
RUN mkdir src && echo "fn main() {}" > src/main.rs
RUN cargo build --release && rm -rf src target/release/.fingerprint
COPY src ./src
RUN cargo build --release

FROM gcr.io/distroless/cc-debian12
COPY --from=builder /app/target/release/myapp /
ENTRYPOINT ["/myapp"]

The dummy-build trick caches dependencies as a separate layer. Source changes only rebuild app code.

See references/docker.md for musl static linking, .dockerignore, and health check patterns.


Caching Strategy

Cache these:

  • ~/.cargo/registry/index
  • ~/.cargo/registry/cache
  • target/

Never cache these:

  • ~/.cargo/registry/src (re-extracted from cache)
  • target/debug/incremental (not portable across CI)

Cache key: hash of Cargo.lock + Rust toolchain version. A lockfile change means dependency rebuild.

See references/ci.md for full cache configuration.


Usage Scenarios

Scenario 1: "I'm setting up CI for a new Rust project" → Start with fmt + clippy + test in GitHub Actions. Add Swatinem/rust-cache for caching. Add cargo-audit once dependencies stabilize. See references/ci.md for complete workflow YAML.

Scenario 2: "I need to deploy a Rust service in Docker" → Use a multi-stage Dockerfile with rust:slim as builder and distroless as runtime. Copy Cargo.toml first for layer caching. See references/docker.md for production patterns.

Scenario 3: "I want to release CLI binaries for multiple platforms" → Use cargo-dist to generate GitHub Actions workflows that build and upload binaries on tag push. Configure targets in Cargo.toml. See references/release.md for cargo-dist setup.

Scenario 4: "I need to audit dependencies for vulnerabilities" → Add cargo audit and cargo deny to CI. Configure deny.toml for license and advisory policies. See references/ci.md for deny.toml configuration.


Reference Files

FileRead When
references/ci.mdGitHub Actions workflow, GitLab CI, caching, cargo-deny, cargo-audit, MSRV testing
references/docker.mdMulti-stage Dockerfile, musl static linking, distroless, .dockerignore, Docker Compose
references/release.mdcargo-dist, git-cliff, cargo publish, versioning, binary optimization, cross-platform releases

Cross-References

WhenCheck
Cargo.toml defaults, clippy lint setuprust-quality → Quick Decisions
Release profile optimization, LTOrust-perf → Quick Decisions
Production observability in containersrust-tracing → Quick Decisions
Test organization for CIrust-tests → Quick Decisions

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.