Skip to content

About

Deterministic GitHub PR and CI lifecycle automation for AsterCommunity repositories

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

AsterCommunity Automation

Deterministic GitHub pull-request and CI lifecycle automation shared by AsterCommunity repositories.

The action owns reusable mechanics; each target repository owns its product-specific path, label, workflow, and diagnostic configuration in .github/aster-automation.json.

Capabilities

  • Idempotent changed-file labels while preserving human-owned labels; every entry point adds or removes only the labels it changes, never replacing the list.
  • Native closing-issue lifecycle synchronization through GitHub GraphQL relationships.
  • One aggregate Check Run for path-filtered workflows.
  • One separate PR Readiness Check Run for external checks, mergeability, draft state, current-head human review, and unresolved threads.
  • One update-in-place diagnostic comment per pull request HEAD.
  • Fingerprinted default-branch and scheduled CI incident Issues that accumulate recurrences, reopen after later regressions, and close after consecutive-success recovery; each event sweeps every completed run of its commit, so an event displaced by the per-SHA concurrency group is not lost. Each counted run is an append-only state record comment and the issue body is a summary derived from them, so concurrent events for different commits never overwrite each other's counts.
  • Scheduled open-PR reconciliation that repairs missed events, fork routing gaps, stale labels, readiness reports, and tracking-issue lifecycle.
  • Deterministic milestone release-readiness dashboards and repository workflow/pin contract validation.
  • Superseded-head cleanup and closed pull request recovery that terminate abandoned pending gates across the full PR history.
  • Configuration validation without runtime dependencies or generated bundles.
  • A shared clippy disallowed-methods contract that keeps raw SeaORM transaction, locking and error-inspection entry points behind their AsterForge replacements, gated by the locked aster_forge_db version.
  • An opt-in guard that rejects Rust code classifying errors by their message text, with reasoned, audited exemptions.
  • An opt-in guard that rejects test-only crate features, such as aster_forge_db/test-support, in the normal feature graph of a shipping build, naming the member and the dependency path that enables them.
  • Adoption issues in opt-in downstream repositories after an AsterForge release batch is published, one per repository and batch, with the crates to update, the upgrade command, breaking changes and the clippy contract entries the update starts to require.

Trust boundary

  • pull_request_target and workflow_run callers execute a commit-pinned copy of this action and checkout only the target repository's trusted default branch.
  • Pull request titles, bodies, paths, job names, logs, and links are data, never shell source.
  • The repository configuration is JSON, bounded to 256 KiB, validated before API writes, and constrained to GITHUB_WORKSPACE.
  • A GitHub App installation token is the intended production identity. A workflow GITHUB_TOKEN remains suitable during migration.
  • Models do not control merge, release, priority, security, or incident closure decisions.
  • Incident state records are trusted only from bot authors (GitHub Apps and github-actions); a record comment posted by a person is ignored, so anyone able to comment cannot change an incident's counts.

Usage

Copy and adapt examples/asterdrive.json to .github/aster-automation.json, then pin the action to an immutable commit:

- uses: AsterCommunity/aster-automation@FULL_COMMIT_SHA
  with:
    mode: pr-automation
    token: ${{ steps.app-token.outputs.token }}
    config-path: .github/aster-automation.json

Supported modes:

  • pr-automation

  • ci-diagnostics

  • pr-readiness

  • reconcile-repository

  • milestone-dashboard

  • sync-clippy-contract — from a scheduled default-branch run, opens or refreshes the aster-automation/clippy-contract pull request when the managed clippy.toml block is out of date, and closes it once the default branch is in sync

  • forge-adoption-issues — AsterForge only: run after a release batch is published, from a full-history checkout of the release commit. For every repository in forgeAdoption.subscribers whose default-branch Cargo.lock locks an older version of a published crate, opens one adoption issue (or updates the one for this release) listing those crates old → new, the CARGO_RESOLVER_INCOMPATIBLE_PUBLISH_AGE=allow cargo update -p ... command, the breaking and behavior changes, the clippy contract entries the new aster_forge_db version starts to require, and the other changelog entries of the batch; older adoption issues that are still open get one comment linking the new one. Set dry-run: true to print the issues without writing

  • check-test-only-features — runs the test-only feature guard on the workspace whose root Cargo.toml is the manifest-path input (absolute or relative to GITHUB_WORKSPACE), with every member shipping; for workspaces that exist only during the job, such as a project generated from a template. It reads no automation configuration

  • validate-config

  • validate-repository — additionally rejects path patterns in labels.rules and workflows that match no tracked file, so renamed or deleted directories cannot silently disable labels and CI triggers

  • validate-repository — additionally requires every workflows rule to describe exactly when its workflow runs for a pull request; see Workflow rules

  • validate-repository with clippyContract — additionally requires the managed block in the repository's clippy.toml to match contracts/clippy-disallowed-methods.json for the aster_forge_db version in Cargo.lock; run node scripts/clippy-contract.ts sync <repository> from the pinned revision to update it

  • validate-repository with messageClassificationGuard — additionally rejects Rust code that classifies errors by their message text; see Message classification guard

  • validate-repository with testOnlyFeatureGuard — additionally rejects test-only crate features in a shipping build; see Test-only feature guard

