Github workflows

From d-o-hub/rust-self-learning-memory · View interactive version

Github workflows is an AI agent skill from the GitHub repository d-o-hub/rust-self-learning-memory. Diagnose, fix, and optimize GitHub Actions workflows for Rust projects. Use when setting up CI/CD, troubleshooting workflow failures, optimizing build times, or ensuring best practices.

How to use this skill

Skill file

GitHub Workflows

Diagnose, fix, and optimize GitHub Actions workflows for Rust projects.

Quick Reference

When to Use

Before Making Changes

ALWAYS verify current state first:

# Get repo info
gh repo view --json nameWithOwner,owner,name

# List existing workflows
gh workflow list

# Check recent runs
gh run list --limit 10

# View workflow files
ls -la .github/workflows/

Complete Rust CI Workflow

See the full workflow template with:

See linked files for caching strategies, troubleshooting, and release management.

Core Workflow Components

| Job | Purpose | Tools |

|-----|---------|-------|

| check | Code quality | rustfmt, clippy, cargo check |

| test | Verification | cargo test |

| coverage | Test metrics | cargo tarpaulin |

| audit | Security | cargo audit, deny |

Common Patterns

Toolchain Pinning Guardrail

nightly broke a transitive dependency (branches 0.4.5, core::intrinsics)

with no repository change and failed every fuzz target as a startup failure;

floating stable similarly adds deny-by-default lints between releases.

dtolnay/rust-toolchain action input, comment why, and validate the pin by

building the affected crate with that toolchain before pushing (LESSON-040).

Composite Input Truthiness Guardrail

caller passes a rendered boolean, and GitHub coerces any non-empty string to

true — so !"false" is false. if: ${{ !inputs.dry-run }} therefore skips

the step on every real run while the job reports success (LESSON-053). Blast

radius, measured from the crates.io index on 2026-10-16: do-memory-core /

-storage-redb / -storage-turso were last published at 0.1.34 and

do-memory-mcp at 0.1.31, while tags ran to v0.1.45 — i.e. roughly a

dozen green releases published nothing, not one or two.

value crosses a boundary: a workflow_dispatch input declared type: boolean

is a real boolean in the calling workflow's if:, while a composite action input

declared without type: (.github/actions/publish-crate/action.yml:15,

default: "false") arrives as a string — and any non-empty string is truthy

in the if: expression language, so !inputs.dry-run is !"false" = false and

the step silently never runs:

```diff

# .github/actions/publish-crate/action.yml — the real publish step (line 197 at v0.1.45)

# after (#1179): negate the string form, like the two correct siblings already did

```

The workflow-level guard (inputs.dry-run == true || github.ref_type == 'tag')

(publish-crates.yml:47) was correct all along and is not the bug — which is

precisely why the chain stayed green: the outer guard passed, the inner step skipped.

Tag-only authority + OIDC still applies (ADR-072/ADR-078, never a static token).

Add the per-crate selector (inputs.crate == '' || inputs.crate == '<name>')

and keep one comparison form across all steps of the action: the broken file

compared correctly on two steps and negated on the third, which is why the skip

survived review. Prefer fromJSON() (or rendering the boolean once into a step

output) over hand-matching stringified booleans.

scripts/test-release-workflow.sh --publish-fixtures (it already fails the chain

for a missing bounded poll or verification step) with a check for the exact

comparison form, and let scripts/validate-gate-contract.sh reject any !inputs.

negation in the publish files. A guard nobody can grep is a guard that regresses.

effect is skipped. Read the step, not the rollup —

gh run view <id> --json jobs -q '.jobs[].steps[] | select(.name == "Publish to crates.io") | .conclusion'

and duration_ms=0 on that step is a failed release even when CI is green.

each crate's versions endpoint with the membership test below and ::error:: +

exit 1s when the published version is missing. Keep the post-release external

assert too (curl -sS -A ci-verify https://crates.io/api/v1/crates/<crate>/versions),

never a sleep-then-assume.

(core → redb → turso → mcp). do-memory-cli answering HTTP 404 is by design (it

ships as a GitHub Release asset) and do-memory-test-utils is publish = false —

neither is a publish failure, and both must be excluded from the expected set

rather than "fixed" by widening the gate. Always send a User-Agent: crates.io

rejects the default curl UA with FETCH_FAILED-shaped noise that looks like an

outage.

only applies to runs dispatched from refs that contain it (dispatching on a tag

uses the tag's copy, so a superseded tag keeps the old behaviour forever).

(publish, push, register) must poll the provider with a bounded loop

(for i in $(seq 1 20), sleep 15) and ::error:: out when the object is

missing. A green job is not evidence that an artifact exists.

full list ([(.versions // [])[].num] | index($v) != null) rather than

comparing the newest entry — [0] equality misreads a superseded-but-present

version as absent and flips a retry into a hard failure.

PR Check Attachment Guardrail

Trigger And Clock Guardrail

Read the whole on: block — a push filter includes tag patterns, so

nightly-tests.yml (cron: 0 2 * * * plus push: tags: ['v*.*.*'] plus

workflow_dispatch) also runs on every release tag. Name the real cause with

gh run view <id> --json event,triggerActor,runStartedAt, never by assuming the

schedule.

and a scheduled run re-attaches to whatever SHA is current (LESSON-051). Reason

from runStartedAt/updatedTime, never from the cron expression.

dispatch it and cite the run id —

gh workflow run nightly-tests.yml -f run_slow_tests=true then

gh run list --workflow nightly-tests.yml --event workflow_dispatch --limit 1.

[opened, synchronize, reopened, labeled, unlabeled]: edited is not a trigger,

so PR body/title edits are free, while every branch push (synchronize) restarts

the entire required suite. Batch docs/skills edits into one push instead of one

push per file (LESSON-052/LESSON-051 churn).

fires on labeled/synchronize, force it on a fresh head SHA

(git commit --allow-empty -m "chore: re-trigger CI" && git push) — never by

deleting runs, dropping a trigger, or weakening the gate to make it quiet.

Workflow Lint Guardrail

yamllint -c .yamllint.yml .github/, actionlint .github/workflows/*.yml, and

shellcheck on every run: block you touched.

the shellcheck path at an empty value disables actionlint's embedded shell

analysis, so shell bugs in workflow run: blocks pass CI green. Run shellcheck

yourself; the fix is never to delete the lint job or silence rules.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.