Skip to content
Merged
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
47 changes: 24 additions & 23 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
# Working on `ruby-gem-release`

Read [CONTRIBUTING.md](CONTRIBUTING.md) and [DESIGN.md](DESIGN.md). This project provides GitHub Actions interfaces and Ruby release tasks, not a general-purpose release service.

Every release action and callback must be idempotent for the same checkout and inputs. Reconcile its own outputs: rebuild reproducibly, accept published gems only on matching checksums, preserve immutable Git tags, and replace mutable hosted notes/assets. Test accepted-but-response-lost outcomes. Preserve artifacts before publication for manual inspection; do not introduce recovery flags, artifact discovery, state restoration, or a completion journal.

The reusable workflow belongs in `.github/workflows/`, the gem API and Rake tasks belong in `lib/` and `tasks/`, and focused RSpec examples belong in `spec/`. Support Ruby 3.3 and newer; use public RubyGems, Rake, GitHub Actions, and RubyGems Trusted Publishing interfaces.

Keep release orchestration reusable while leaving project-specific preparation and version bump commands configurable by the calling repository. Test task behavior with focused unit tests and execute both interfaces' callback commands in real consumers with local Git remotes and isolated package and hosting publication. Consumer tests do not validate live Actions authentication or artifact uploads; never dispatch a publishing workflow from PR CI.

Keep orchestration permutations and YAML assertions in focused source specs (`bundle exec rake spec:unit`). Keep real-process smoke coverage in `spec/integration/`, including the portable consumers; do not stub their transport or installed-gem loading. CI runs source tests and installed-gem integration separately, without repeating the full integration suite against source. Profile before and after changes to the harness instead of assuming a speedup.

Keep semantic releases opt-in. Calculate from reachable released tags, not development versions; persist one immutable decision across processes, preserve it when recording the next version, and never reanalyze during preparation or publication. Preserve manual workflow defaults and publication guards. Semantic consumer fixtures must verify success, publication failure, and empty-release rejection against the installed artifact without real publication.

The root `action.yml` exposes the same Ruby tasks as a composite action. Keep both interfaces consistent without making version-pinned workflows depend on moving action references: pin every external action and reusable workflow to a full commit SHA with its version as a trailing comment, never a tag or branch. Action callers own job permissions, runner, environment, and concurrency. Preserve authentication selection and failure-aware artifact preservation; run installed-artifact consumer CI and `actionlint .github/workflows/*.yml examples/.github/workflows/*.yml` when changing YAML interfaces.

Run `bundle exec rake` locally for specs and RuboCop before every push, and `bundle exec rake build` for package construction when applicable. Danger checks the changelog in PR CI, not as a routine local command. Document user-visible changes in `CHANGELOG.md`, listing entries within each release chronologically and keeping `- Your contribution here.` as the last entry in the next-release section; keep Markdown paragraphs on one source line.

The normal RuboCop command checks prose, Markdown Ruby examples, spelling, and YAML through `rubocop-prose`, `rubocop-md`, `rubocop-spellcheck`, and `rubocop-yaml`. Fix typos rather than suppressing checks; keep reviewed project vocabulary in `.spellcheck.txt` alongside the bundled English dictionary.

Preserve the logo asset and its provenance, README placement, and rendering checks described in [DESIGN.md](DESIGN.md).

Preserve unrelated worktree changes. Use a separate worktree for each PR with a `dblock/<topic>` branch from `master`, keeping the primary checkout on `master` when clean. Keep one coherent commit per PR; amend it when making updates and use `git push --force-with-lease` for the topic branch when needed. Use squash or rebase merges, not merge commits. Ordinary development changes require PRs; explicitly authorized release automation may push release preparation and next development iteration commits directly without PRs. Never force-push to `master`. Do not merge, publish, or create release tags without authorization.

After a PR merges, clean up its local worktree and branch when no longer needed: verify the merged PR, inspect for uncommitted changes and dependent work, remove only clean worktrees, and delete the branch only when no work would be lost. Never discard changes to perform cleanup.
Read [CONTRIBUTING.md](CONTRIBUTING.md) for setup, commands, tests, and PR rules, and [DESIGN.md](DESIGN.md) for the design. This project provides GitHub Actions interfaces and Ruby release tasks, not a general-purpose release service.

