Skip to content

Commit 8af6a83

Browse files
committed
Merge branch 'main' into missing=timeouts
2 parents 17ce636 + e06dae2 commit 8af6a83

File tree

1,685 files changed

+272276
-139229
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,685 files changed

+272276
-139229
lines changed

.backportrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"repoOwner": "elastic",
3+
"repoName": "elasticsearch-specification",
4+
"targetBranchChoices": ["9.1", "9.0", "8.19", "8.18"],
5+
"fork": false
6+
}

.buildkite/kibana.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# Since we're into the current repo, move to the top-level
6+
cd ..
7+
8+
echo "--- Install dependencies"
9+
lsb_release -a
10+
apt-get update -y
11+
apt-get install -y unzip
12+
13+
echo "--- Clone elasticsearch-js"
14+
git clone -v -- [email protected]:elastic/elasticsearch-js.git
15+
16+
echo "--- Clone elastic-client-generator-js"
17+
git clone -v -- [email protected]:elastic/elastic-client-generator-js.git
18+
mkdir elastic-client-generator-js/output
19+
20+
echo "--- Clone Kibana"
21+
git clone -v --reference /usr/local/git-references/git-github.1485827954.workers.dev-elastic-kibana-git -- [email protected]:elastic/kibana.git
22+
pushd kibana
23+
24+
echo "--- Install Node.js and Yarn"
25+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
26+
set +e # https://github.com/nvm-sh/nvm/issues/3117
27+
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
28+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
29+
set -e
30+
31+
nvm install
32+
nvm use
33+
npm install --global yarn
34+
popd
35+
36+
echo "--- Install elasticsearch-js"
37+
pushd elasticsearch-js
38+
npm install
39+
node .buildkite/make.mjs --task codegen main
40+
npm run build
41+
npm pack
42+
popd
43+
44+
pushd kibana
45+
yarn add ../elasticsearch-js/elastic-elasticsearch-*.tgz
46+
47+
echo "--- Bootstrap Kibana"
48+
git --no-pager diff
49+
yarn kbn bootstrap --allow-root
50+
51+
echo "--- Check types"
52+
node scripts/type_check.js

.buildkite/kibana.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
agents:
2+
memory: "24G"
3+
cpu: "4"
4+
ephemeralStorage: 15Gi
5+
6+
steps:
7+
- label: "Run Kibana type checks"
8+
command: .buildkite/kibana.sh

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,5 +234,6 @@ dist/* binary
234234

235235
output/** linguist-generated=true
236236
output/schema/validation-errors.json linguist-generated=false
237+
compiler-rs/compiler-wasm-lib/pkg/* linguist-generated=true
237238

238239
####################################################################################################

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1 @@
1-
<!--
2-
3-
Hello there!
4-
5-
Thank you for opening a pull request!
6-
Please make sure to follow the steps below when opening a pr:
7-
8-
- Sign the CLA https://www.elastic.co/contributor-agreement/
9-
- Tag the relative issue (if any) and give a brief explanation on what your changes are doing
10-
- If you did a spec change, remember to generate again the outputs, you can do it by running `make contrib`
11-
- Add the appropriate backport labels. If you need to backport a breaking change (e.g. changing the structure of a type or changing the type/optionality of a field), please follow these rules:
12-
- If the API is unusable without the change -> every supported version
13-
- If the API is usable, but fix is on the response side -> every supported version
14-
- If the API is usable, but fix is on the request side -> no backport, unless the API is _partially_ usable and the fix unlocks a missing feature that has no workaround
15-
16-
Happy coding!
17-
18-
-->
1+
<!-- Hello there! Thank you for opening a pull request. See CONTRIBUTING.md for instructions. -->

.github/download-artifacts/index.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@
1717
* under the License.
1818
*/
1919

