feat(entity): derive Default on DB models (closes #183)#279
Merged
Conversation
GitHub gates the `issue_comment` webhook on the `issues` permission, even
for comments posted on the main conversation tab of a pull request. The
manifest subscribed to the event but never received it, so `/ci run`
triggers posted on PR conversations were silently dropped. `write` is
required because the same `/repos/{owner}/{repo}/issues/{n}/comments`
endpoint is used to reply with build status via the existing reporter.
…pplyInput
`/gradient run` needs the PR head SHA to lay down a fresh evaluation when no
parked approval gate exists; the issue_comment webhook does not carry it.
Adds `CiReporter::get_pull_request` (default no-op, implemented for the
Gitea/Forgejo, GitLab, GitHub, and GitHub App reporters), returning a
`PullRequestSnapshot { head_sha, head_branch, head_clone_url, is_fork }`.
Also threads `wildcard_override: Option<String>` through `ApplyInput` /
`apply_trigger` / `trigger_evaluation` so a comment can re-target the run
without editing project config.
…only Replaces the previous `/ci run` parser with a `GradientCommand` enum recognising `/gradient run [wildcard]` and `/gradient approve`. The legacy `/ci` prefix is hard-rejected (test covers the regression). Dispatch in `handle_issue_comment`: - Both commands run a `sender_is_trusted` (`is_repo_writer`) gate against the project's reporter — non-maintainers are dropped at debug level with no side effect. - `/gradient approve` only unparks an existing `Waiting + Approval` row. - `/gradient run` unparks if a parked eval exists for the PR (so it doubles as approve), and otherwise fetches the PR via `reporter.get_pull_request` and calls `trigger_pr_for_integration` with `manual=true` and `wildcard_override` from the comment so a fresh evaluation is laid down at the current PR head. Docs, the Nix state module, and the project-triggers UI are updated to reference `/gradient` everywhere; `docs/src/tests.md` lists the new parser tests and the renamed legacy-prefix regression.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Defaulton all 40DeriveEntityModelstructs so callers can useModel { id, ..Default::default() }.id_newtype!macro to deriveDefault(resolves toUuid::nil()).Default+#[default]to the 6DeriveActiveEnumcolumn types, picking the natural initial state (Pending/Created/Queued/DeepGc), the documented default (CacheSubscriptionMode::ReadWrite), or the fail-noisy variant for severity (MessageLevel::Error).issues: writeto the GitHub App manifest so theissue_commentwebhook actually fires (issues: writeis needed because the existingpost_pr_commentreporter uses the/issues/{n}/commentsendpoint)./ci runwith/gradient run [wildcard]and add/gradient approve(hard rename — legacy prefix is rejected, regression test included)./gradientcommands are now maintainer-only viais_repo_writer./gradient approveonly unparks an existing approval gate;/gradient rununparks if a parked eval exists for the PR and otherwise fetches the PR via the newCiReporter::get_pull_requestand callstrigger_pr_for_integrationwithmanual=trueso a fresh evaluation is laid down at the current PR head.wildcard_override: Option<String>throughApplyInput/apply_trigger/trigger_evaluationso a comment can re-target a single run without editing project config.A nil ID is a placeholder, not a persistable value — callers override
id(typicallyId::now_v7()) and let the rest of the fields fall through.Test plan
cargo check --workspace --testscleancargo clippy --workspace --tests -- -D warningscleanentity::model_default_testssmoke-testsModel::default()foruser,build,evaluation,audit_log,organization_cache(covers enum,Json,Option<NaiveDateTime>field shapes)build_manifest_has_default_permissions_and_eventsextended to assertissues: writeparse_gradient_*parser tests cover barerun,run <wildcard>,approve, case-insensitivity, quote-reply prefix, rejection of unknown subcommands and the legacy/ciprefixRecordingCiReporter(test-support) keeps working via the default no-op impl ofget_pull_requestdocs/gradient-api.yaml,docs/src/tests.md,docs/src/development/github-app-setup.md,nix/modules/gradient-state.nix, and the project-triggers Angular templateCloses #183.