Workflow rules

PR Gate waits for every workflow in workflows whose paths match a changed file of the pull request, so each rule must say exactly when GitHub starts that workflow for a pull request. validate-repository reads the workflow file whose top-level name: is the rule's name and rejects, listing every mismatch of every rule:

  • a rule whose workflow has neither a pull_request nor a pull_request_target trigger (a tag-only release, a scheduled benchmark, a docs deploy): the gate would wait for it forever. Remove the rule; workflows that do not run for pull requests stay out of workflows (they can still be subscribed by CI Diagnostics);
  • a path only the workflow has: the gate would pass before that run finishes;
  • a path only the rule has: the gate would wait for a run that never starts;
  • several workflow files with the rule's name, and a trigger the reader cannot interpret (for example paths-ignore, which a rule cannot express).

Paths are compared as sets of the literal patterns, so order does not matter but equivalent spellings do. A workflow with both pull-request events runs for the union of their paths. A pull-request event without a paths filter runs for every pull request; its rule must be exactly "paths": ["**"], which matches every changed file. Branch and activity-type filters are not compared. The trigger is read without a YAML dependency, covering block and flow sequences, quoted scalars, comments, and anchors with aliases defined inside on: (paths: &paths on push, paths: *paths on pull_request).

Message classification guard

Deciding what an error means from its rendered text breaks silently: rewording a message, or user data inside one (an object key containing 429, a column named unique_…), changes retryability or the HTTP status without any compile error or test failure. Classify errors by their structure instead: a variant, an error kind, a status or error code, a constraint name the driver reports. Clippy's disallowed-methods cannot express this because str::contains is fine almost everywhere, so validate-repository runs a dedicated guard over the tracked .rs files matching the configured globs:

"messageClassificationGuard": {
  "paths": ["src/**/*.rs", "crates/*/src/**/*.rs"]
}

Every pattern must match at least one tracked Rust file. A finding is rendered error text followed or preceded by a text test:

Rendered text Examples
.to_string() of an error-named value (e, err, error, source, cause, *_err, *_error, err_*, error_*) error.to_string(), self.last_error.to_string()
.unwrap_err().to_string(), .expect_err(…).to_string() result.unwrap_err().to_string()
.message() and any *_message() accessor err.message(), error.protocol_message()
format! of an error-named value format!("{error:?}"), format!("{}", err)
a variable or field named like a message message, msg, errmsg, *_message, *_msg, error_text, err_str, error_string, status.error_message
an error-rendering helper format_sdk_error(&err), Self::render_error(…), error_chain(err)
a local bound to any of the above let marker = error.to_string(); then marker

each optionally followed by .to_ascii_lowercase(), .to_lowercase(), .as_str(), .trim() or similar conversions, and

