Skip to content

Commit 284276f

Browse files
committed
Output validation comments even without changes
Otherwise, a PR that breaks validation but then restores it will keep a comment saying that validation is broken.
1 parent e668a98 commit 284276f

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

.github/validate-pr/index.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ async function run() {
5656
path.join(tsValidationPath, 'types.ts')
5757
)
5858
const context = github.context
59+
const branch = context.base_ref
5960
assert(context.payload.pull_request, 'We should be in a PR context')
6061
const files = []
6162
let page = 1
@@ -149,20 +150,18 @@ async function run() {
149150
}
150151
changedApis.sort((a, b) => a.api.localeCompare(b.api))
151152

153+
let comment = `Following you can find the validation changes against the ${branch} branch for the API${changedApis.length === 1 ? '' : 's'}.\n\n`
152154
if (changedApis.length > 0) {
153-
let comment = `Following you can find the validation changes for the API${changedApis.length === 1 ? '' : 's'} you have modified.\n\n`
154155
comment += '| API | Status | Request | Response |\n'
155156
comment += '| --- | --- | --- | --- |\n'
156157
for (const change of changedApis) {
157158
comment += buildDiffTableLine(change)
158159
}
159-
comment += `\nYou can validate ${changedApis.length === 1 ? 'this' : 'these'} API${changedApis.length === 1 ? '' : 's'} yourself by using the ${tick}make validate${tick} target.\n`
160-
161-
core.setOutput('has_results', 'true')
162-
core.setOutput('comment_body', comment)
163160
} else {
164-
core.setOutput('has_results', 'false')
161+
comment += 'No changes detected.'
165162
}
163+
comment += `\nYou can validate ${changedApis.length === 1 ? 'this' : 'these'} API${changedApis.length === 1 ? '' : 's'} yourself by using the ${tick}make validate${tick} target.\n`
164+
core.setOutput('comment_body', comment)
166165

167166
core.info('Done!')
168167
}
@@ -236,4 +235,4 @@ function generateResponse (r) {
236235
run().catch((err) => {
237236
core.error(err)
238237
process.exit(1)
239-
})
238+
})

.github/workflows/validate-pr.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ jobs:
7575
body-includes: 'Following you can find the validation changes'
7676

7777
- name: Create or update comment
78-
if: steps.validation.outputs.has_results == 'true'
7978
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
8079
with:
8180
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)