## Rules to Keep

Do not break these:

- The reusable workflow lives in `.github/workflows/`, the gem API and Rake tasks in `lib/` and `tasks/`, and specs in `spec/`. The root `action.yml` exposes the same tasks as a composite action.
- Support Ruby 3.3 and newer. Use only public RubyGems, Rake, GitHub Actions, and Trusted Publishing interfaces.
- Keep orchestration reusable; calling repositories configure their own preparation and version bump commands.
- Every release action and callback follows the [rerun rules](RELEASING.md#verify-and-recover). Do not add recovery flags, artifact discovery, state restoration, or a completion journal.
- Keep semantic releases opt-in. Versions come from reachable release tags, not development versions. Record one immutable decision, keep it when recording the next version, and never reanalyze during preparation or publication.
- Keep the manual workflow defaults and publication guards unchanged.
- Keep the reusable workflow and composite action consistent. Pin every external action and reusable workflow to a full commit SHA with a trailing version comment, never a tag or branch.
- Keep authentication selection and artifact upload on failure working.
- Do not stub environment exports or installed-gem loading in the portable consumer specs.
- Profile the test harness before and after changing it; do not assume a speedup.
- Keep the logo, its provenance, and its README placement as described in [DESIGN.md](DESIGN.md#self-release-and-artwork).

## Safety

- Never dispatch a publishing workflow from PR CI.
- Do not merge, publish, or create release tags without authorization.
- Never force-push `master`.
- Preserve unrelated worktree changes, and never discard changes to clean up.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [#91](https://github.com/dblock/ruby-gem-release/pull/91): Accept an Intridea Next section with release notes but no contribution placeholder, rejecting a placeholder marked differently from the configured one - [@dblock](https://github.com/dblock).
- [#92](https://github.com/dblock/ruby-gem-release/pull/92): Document manual recovery from the preserved bundle when the default branch advances during publication - [@dblock](https://github.com/dblock).
- [#93](https://github.com/dblock/ruby-gem-release/pull/93): Document disabling the local Bundler `release` tasks so the workflow is the only release path - [@dblock](https://github.com/dblock).
- [#95](https://github.com/dblock/ruby-gem-release/pull/95): Rewrite the documentation in plain language, consolidating repeated rules so each lives in one place - [@dblock](https://github.com/dblock).
- Your contribution here.

## 0.9.0 (2026/11/20)
Expand Down
78 changes: 62 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,83 @@
# Contributing

Create a topic branch from `master` and keep each pull request focused on one coherent change.
Make one focused change per pull request.

Use a separate worktree for each PR with a `dblock/<topic>` branch, keeping the primary checkout on `master` when clean. Ordinary development changes go through PRs. Authorized release automation is an exception: release preparation and next development iteration commits may be pushed directly without PRs. The default-branch ruleset blocks force pushes and deletion but does not enforce PRs, allowing release automation and other writers to make fast-forward pushes.

After a PR merges, verify its merged state and check for uncommitted changes and dependent work before removing its clean, unneeded worktree and local branch. Do not discard work to clean up.
- Use a separate worktree for each PR, on a `dblock/<topic>` branch from `master`. Keep the primary checkout on `master` when it is clean.
- Ordinary changes go through PRs. Only authorized release automation pushes directly, for release and next development commits. The default-branch ruleset blocks force pushes and deletion but does not require PRs, so release automation and other writers can push fast-forward commits.
- After a PR merges, confirm it merged and check for uncommitted changes and dependent work. Then remove the clean worktree and local branch. Never discard work to clean up.

## Setup and Validation

Ruby 3.3 or newer is supported. Install dependencies with `bundle install`, run the specs and RuboCop locally with `bundle exec rake` before every push, and construct the gem with `bundle exec rake build` when applicable. Danger checks the changelog in PR CI rather than as a routine local command.
Ruby 3.3 or newer is supported.

```sh
bundle install
bundle exec rake
bundle exec rake build
```

`bundle exec rake` runs the specs and RuboCop; run it before every push. `bundle exec rake build` builds the gem when packaging changes. Danger checks the changelog in PR CI; you do not run it locally.

RuboCop includes Markdown prose checks with `rubocop-prose`, Ruby code block checks with `rubocop-md`, spelling checks with `rubocop-spellcheck`, and YAML checks with `rubocop-yaml`. Keep paragraphs on one source line, fix spelling mistakes, and add reviewed project vocabulary to `.spellcheck.txt`. Repository spelling checks cover comments and documentation, not Ruby strings; the standard license text is excluded from spelling and paragraph-length checks.
RuboCop also checks documentation and YAML:

Danger uses the reusable [danger-pr-comment](https://github.com/danger/danger-pr-comment) workflows. The read-only pull request job checks out full history and uses the default `danger dry_run` command, exporting a report instead of posting comments. A separate `workflow_run` job posts the report without checking out or executing contribution code. It does not create a comment for an empty report, but always updates an existing report comment. Keep full history available for fork commits and their merge base; the commenting workflow must be on `master` before it can respond to completed runs.
- `rubocop-prose` checks Markdown prose.
- `rubocop-md` checks Ruby code blocks in Markdown.
- `rubocop-spellcheck` checks spelling in comments and documentation, not Ruby strings.
- `rubocop-yaml` checks YAML.

Keep each paragraph on one source line. Fix spelling mistakes; add only reviewed project words to `.spellcheck.txt`. The license text is excluded from spelling and paragraph-length checks.

Danger runs through the reusable [danger-pr-comment](https://github.com/danger/danger-pr-comment) workflows. A read-only PR job checks out full history and runs `danger dry_run`, which saves a report instead of commenting. A separate `workflow_run` job posts the report without checking out or running contributed code. It skips empty reports but always updates an existing report comment. Keep full history so fork commits and their merge base are available. The commenting workflow only responds once it is on `master`.

## Tests

Idempotence is required for every release action, including custom callbacks. Reconcile each task's own outputs using its current checkout and inputs; replace mutable outputs, but reject immutable checksum or tag conflicts. Cover response-lost success, repetition, and conflicts. Do not add recovery flags, artifact discovery, state restoration, or a completion journal.
Every release action must follow the [rerun rules](RELEASING.md#verify-and-recover). Test success with a lost response, reruns, and checksum or tag conflicts.

Specs live in `spec/`. Add focused specs for task behavior, and use real consumer projects to run the commands of the reusable workflow and composite action. Coverage reports (HTML and LCOV) go to `coverage/`, and CI uploads them to Coveralls.

RSpec examples live in `spec/`; add focused examples for release-task behavior and use real consumers to execute the reusable workflow and composite action's callback commands. Specs write HTML and LCOV coverage reports under `coverage/`, which CI uploads to Coveralls.
| Command | Runs |
| --- | --- |
| `bundle exec rake spec:unit` | Source specs, excluding `spec/integration/`. Run by the Test workflow. |
| `bundle exec rake spec:integration` | Consumer integration specs. CI runs them on the installed gem. |
| `bundle exec rake spec` | The full suite, in parallel. |
| `bundle exec rake spec:serial` | The full suite, serially. |
| `bundle exec rake` | The full suite plus RuboCop. |

Run focused source tests with `bundle exec rake spec:unit`, which excludes `spec/integration/`. This includes in-process Rake coverage of documented configurations, timezone and version behavior, and lightweight YAML and shell-contract checks without creating consumer repositories. The Test workflow runs this task; installed-gem CI runs `bundle exec rake spec:integration` so consumer integration is not repeated against source in CI. `bundle exec rake spec` and the default task still run the complete suite locally.
Unit specs cover documented configurations, timezone and version behavior, and YAML and shell contracts in-process, without creating consumer repositories. CI does not run integration specs against source.

Consumer integration specs live in the `composite`, `workflow`, and `consumer` directories under `spec/integration/`; CI runs each directory as an explicit matrix entry for each supported Ruby version. Keep a small real-process matrix covering both Actions interfaces' success, failure/recovery, empty-release rejection, custom registry, and credential propagation. Preserve the provider-neutral consumers across separate processes: they verify environment transport, private state, and installed-library loading. Stub orchestration boundaries in focused specs, not these smoke tests. Existing domain specs cover detailed format, version, timezone, Git, and authentication edge cases without repeating whole release pipelines.
`spec` and `spec:integration` run spec files in parallel with `parallel_tests` and merge coverage at the end. Workers default to the number of processors.

`bundle exec rake spec` and `spec:integration` run independent spec files concurrently with `parallel_tests`; coverage reports are generated once, after all workers finish. Workers default to the available processors. Set `PARALLEL_TEST_PROCESSORS=2` to limit workers, or use `bundle exec rake spec:serial` for a serial full-suite run. `SPEC=spec/path_spec.rb` selects files and `SPEC_OPTS='--seed 12345'` passes RSpec options.
- `PARALLEL_TEST_PROCESSORS=2` limits workers.
- `SPEC=spec/path_spec.rb` selects files.
- `SPEC_OPTS='--seed 12345'` passes RSpec options.

Run one integration suite locally with, for example, `SPEC='spec/integration/consumer/**/*_spec.rb' bundle exec rake spec:integration`. CI runs the same selectors against the installed gem, so add new integration specs to one of these directories; files elsewhere under `spec/integration/` run locally but not in CI.
### Integration Specs

Profile integration examples with `bundle exec rake spec:integration SPEC_OPTS='--profile 15 --seed 12345'`. Compare before and after on the same machine and Ruby, including subprocess counts when changing the harness; do not enforce environment-dependent timing thresholds.
Integration specs live in `spec/integration/composite`, `spec/integration/workflow`, and `spec/integration/consumer`. CI runs each directory as a matrix entry per supported Ruby. Put new integration specs in one of these directories; files elsewhere run locally but not in CI. Run one suite with:

The release integration workflow builds and installs the actual gem, then exercises both interfaces' callback commands with real local Git pushes and isolated RubyGems and GitHub publication boundaries. Tests verify release and next development iteration commits, artifact identity, and publication ordering without publishing packages or creating hosted releases. They do not execute live Actions authentication or artifact uploading. Preserve authentication selection and failure-aware artifact upload when changing either interface. Validate workflow examples with `actionlint .github/workflows/*.yml examples/.github/workflows/*.yml`.
```sh
SPEC='spec/integration/consumer/**/*_spec.rb' bundle exec rake spec:integration
```

Keep this real-process matrix small. It covers both Actions interfaces: success, failure and recovery, empty-release rejection, a custom registry, and credential propagation. Keep the provider-neutral consumers running across separate processes; they check environment exports, private state, and loading the installed gem. Semantic consumer fixtures cover success, publication failure, and empty-release rejection against the installed gem. Stub orchestration in focused specs, not in these smoke tests. Domain specs cover format, version, timezone, Git, and authentication edge cases.

The release integration workflow builds and installs the real gem. It runs both interfaces' commands with real pushes to local Git remotes and fake RubyGems and GitHub publication; unexpected network requests fail. Tests check release and next development commits, artifact identity, and publication order, without publishing anything. They do not test live Actions authentication or artifact upload, so preserve authentication selection and upload-on-failure behavior when you change either interface. When you change YAML interfaces, check installed-gem consumer CI and validate the workflows with:

```sh
actionlint .github/workflows/*.yml examples/.github/workflows/*.yml
```

To profile integration specs, run the command below. Compare before and after on the same machine and Ruby, including subprocess counts when you change the harness. Do not enforce timing thresholds.

```sh
bundle exec rake spec:integration SPEC_OPTS='--profile 15 --seed 12345'
```

## Pull Requests

Keep one coherent commit per PR; amend updates and use `git push --force-with-lease` on the topic branch. Squash and rebase merges are supported; merge commits are disabled. Update affected documentation and append notable changes to the current Next changelog section with the PR link and author attribution, above `- Your contribution here.`. Keep Markdown paragraphs on one line. See [RELEASING.md](RELEASING.md).
- Keep one coherent commit per PR. Amend it and push with `git push --force-with-lease` on the topic branch.
- Squash and rebase merges are allowed; merge commits are disabled.
- Update affected documentation.
- Add user-visible changes to the Next section of `CHANGELOG.md`, oldest first, with the PR link and author, above `- Your contribution here.`, which stays last.

See [RELEASING.md](RELEASING.md) for releases.
Loading
Loading