Skip to content

Commit f22e21a

Browse files
committed
Resolves conlicts
2 parents db9d574 + dbdc495 commit f22e21a

File tree

1,229 files changed

+80185
-17982
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,229 files changed

+80185
-17982
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.0", "8.19", "8.18", "8.17"],
5+
"fork": false
6+
}

.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/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: 93 additions & 50 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,10 +82,13 @@ 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
@@ -96,53 +100,62 @@ async function run() {
96100
.filter(endpoint => endpoint.name.split('.').filter(s => !privateNames.includes(s))[0] === getApi(file).split('.')[0])
97101
.map(endpoint => endpoint.name)
98102
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))
103+
apisToValidate.add(api)
108104
}
109105
} 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))
106+
const api = getApi(file)
107+
apisToValidate.add(api)
108+
}
109+
}
110+
111+
// Call getReport once with all APIs
112+
if (apisToValidate.size > 0) {
113+
const allApis = Array.from(apisToValidate).join(',')
114+
const report = await getReport({
115+
api: allApis,
116+
'generate-report': false,
117+
request: true,
118+
response: true,
119+
ci: false,
120+
verbose: false
121+
})
122+
123+
// Extract individual API reports from the combined result
124+
for (const api of apisToValidate) {
125+
const namespace = getNamespace(api)
126+
if (report.has(namespace)) {
127+
const namespaceReport = report.get(namespace).find(r => r.api === getName(api))
128+
if (namespaceReport) {
129+
reports.set(api, namespaceReport)
130+
}
131+
}
119132
}
120133
}
121134

122135
cd(path.join(__dirname, '..', '..'))
123136

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

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`
147+
let comment = `Following you can find the validation changes against the target branch for the API${changedApis.length === 1 ? '' : 's'}.\n\n`
148+
if (changedApis.length > 0) {
132149
comment += '| API | Status | Request | Response |\n'
133150
comment += '| --- | --- | --- | --- |\n'
134-
for (const line of [...new Set(table)]) {
135-
comment += line
151+
for (const change of changedApis) {
152+
comment += buildDiffTableLine(change)
136153
}
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-
})
154+
} else {
155+
comment += '**No changes detected**.\n'
145156
}
157+
comment += `\nYou can validate ${changedApis.length === 1 ? 'this' : 'these'} API${changedApis.length === 1 ? '' : 's'} yourself by using the ${tick}make validate${tick} target.\n`
158+
core.setOutput('comment_body', comment)
146159

147160
core.info('Done!')
148161
}
@@ -151,35 +164,65 @@ function getApi (file) {
151164
return file.split('/').slice(1, 3).filter(s => !privateNames.includes(s)).filter(Boolean).join('.')
152165
}
153166

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`
167+
function findBaselineReport(apiName, baselineValidation) {
168+
const [namespace, method] = apiName.split('.')
169+
170+
if (!baselineValidation.namespaces[namespace]) {
171+
return null
172+
}
173+
174+
return baselineValidation.namespaces[namespace].apis.find(api => api.api === method)
157175
}
158176

159-
function generateStatus (report) {
160-
if (!report.diagnostics.hasRequestType || !report.diagnostics.hasResponseType) {
177+
function hasChanges(baselineReport, report) {
178+
if (!report) return false
179+
180+
return baselineReport.status !== report.status ||
181+
baselineReport.passingRequest !== report.passingRequest ||
182+
baselineReport.passingResponse !== report.passingResponse
183+
}
184+
185+
function buildDiffTableLine(change) {
186+
const { api, baseline, current } = change
187+
188+
const status = generateStatus(current.status)
189+
const request = generateRequest(current)
190+
const response = generateResponse(current)
191+
192+
const baselineStatus = generateStatus(baseline.status)
193+
const baselineRequest = generateRequest(baseline)
194+
const baselineResponse = generateResponse(baseline)
195+
196+
const statusDiff = status !== baselineStatus ? `${baselineStatus}${status}` : status
197+
const requestDiff = request !== baselineRequest ? `${baselineRequest}${request}` : request
198+
const responseDiff = response !== baselineResponse ? `${baselineResponse}${response}` : response
199+
200+
return `| ${tick}${api}${tick} | ${statusDiff} | ${requestDiff} | ${responseDiff} |\n`
201+
}
202+
203+
204+
function generateStatus (status) {
205+
if (status === 'missing_types' || status === 'missing_request_type' || status === 'missing_response_type') {
161206
return ':orange_circle:'
162207
}
163-
if (report.totalRequest <= 0 || report.totalResponse <= 0) {
208+
if (status === 'missing_test') {
164209
return ':white_circle:'
165210
}
166-
if (report.diagnostics.request.length === 0 && report.diagnostics.response.length === 0) {
211+
if (status === 'passing') {
167212
return ':green_circle:'
168213
}
169214
return ':red_circle:'
170215
}
171216

172217
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'
218+
if (r.status === 'missing_test') return 'Missing test'
219+
if (r.status === 'missing_types' || r.status == 'missing_request_type') return 'Missing type'
176220
return `${r.passingRequest}/${r.totalRequest}`
177221
}
178222

179223
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'
224+
if (r.status === 'missing_test') return 'Missing test'
225+
if (r.status === 'missing_types' || r.status == 'missing_response_type') return 'Missing type'
183226
return `${r.passingResponse}/${r.totalResponse}`
184227
}
185228

.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
}

.github/workflows/code-format.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v4
1212

13-
- name: Use Node.js 20
13+
- name: Use Node.js 22
1414
uses: actions/setup-node@v4
1515
with:
16-
node-version: 20
16+
node-version: 22
1717

1818
- name: Install
1919
run: |

.github/workflows/compiler-rs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v4
1616

17-
- name: Use Node.js 20
17+
- name: Use Node.js 22
1818
uses: actions/setup-node@v4
1919
with:
20-
node-version: 20
20+
node-version: 22
2121

2222
- name: Install deps
2323
run: |

.github/workflows/compiler.test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v4
1515

16-
- name: Use Node.js 20
16+
- name: Use Node.js 22
1717
uses: actions/setup-node@v4
1818
with:
19-
node-version: 20
19+
node-version: 22
2020

2121
- name: Install deps
2222
run: |

.github/workflows/generate.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ jobs:
3434
token: ${{ secrets.PAT }}
3535
persist-credentials: true
3636

37-
- name: Setup Node 20
37+
- name: Setup Node 22
3838
uses: actions/setup-node@v4
3939
with:
40-
node-version: 20
40+
node-version: 22
4141
cache: npm
4242
cache-dependency-path: '**/package-lock.json'
4343

0 commit comments

Comments
 (0)