Skip to content

Commit d97e9ac

Browse files
authored
Fail CI on generation errors (#2614)
1 parent 289be00 commit d97e9ac

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

.github/validate-pr/index.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,22 @@ async function run () {
107107
return 0
108108
})
109109

110-
let comment = `Following you can find the validation results for the API${table.length === 1 ? '' : 's'} you have changed.\n\n`
111-
comment += '| API | Status | Request | Response |\n'
112-
comment += '| --- | --- | --- | --- |\n'
113-
for (const line of [...new Set(table)]) {
114-
comment += line
115-
}
116-
comment += `\nYou can validate ${table.length === 1 ? 'this' : 'these'} API${table.length === 1 ? '' : 's'} yourself by using the ${tick}make validate${tick} target.\n`
110+
if (table.length > 0) {
111+
let comment = `Following you can find the validation results for the API${table.length === 1 ? '' : 's'} you have changed.\n\n`
112+
comment += '| API | Status | Request | Response |\n'
113+
comment += '| --- | --- | --- | --- |\n'
114+
for (const line of [...new Set(table)]) {
115+
comment += line
116+
}
117+
comment += `\nYou can validate ${table.length === 1 ? 'this' : 'these'} API${table.length === 1 ? '' : 's'} yourself by using the ${tick}make validate${tick} target.\n`
117118

118-
await octokit.rest.issues.createComment({
119-
owner: 'elastic',
120-
repo: 'elasticsearch-specification',
121-
issue_number: context.payload.pull_request.number,
122-
body: comment
123-
})
119+
await octokit.rest.issues.createComment({
120+
owner: 'elastic',
121+
repo: 'elasticsearch-specification',
122+
issue_number: context.payload.pull_request.number,
123+
body: comment
124+
})
125+
}
124126

125127
core.info('Done!')
126128
}

.github/workflows/validate-pr.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@ name: Validate APIs
22

33
on:
44
pull_request:
5-
paths:
6-
- 'specification/**'
7-
- '!specification/_types/**'
8-
- '!specification/_spec_utils/**'
9-
- '!specification/_doc_ids/**'
10-
- '!specification/_json_spec/**'
11-
125
branches:
136
- main
147

@@ -51,6 +44,11 @@ jobs:
5144
npm install --prefix .github/validate-pr
5245
make setup
5346
47+
- name: Generate specification and check generated types
48+
working-directory: ./elasticsearch-specification
49+
run: |
50+
make generate
51+
5452
- name: Download artifacts
5553
working-directory: ./clients-flight-recorder
5654
run: |

typescript-generator/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"kibana": "KIBANA=true ts-node src/client.ts",
1111
"lint": "ts-standard src",
1212
"lint:fix": "ts-standard --fix src",
13-
"is-valid-output": "tsc --noEmit",
13+
"is-valid-output": "tsc --noEmit ../output/typescript/types.ts",
1414
"test": "npm run lint",
1515
"build": "rm -rf lib && tsc"
1616
},

0 commit comments

Comments
 (0)