20-
'use strict'
21-
22-
const core = require('@actions/core')
23-
const { join } = require('path')
24-
const minimist = require('minimist')
25-
const stream = require('stream')
26-
const { promisify } = require('util')
27-
const { createWriteStream, promises } = require('fs')
28-
const rimraf = require('rimraf')
29-
const fetch = require('node-fetch')
30-
const crossZip = require('cross-zip')
20+
import core from '@actions/core'
21+
import { join, dirname } from 'path'
22+
import { fileURLToPath } from 'url'
23+
import minimist from 'minimist'
24+
import stream from 'stream'
25+
import { promisify } from 'util'
26+
import { createWriteStream, promises } from 'fs'
27+
import { rimraf } from 'rimraf'
28+
import fetch from 'node-fetch'
29+
import crossZip from 'cross-zip'
3130

3231
const { mkdir, rename, readdir, unlink } = promises
3332
const pipeline = promisify(stream.pipeline)
3433
const unzip = promisify(crossZip.unzip)
35-
const rm = promisify(rimraf)
3634

35+
const __filename = fileURLToPath(import.meta.url)
36+
const __dirname = dirname(__filename)
3737
const esFolder = join(__dirname, '..', '..', 'artifacts')
3838
const zipFolder = join(esFolder, 'artifacts.zip')
3939
const downloadedSpec = join(esFolder, 'rest-api-spec', 'api')
@@ -57,8 +57,8 @@ async function downloadArtifacts (opts) {
5757
core.info(`Resolved artifact URL for ${resolved.commit_url}`)
5858

5959
core.info('Cleanup')
60-
await rm(esFolder)
61-
await rm(specFolder)
60+
await rimraf(esFolder)
61+
await rimraf(specFolder)
6262
await mkdir(esFolder, { recursive: true })
6363
await mkdir(specFolder, { recursive: true })
6464

@@ -74,7 +74,7 @@ async function downloadArtifacts (opts) {
7474
await unzip(zipFolder, esFolder)
7575

7676
core.info('Cleanup')
77-
await rm(zipFolder)
77+
await rimraf(zipFolder)
7878

7979
core.info('Moving files')
8080
const files = await readdir(downloadedSpec)

.github/download-artifacts/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "download-artifacts",
33
"version": "1.0.0",
44
"description": "",
5+
"type": "module",
56
"main": "index.js",
67
"scripts": {
78
"test": "echo \"Error: no test specified\" && exit 1"
@@ -13,7 +14,7 @@
1314
"@actions/core": "^1.6.0",
1415
"cross-zip": "^4.0.0",
1516
"minimist": "^1.2.5",
16-
"node-fetch": "^2.6.7",
17-
"rimraf": "^3.0.2"
17+
"node-fetch": "^3",
18+
"rimraf": "^6"
1819
}
1920
}

.github/validate-pr/index.js

Lines changed: 99 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import assert from 'assert'
2626
import * as core from '@actions/core'
2727
import { copyFile } from 'fs/promises'
2828
import * as github from '@actions/github'
29-
import specification from '../../output/schema/schema.json' assert { type: 'json' }
29+
import specification from '../../output/schema/schema.json' with { type: 'json' }
30+
import baselineValidation from '../../../clients-flight-recorder/recordings/types-validation/types-validation.json' with { type: 'json' }
3031
import { run as getReport } from '../../../clients-flight-recorder/scripts/types-validator/index.js'
3132
import {
3233
getNamespace,
@@ -81,68 +82,85 @@ async function run() {
8182
const specFiles = files.filter(
8283
(file) => file.includes('specification') && !file.includes('compiler/test')
8384
)
84-
const table = []
85+
const reports = new Map()
8586

8687
cd(tsValidationPath)
8788

89+
// Collect all APIs to validate
90+
const apisToValidate = new Set()
91+
8892
for (const file of specFiles) {
8993
if (file.startsWith('specification/_types')) continue
9094
if (file.startsWith('specification/_spec_utils')) continue
9195
if (file.startsWith('specification/_doc_ids')) continue
9296
if (file.startsWith('specification/_json_spec')) continue
93-
if (file === 'specification/tsconfig.json') continue
97+
if (file.startsWith('specification/node_modules')) continue
98+
if (file.endsWith('tsconfig.json')) continue
99+
if (file.endsWith('eslint.config.js')) continue
100+
if (file.endsWith('package.json')) continue
101+
if (file.endsWith('package-lock.json')) continue
102+
if (file.endsWith('.md')) continue
94103
if (getApi(file).endsWith('_types')) {
95104
const apis = specification.endpoints
96105
.filter(endpoint => endpoint.name.split('.').filter(s => !privateNames.includes(s))[0] === getApi(file).split('.')[0])
97106
.map(endpoint => endpoint.name)
98107
for (const api of apis) {
99-
const report = await getReport({
100-
api,
101-
'generate-report': false,
102-
request: true,
103-
response: true,
104-
ci: false,
105-
verbose: false
106-
})
107-
table.push(buildTableLine(api, report))
108+
apisToValidate.add(api)
108109
}
109110
} else {
110-
const report = await getReport({
111-
api: getApi(file),
112-
'generate-report': false,
113-
request: true,
114-
response: true,
115-
ci: false,
116-
verbose: false
117-
})
118-
table.push(buildTableLine(getApi(file), report))
111+
const api = getApi(file)
112+
apisToValidate.add(api)
113+
}
114+
}
115+
116+
// Call getReport once with all APIs
117+
if (apisToValidate.size > 0) {
118+
const allApis = Array.from(apisToValidate).join(',')
119+
const report = await getReport({
120+
api: allApis,
121+
'generate-report': false,
122+
request: true,
123+
response: true,
124+
ci: false,
125+
verbose: false
126+
})
127+
128+
// Extract individual API reports from the combined result
129+
for (const api of apisToValidate) {
130+
const namespace = getNamespace(api)
131+
if (report.has(namespace)) {
132+
const namespaceReport = report.get(namespace).find(r => r.api === getName(api))
133+
if (namespaceReport) {
134+
reports.set(api, namespaceReport)
135+
}
136+
}
119137
}
120138
}
121139

122140
cd(path.join(__dirname, '..', '..'))
123141

124-
table.sort((a, b) => {
125-
if (a < b) return -1
126-
if (a > b) return 1
127-
return 0
128-
})
142+
// Compare current reports with baseline and find changes
143+
const changedApis = []
144+
for (const [apiName, report] of reports) {
145+
const baselineReport = findBaselineReport(apiName, baselineValidation)
146+
if (baselineReport && hasChanges(baselineReport, report, apiName)) {
147+
changedApis.push({ api: apiName, baseline: baselineReport, current: report })
148+
}
149+
}
150+
changedApis.sort((a, b) => a.api.localeCompare(b.api))
129151

130-
if (table.length > 0) {
131-
let comment = `Following you can find the validation results for the API${table.length === 1 ? '' : 's'} you have changed.\n\n`
152+
let comment = `Following you can find the validation changes against the target branch for the API${changedApis.length === 1 ? '' : 's'}.\n\n`
153+
if (changedApis.length > 0) {
132154
comment += '| API | Status | Request | Response |\n'
133155
comment += '| --- | --- | --- | --- |\n'
134-
for (const line of [...new Set(table)]) {
135-
comment += line
156+
for (const change of changedApis) {
157+
comment += buildDiffTableLine(change)
136158
}
137-
comment += `\nYou can validate ${table.length === 1 ? 'this' : 'these'} API${table.length === 1 ? '' : 's'} yourself by using the ${tick}make validate${tick} target.\n`
138-
139-
await octokit.rest.issues.createComment({
140-
owner: 'elastic',
141-
repo: 'elasticsearch-specification',
142-
issue_number: context.payload.pull_request.number,
143-
body: comment
144-
})
159+
} else {
160+
comment += '**No changes detected**.\n'
145161
}
162+
comment += `\nYou can validate ${changedApis.length === 1 ? 'this' : 'these'} API${changedApis.length === 1 ? '' : 's'} yourself by using the ${tick}make validate${tick} target.\n`
163+
core.setOutput('comment_body', comment)
146164

147165
core.info('Done!')
148166
}
@@ -151,35 +169,65 @@ function getApi (file) {
151169
return file.split('/').slice(1, 3).filter(s => !privateNames.includes(s)).filter(Boolean).join('.')
152170
}
153171

154-
function buildTableLine (api, report) {
155-
const apiReport = report.get(getNamespace(api)).find(r => r.api === getName(api))
156-
return `| ${tick}${api}${tick} | ${generateStatus(apiReport)} | ${generateRequest(apiReport)} | ${generateResponse(apiReport)} |\n`
172+
function findBaselineReport(apiName, baselineValidation) {
173+
const [namespace, method] = apiName.split('.')
174+
175+
if (!baselineValidation.namespaces[namespace]) {
176+
return null
177+
}
178+
179+
return baselineValidation.namespaces[namespace].apis.find(api => api.api === method)
157180
}
158181

159-
function generateStatus (report) {
160-
if (!report.diagnostics.hasRequestType || !report.diagnostics.hasResponseType) {
182+
function hasChanges(baselineReport, report) {
183+
if (!report) return false
184+
185+
return baselineReport.status !== report.status ||
186+
baselineReport.passingRequest !== report.passingRequest ||
187+
baselineReport.passingResponse !== report.passingResponse
188+
}
189+
190+
function buildDiffTableLine(change) {
191+
const { api, baseline, current } = change
192+
193+
const status = generateStatus(current.status)
194+
const request = generateRequest(current)
195+
const response = generateResponse(current)
196+
197+
const baselineStatus = generateStatus(baseline.status)
198+
const baselineRequest = generateRequest(baseline)
199+
const baselineResponse = generateResponse(baseline)
200+
201+
const statusDiff = status !== baselineStatus ? `${baselineStatus}${status}` : status
202+
const requestDiff = request !== baselineRequest ? `${baselineRequest}${request}` : request
203+
const responseDiff = response !== baselineResponse ? `${baselineResponse}${response}` : response
204+
205+
return `| ${tick}${api}${tick} | ${statusDiff} | ${requestDiff} | ${responseDiff} |\n`
206+
}
207+
208+
209+
function generateStatus (status) {
210+
if (status === 'missing_types' || status === 'missing_request_type' || status === 'missing_response_type') {
161211
return ':orange_circle:'
162212
}
163-
if (report.totalRequest <= 0 || report.totalResponse <= 0) {
213+
if (status === 'missing_test') {
164214
return ':white_circle:'
165215
}
166-
if (report.diagnostics.request.length === 0 && report.diagnostics.response.length === 0) {
216+
if (status === 'passing') {
167217
return ':green_circle:'
168218
}
169219
return ':red_circle:'
170220
}
171221

172222
function generateRequest (r) {
173-
if (r.totalRequest === -1) return 'Missing recording'
174-
if (!r.diagnostics.hasRequestType) return 'Missing type'
175-
if (r.totalRequest === 0) return 'Missing test'
223+
if (r.status === 'missing_test') return 'Missing test'
224+
if (r.status === 'missing_types' || r.status == 'missing_request_type') return 'Missing type'
176225
return `${r.passingRequest}/${r.totalRequest}`
177226
}
178227

179228
function generateResponse (r) {
180-
if (r.totalResponse === -1) return 'Missing recording'
181-
if (!r.diagnostics.hasResponseType) return 'Missing type'
182-
if (r.totalResponse === 0) return 'Missing test'
229+
if (r.status === 'missing_test') return 'Missing test'
230+
if (r.status === 'missing_types' || r.status == 'missing_response_type') return 'Missing type'
183231
return `${r.passingResponse}/${r.totalResponse}`
184232
}
185233

.github/validate-pr/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
"dependencies": {
1414
"@actions/core": "^1.6.0",
1515
"@actions/github": "^5.0.0",
16-
"zx": "^4.3.0"
16+
"zx": "^8"
1717
}
1818
}

0 commit comments

Comments
 (0)