Text test Example
.contains(, .starts_with(, .ends_with(, .find(, .rfind(, .strip_prefix(, .strip_suffix( with any argument message.contains(needle), message.find(prefix)?
== / != against a string literal, on either side; for every form but a message-named variable, against any value msg == "timed out", "busy" != error.to_string(), err.message() == duplicate_name_message(name)
matches! or match with string-literal patterns matches!(message.as_str(), "a" | "b")
passing it to an infer* / classify* function infer_storage_error_kind(error.message())

The scanner lexes each file just enough to ignore comments and the contents of string, raw string, byte string and character literals, and matches across lines, so formatting, method chains, ?, and macro invocations and macro_rules! bodies are all covered.

Test code is skipped: files under a tests or test_support directory, tests.rs, *_tests.rs and test_support.rs files, files starting with #![cfg(test)], items whose attributes require a test build (#[cfg(test)], #[cfg(all(…, test, …))], a cfg(any(…)) of test-only predicates, or a test attribute such as #[test], #[tokio::test] or #[sqlx::test(…)]), covering inline mod x { … } blocks, functions and impls, and files that only test code declares: a test-only mod x; (resolved like rustc: x.rs or x/mod.rs next to a crate root or mod.rs, otherwise in the directory named after the declaring file, or the item's #[path] wherever it sits among the attributes) and every mod a test file declares in turn. A file that production code also declares stays in the scan. Declarations are read from every tracked Rust file, including files outside paths. Limits: #[cfg(any(test, feature = "…"))] and cfg_attr are production code; a mod x; inside an inline module is resolved as if it were declared at the top of the file; a local bound from error text stops counting at the next let or assignment of the same name, even one in an inner block; a multi-line attribute between a marker and its fn ends the marker's comment block.

A finding that cannot be fixed yet needs an explicit, reasoned exemption, a plain // comment (not a doc comment):

// aster-allow(message-classification): aria2 reports these only as text under code 1 (AsterDrive#800)

A marker exempts the findings whose expression has it on one of its lines, the findings directly below its comment block, the findings in the head of the statement directly below its comment block (up to the statement's first { or ;, so one marker covers an if a || b || c { condition), or, when it is in the comment and attribute lines directly above a fn, every finding in that function. Link the issue tracking the removal; removing the marker is part of closing it. Validation fails, naming file:line, the matched form and the source, with a link to this section, for every finding without a marker, every marker without a reason, and every marker that exempts nothing, so stale markers are removed once the code is fixed.

Test-only feature guard

Some crates have features that exist only for tests and turn on code in whatever they are compiled into: aster_forge_db/test-support makes pause_point! live and enables the interleave scenario API and fail_commit, and database-container-tests implies it. Products enable them in [dev-dependencies] only. With Cargo resolver 2 or later, dev-dependency features never reach a non-test build, but one workspace member that enables such a feature in normal [dependencies] makes Cargo's feature unification compile it into the release binary, without any error. contracts/test-only-features.json lists these features per crate, each entry with the first release of the crate in which they are test-only (since):

{ "crate": "aster_forge_db", "features": ["test-support", "database-container-tests"], "since": "0.1.0-alpha.6" }

Enable the guard in validate-repository:

"testOnlyFeatureGuard": {
  "manifestPath": "Cargo.toml",
  "exclude": ["my_test_helpers"]
}

Both fields are optional; {} checks the workspace of the root Cargo.toml with every member shipping; unknown fields are rejected. exclude lists, by package name, members that never ship, such as a publish = false crate of test helpers; each must be a workspace member, and a new member ships until it is excluded. Excluding a member removes it as a starting point, not from the graph: a shipping member that depends on it normally still fails.

For every locked copy of a listed crate the contract applies to (a path copy always: a workspace member, as in AsterForge, or a path dependency, as in a project patched to an AsterForge checkout, both the current source whose version may lag behind the release that adds an entry; a registry or git copy from since; a crate that is not in Cargo.lock is skipped; copies of one version from different sources are selected by source), the guard asks Cargo for the inverted feature graph of the shipping members with normal edges only, every feature of every shipping member and every target platform:

cargo tree --locked --workspace [--exclude <member> ...] --all-features --target all \
  --edges features,normal --invert <crate>@<version> --prefix depth

cargo metadata cannot answer this: it reports one feature set per package with dev-dependencies unified in. Each path from a listed feature to a shipping member or member feature fails validation, one line per member and feature with the shortest path, for example:

app: aster_forge_db 0.1.0-alpha.6 feature "test-support" via app/default -> app v0.1.0 -> lib/default -> lib v0.1.0 -> aster_forge_db/database-container-tests -> aster_forge_db/test-support

This covers a direct normal dependency, a dependency through another member or any other crate, a feature implied by another feature, a member feature that forwards a test-only feature (all member features are checked, since any of them may be in a release build), and a platform-specific dependency. A test-only crate's own features selected on the command line are not activations, so AsterForge's own tests can build aster_forge_db with them. The guard rejects a workspace on resolver 1 (a virtual workspace without resolver, or an edition before 2021), where dev-dependency features do reach normal builds and the graph would not show them, and a workspace without Cargo.lock; it never updates the lockfile.

The guard runs cargo, so the job needs a Rust toolchain on PATH (GitHub-hosted Ubuntu runners have one; a rust-toolchain.toml is honoured) and network access to download the crates Cargo needs to read their manifests. It fails when cargo is missing rather than skipping the check. The check-test-only-features mode runs the same check on a workspace outside the repository's configuration, such as a project generated from a template.

Forge adoption issues

AsterForge lists its opt-in downstream repositories in forgeAdoption:

"forgeAdoption": {
  "releasePlan": "release-plan.json",
  "changelog": "CHANGELOG.md",
  "label": "Dependencies",
  "subscribers": ["AsterCommunity/AsterDrive", "AsterCommunity/AsterYggdrasil", "AsterCommunity/AsterACME"]
}
  • The batch is the release plan's publish_order at the checked-out commit, which must be the commit that last changed the plan. Its full SHA identifies the batch.
  • The batch's changelog entries are the top-level bullets in [Unreleased] (or in a section the previous release did not have) that the changelog at the previous release commit (the one before it that changed the plan) does not contain. AsterForge keeps one workspace changelog and cuts [Unreleased] some time after a release, so this is what tells two published batches apart. Entries whose bold title (or ### heading) says breaking or behavior are called out first; bare #123 references are qualified with the AsterForge repository.
  • A subscriber is skipped when its default branch has no root Cargo.lock, locks none of the batch's crates from a registry, or already locks the published versions; git and path copies do not count. Only the outdated crates are listed and updated, and the lockfile is read with the raw media type, so it is not limited to 1 MB. When a crate name has several copies in Cargo.lock (registry, git or path), each outdated copy is passed as name@version, or as <source>#name@version when another copy has the same version, so Cargo can tell them apart.
  • The clippy delta lists the bundled contract's entries whose since the published aster_forge_db reaches and the oldest locked one does not.
  • Each issue starts with <!-- forge-adoption: <owner/repo> <release SHA> -->. Issues are found by listing the configured label (open and closed) and reading that marker on bot-authored issues, so the label must already exist in every subscriber and stay on the issue. A rerun rewrites only the title and body of an open issue and leaves a closed one alone; a release comments <!-- forge-adoption-superseded-by: <owner/repo> <release SHA> --> once on every open adoption issue of a release commit that precedes it in history (not by issue number, so a late rerun of an older release never points a newer issue back at it) and never closes it.
  • Subscribers are processed independently. If any fails, the run fails after the others are done and names each failure; every write is idempotent, so rerunning the job completes the rest.
  • The token needs issues: write and contents: read on every subscriber, and nothing on AsterForge itself: the release is read from the checkout.

Locally, a dry run against a release commit (with any token that can read the subscribers):

echo '{}' > /tmp/event.json
env INPUT_MODE=forge-adoption-issues INPUT_DRY-RUN=true INPUT_TOKEN="$(gh auth token)" \
  GITHUB_WORKSPACE="$PWD" GITHUB_REPOSITORY=AsterCommunity/AsterForge GITHUB_EVENT_PATH=/tmp/event.json \
  node /path/to/aster-automation/src/action.ts

See migration and GitHub App identity for the complete workflow shape.

Development

The action is written in TypeScript and has no build step: the runner's node24 executes src/action.ts directly by stripping types, so the commit a repository pins is exactly the code that runs. Nothing generated is committed, there is no bundle or dist/, and package.json has no runtime dependencies.

  • src/ holds the action, scripts/ the maintainer CLI and test/ the node --test suite, all as .ts.
  • Only erasable TypeScript is allowed (no enum, namespace, parameter properties or decorators), and relative imports use the .ts extension. tsconfig.json enforces both with erasableSyntaxOnly and allowImportingTsExtensions.
  • Untrusted JSON (configuration, event payloads, GitHub API responses, the clippy and test-only feature contracts, cargo metadata output) enters as unknown and is narrowed by the decoders in src/decode.ts, src/config.ts and src/github-types.ts; the types are derived from those checks.
  • typescript and @types/node are development dependencies used only for type checking.

Requires Node.js 24 or newer.

npm ci
npm run validate   # tsc --noEmit, then node --test test/*.test.ts

The test-only feature tests run cargo (offline) on generated workspaces whose crates.io dependencies come from a vendored directory source, so they need a Rust toolchain.

The Self-test workflow runs the action from the checkout (uses: ./) on a GitHub-hosted runner in validate-config mode, and in validate-repository mode against the fixture repository in test/fixtures/repository (including the test-only feature guard with the runner's cargo), requires check-test-only-features to reject test/fixtures/test-only-features-violation, then runs the same validation.

Versioning

Workflow callers must pin a full commit SHA. Release tags provide discovery and changelog identity, not a mutable execution trust boundary.

License

MIT

About

Deterministic GitHub PR and CI lifecycle automation for AsterCommunity repositories

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages