From 3859857f4793720891b2f47aa87c0499ad52817c Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Thu, 13 Jun 2024 09:49:51 +0400 Subject: [PATCH 1/4] Fix generation output type check --- typescript-generator/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript-generator/package.json b/typescript-generator/package.json index b3c0bdbe63..0dad5b09ec 100644 --- a/typescript-generator/package.json +++ b/typescript-generator/package.json @@ -10,7 +10,7 @@ "kibana": "KIBANA=true ts-node src/client.ts", "lint": "ts-standard src", "lint:fix": "ts-standard --fix src", - "is-valid-output": "tsc --noEmit", + "is-valid-output": "tsc --noEmit ../output/typescript/types.ts", "test": "npm run lint", "build": "rm -rf lib && tsc" }, From efcf553170de0c5b5ed9e90f034873d8dd451b46 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Thu, 13 Jun 2024 11:20:31 +0400 Subject: [PATCH 2/4] Generate specification in validate workflow --- .github/workflows/validate-pr.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/validate-pr.yml b/.github/workflows/validate-pr.yml index 0b388ddc72..b76165ab4d 100644 --- a/.github/workflows/validate-pr.yml +++ b/.github/workflows/validate-pr.yml @@ -2,13 +2,6 @@ name: Validate APIs on: pull_request: - paths: - - 'specification/**' - - '!specification/_types/**' - - '!specification/_spec_utils/**' - - '!specification/_doc_ids/**' - - '!specification/_json_spec/**' - branches: - main @@ -51,6 +44,11 @@ jobs: npm install --prefix .github/validate-pr make setup + - name: Generate specification and check generated types + working-directory: ./elasticsearch-specification + run: | + make generate + - name: Download artifacts working-directory: ./clients-flight-recorder run: | From d364ffb59233f733dd7092e0db318171508901b1 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Thu, 13 Jun 2024 16:24:32 +0400 Subject: [PATCH 3/4] Post comment only if there were changes --- .github/validate-pr/index.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/validate-pr/index.js b/.github/validate-pr/index.js index b4a59b6936..c1d93e033d 100644 --- a/.github/validate-pr/index.js +++ b/.github/validate-pr/index.js @@ -107,20 +107,22 @@ async function run () { return 0 }) - let comment = `Following you can find the validation results for the API${table.length === 1 ? '' : 's'} you have changed.\n\n` - comment += '| API | Status | Request | Response |\n' - comment += '| --- | --- | --- | --- |\n' - for (const line of [...new Set(table)]) { - comment += line - } - comment += `\nYou can validate ${table.length === 1 ? 'this' : 'these'} API${table.length === 1 ? '' : 's'} yourself by using the ${tick}make validate${tick} target.\n` + if (table.length >= 0) { + let comment = `Following you can find the validation results for the API${table.length === 1 ? '' : 's'} you have changed.\n\n` + comment += '| API | Status | Request | Response |\n' + comment += '| --- | --- | --- | --- |\n' + for (const line of [...new Set(table)]) { + comment += line + } + comment += `\nYou can validate ${table.length === 1 ? 'this' : 'these'} API${table.length === 1 ? '' : 's'} yourself by using the ${tick}make validate${tick} target.\n` - await octokit.rest.issues.createComment({ - owner: 'elastic', - repo: 'elasticsearch-specification', - issue_number: context.payload.pull_request.number, - body: comment - }) + await octokit.rest.issues.createComment({ + owner: 'elastic', + repo: 'elasticsearch-specification', + issue_number: context.payload.pull_request.number, + body: comment + }) + } core.info('Done!') } From 02597f260ab6cc78eb6ea9f3ce174dcbcf31933c Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Thu, 13 Jun 2024 16:28:39 +0400 Subject: [PATCH 4/4] Fix comparison --- .github/validate-pr/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/validate-pr/index.js b/.github/validate-pr/index.js index c1d93e033d..53dc3dec79 100644 --- a/.github/validate-pr/index.js +++ b/.github/validate-pr/index.js @@ -107,7 +107,7 @@ async function run () { return 0 }) - if (table.length >= 0) { + if (table.length > 0) { let comment = `Following you can find the validation results for the API${table.length === 1 ? '' : 's'} you have changed.\n\n` comment += '| API | Status | Request | Response |\n' comment += '| --- | --- | --- | --- |\n'