browser_review_gate 0.5.4 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2bca6bbab560800bc0b31754503019313587216fe741889a50f073a5683726ef
|
|
4
|
+
data.tar.gz: 17d1ef5b020bc258a0df17e22bf13cd26dca73efe15243060b09f85e5c49ab1c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 31d206b2156a6381e78ca6b0cda4cdc2aaef3b8f32df1345265ea2f6561772e3a578e679c23c2966b172332bbb4324e72110144c6ab44afef8cda76f1212a29e
|
|
7
|
+
data.tar.gz: eda6d97f4d0a387a920079a2fa62d3d19dd31a2abf30adf8e734196de3393c981c8e7e5a9ac3fd5472cb7cf8357fa7603223ec2feb7b08dc1c209e9e64abc73c
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.5
|
|
4
|
+
|
|
5
|
+
- A draft is gated too. A push to a draft used to skip the workflow, so the new head had no
|
|
6
|
+
`browser-verification` status and review looked open while the old comment still said it was on
|
|
7
|
+
hold. Now the head of a draft stays pending, and a reviewer requested on a draft is taken back. A
|
|
8
|
+
draft is still assessed only when it is marked ready (or dispatched by hand), so no model is
|
|
9
|
+
called on draft pushes. Re-run `browser-review-gate install` to update the workflow.
|
|
10
|
+
|
|
3
11
|
## 0.5.4
|
|
4
12
|
|
|
5
13
|
- A case that fails and passes on the same commit is marked flaky in the PR comment and counted in
|
|
@@ -27,8 +27,9 @@ module BrowserReviewGate
|
|
|
27
27
|
stats [--days N] [--json] what the gate did on PRs of the last N days (default 30)
|
|
28
28
|
TEXT
|
|
29
29
|
|
|
30
|
-
# `github`, `config`, `model` and `
|
|
31
|
-
def initialize(argv, stdin: $stdin, stdout: $stdout, stderr: $stderr, github: nil, config: nil, model: nil, shell: nil)
|
|
30
|
+
# `github`, `config`, `model`, `shell` and `env` are replaced in tests.
|
|
31
|
+
def initialize(argv, stdin: $stdin, stdout: $stdout, stderr: $stderr, github: nil, config: nil, model: nil, shell: nil, env: ENV)
|
|
32
|
+
@env = env
|
|
32
33
|
@shell = shell
|
|
33
34
|
@argv = argv.dup
|
|
34
35
|
@github = github
|
|
@@ -190,18 +191,26 @@ module BrowserReviewGate
|
|
|
190
191
|
return 0
|
|
191
192
|
end
|
|
192
193
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
failed =
|
|
199
|
-
# Escaped per the workflow-command spec so a message can never start a command of its own.
|
|
200
|
-
message = error.message.gsub("%", "%25").gsub("\r", "%0D").gsub("\n", "%0A")
|
|
201
|
-
@stdout.puts "::error title=Browser verification assessment failed::#{message}"
|
|
194
|
+
# A draft is assessed when it is marked ready or by hand; until then its head stays on hold.
|
|
195
|
+
if pull_request["draft"] && @env["GITHUB_EVENT_NAME"] != "workflow_dispatch"
|
|
196
|
+
@stdout.puts "PR #{number} is a draft; it is assessed when it is marked ready for review."
|
|
197
|
+
failed = false
|
|
198
|
+
else
|
|
199
|
+
failed = !assessed?(number, pull_request)
|
|
202
200
|
end
|
|
203
201
|
Gate.new(github: github, config: config, log: @stdout).enforce(number)
|
|
204
202
|
failed ? 1 : 0
|
|
205
203
|
end
|
|
204
|
+
|
|
205
|
+
def assessed?(number, pull_request)
|
|
206
|
+
model = @model || (config.local? ? nil : ModelClient.for(config))
|
|
207
|
+
Assessor.new(github: github, model: model, config: config, prompts: Prompts.new(root), log: @stdout).assess(number, pull_request: pull_request)
|
|
208
|
+
true
|
|
209
|
+
rescue Error => error
|
|
210
|
+
# Escaped per the workflow-command spec so a message can never start a command of its own.
|
|
211
|
+
message = error.message.gsub("%", "%25").gsub("\r", "%0D").gsub("\n", "%0A")
|
|
212
|
+
@stdout.puts "::error title=Browser verification assessment failed::#{message}"
|
|
213
|
+
false
|
|
214
|
+
end
|
|
206
215
|
end
|
|
207
216
|
end
|
|
@@ -39,6 +39,7 @@ module BrowserReviewGate
|
|
|
39
39
|
|
|
40
40
|
def verdict(number, pull_request, comments, assessment, waived_by)
|
|
41
41
|
return [ :open, "Browser verification waived by #{waived_by}." ] if waived_by
|
|
42
|
+
return [ :closed, "Draft: browser testing is assessed when it is marked ready for review." ] if !assessment && pull_request["draft"]
|
|
42
43
|
return [ :closed, "The browser-testing assessment for this commit is not available." ] unless assessment
|
|
43
44
|
return [ :open, "Browser verification is not needed." ] unless assessment.required?
|
|
44
45
|
return [ :open, "Required browser cases are verified." ] if verified?(number, pull_request, comments, assessment)
|
|
@@ -91,7 +92,7 @@ module BrowserReviewGate
|
|
|
91
92
|
@github.remove_reviewers(number, reviewers: reviewers, team_reviewers: teams)
|
|
92
93
|
waiting = paused(comments)
|
|
93
94
|
waiting = { "reviewers" => waiting["reviewers"] | reviewers, "teams" => waiting["teams"] | teams }
|
|
94
|
-
write_notice(number, comments, "#{author(pull_request)}#{notice(number, assessment, comments)}\n\n#{names(waiting)} will be " \
|
|
95
|
+
write_notice(number, comments, "#{author(pull_request)}#{notice(number, pull_request, assessment, comments)}\n\n#{names(waiting)} will be " \
|
|
95
96
|
"asked again automatically once the run is published.", waiting)
|
|
96
97
|
@log.puts "Took back reviewer requests until browser verification is available."
|
|
97
98
|
end
|
|
@@ -158,7 +159,8 @@ module BrowserReviewGate
|
|
|
158
159
|
(waiting["reviewers"] + waiting["teams"]).map { |name| Markdown.escape(name) }.join(", ")
|
|
159
160
|
end
|
|
160
161
|
|
|
161
|
-
def notice(number, assessment, comments)
|
|
162
|
+
def notice(number, pull_request, assessment, comments)
|
|
163
|
+
return "Review request paused. This PR is a draft: browser testing is assessed when it is marked ready for review." if !assessment && pull_request["draft"]
|
|
162
164
|
return "Review request paused. The browser-testing assessment for this commit is not available. Request review again to retry it." unless assessment
|
|
163
165
|
|
|
164
166
|
report = Report.latest(comments, config: @config)
|
|
@@ -38,10 +38,9 @@ concurrency:
|
|
|
38
38
|
|
|
39
39
|
jobs:
|
|
40
40
|
gate:
|
|
41
|
-
# A draft
|
|
41
|
+
# A draft runs too, so a push keeps its head on hold; it is assessed once marked ready or by hand.
|
|
42
42
|
# Of all labels, only the two that open the gate matter, added or removed: a published run and a waiver.
|
|
43
43
|
if: >-
|
|
44
|
-
(github.event_name == 'workflow_dispatch' || !github.event.pull_request.draft) &&
|
|
45
44
|
(!contains(fromJSON('["labeled","unlabeled"]'), github.event.action) ||
|
|
46
45
|
contains(fromJSON('<%= JSON.generate(gate_labels) %>'), github.event.label.name))
|
|
47
46
|
runs-on: ubuntu-latest
|