Skip to content
Draft
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
27 changes: 27 additions & 0 deletions .github/scripts/warden-require-ready.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
# Fail Warden on draft pull requests. Ruleset workflows never receive
# ready_for_review, so a passing run on a draft would let a PR that is later
# marked ready merge without review. This reads the live draft state, not the
# event payload, so re-running the check after marking the PR ready passes.
set -eu

: "${PR_URL:?PR_URL is required}"
: "${GITHUB_STEP_SUMMARY:?GITHUB_STEP_SUMMARY is required}"

is_draft=$(gh pr view "$PR_URL" --json isDraft --jq .isDraft)

case "$is_draft" in
false)
exit 0
;;
true)
message="Warden reviews this pull request once it is ready for review. Mark it ready, then re-run this check or push a commit."
printf '::error::%s\n' "$message"
printf '## Warden is waiting\n\n%s\n' "$message" >> "$GITHUB_STEP_SUMMARY"
exit 1
;;
*)
printf '::error::Unexpected isDraft value from gh: %s\n' "$is_draft"
exit 1
;;
esac
6 changes: 6 additions & 0 deletions .github/workflows/warden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ jobs:
repository: ${{ github.repository_owner }}/.github
path: .warden-org

- name: Require ready for review
env:
GH_TOKEN: ${{ github.token }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: .warden-org/.github/scripts/warden-require-ready.sh

- name: Analyze
id: warden-analyze
uses: getsentry/warden@v0
Expand Down
3 changes: 3 additions & 0 deletions warden.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ ignorePaths = [
"**/migrations/meta/**",
"**/*_snapshot.json",
]
# Skip hunks an earlier clean run on the PR already reviewed, so re-runs and
# pushes after a PR is marked ready do not pay for the same code twice.
incremental = true
incrementalApp = "sentry-warden"

[defaults.agent]
Expand Down
Loading