Skip to content

Commit c1d6624

Browse files
pquentingithub-actions[bot]
authored andcommitted
Download recordings using branch, not version (#2690)
(cherry picked from commit 3722b31)
1 parent 0ae2a65 commit c1d6624

File tree

5 files changed

+20
-18
lines changed

5 files changed

+20
-18
lines changed

.github/workflows/validate-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
else
5858
branch=$GITHUB_REF_NAME
5959
fi
60-
node scripts/upload-recording/download.js --branch latest
60+
node scripts/upload-recording/download.js --branch $branch
6161
node scripts/clone-elasticsearch/index.js --branch $branch
6262
env:
6363
GCS_CREDENTIALS: ${{ secrets.GCS_CREDENTIALS }}

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
SHELL := /bin/bash
22

33
validate: ## Validate a given endpoint request or response
4-
@node compiler/run-validations.js --api $(api) --type $(type) --stack-version $(stack-version)
4+
@node compiler/run-validations.js --api $(api) --type $(type) --branch $(branch)
55

66
validate-no-cache: ## Validate a given endpoint request or response without local cache
7-
@node compiler/run-validations.js --api $(api) --type $(type) --stack-version $(stack-version) --no-cache
7+
@node compiler/run-validations.js --api $(api) --type $(type) --branch $(branch) --no-cache
88

99
generate: ## Generate the output spec
1010
@echo ">> generating the spec .."

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,16 @@ git clone https://github.com/elastic/elasticsearch-specification.git
204204
git clone https://github.com/elastic/clients-flight-recorder.git
205205

206206
cd elasticsearch-specification
207-
# this will validate the xpack.info request type against the 8.1.0 stack version
208-
make validate api=xpack.info type=request stack-version=8.1.0-SNAPSHOT
207+
# this will validate the xpack.info request type against the main branch of Elasticsearch
208+
make validate api=xpack.info type=request branch=main
209209

210-
# this will validate the xpack.info request and response types against the 8.1.0 stack version
211-
make validate api=xpack.info stack-version=8.1.0-SNAPSHOT
210+
# this will validate the xpack.info request and response types against the 8.15 branch
211+
make validate api=xpack.info branch=8.15
212212
```
213213

214214
The last command above will install all the dependencies and run, download
215215
the test recordings and finally validate the specification.
216-
If you need to download the recordings again, run `make validate-no-cache api=xpack.info type=request stack-version=8.1.0-SNAPSHOT`.
216+
If you need to download the recordings again, run `make validate-no-cache api=xpack.info type=request branch=main`.
217217

218218
Once you see the errors, you can fix the original definition in `/specification`
219219
and then run the command again until the types validator does not trigger any new error.

compiler/run-validations.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ async function run () {
6464
const isStale = lastRun.getTime() + DAY < Date.now()
6565

6666
if (typeof argv.api !== 'string') {
67-
spinner.fail('You must specify the api, for example: \'make validate api=index type=request stack-version=8.1.0-SNAPSHOT\'')
67+
spinner.fail('You must specify the api, for example: \'make validate api=index type=request branch=main\'')
6868
process.exit(1)
6969
}
7070

@@ -75,15 +75,16 @@ async function run () {
7575

7676
// if true it's because the make target wasn't configured with a type argument
7777
if (argv.type !== true && argv.type !== 'request' && argv.type !== 'response') {
78-
spinner.fail('You must specify the type (request or response), for example: \'make validate api=index type=request stack-version=8.1.0-SNAPSHOT\'')
78+
spinner.fail('You must specify the type (request or response), for example: \'make validate api=index type=request branch=main\'')
7979
process.exit(1)
8080
}
8181

82-
if (typeof argv['stack-version'] !== 'string') {
83-
spinner.fail('You must specify the stack version, for example: \'make validate api=index type=request stack-version=8.1.0-SNAPSHOT\'')
82+
if (typeof argv.branch !== 'string' && typeof argv.branch !== 'number') {
83+
spinner.fail('You must specify the branch, for example: \'make validate api=index type=request branch=main\'')
8484
process.exit(1)
8585
}
8686

87+
8788
const isFlightRecorderCloned = await $`[[ -d ${path.join(__dirname, '..', '..', 'clients-flight-recorder')} ]]`.exitCode === 0
8889
if (!isFlightRecorderCloned) {
8990
spinner.text = 'It looks like you didn\'t cloned the flight recorder, doing that for you'
@@ -165,7 +166,8 @@ async function run () {
165166

166167
spinner.text = 'Running validations'
167168

168-
const branchName = argv['stack-version'].startsWith('7.') ? '7.x' : argv['stack-version'].slice(0, 3)
169+
const branchArg = argv.branch.toString()
170+
const branchName = branchArg.startsWith('7.') ? '7.x' : branchArg
169171

170172
if (noCache || isStale || metadata.branchName !== branchName) {
171173
metadata.lastRun = new Date()
@@ -175,7 +177,7 @@ async function run () {
175177
await $`node ${path.join(uploadRecordingsPath, 'download.js')} --branch ${branchName}`
176178

177179
spinner.text = 'Fetching artifacts'
178-
await $`node ${path.join(cloneEsPath, 'index.js')} --version ${argv['stack-version']}`
180+
await $`node ${path.join(cloneEsPath, 'index.js')} --branch ${argv['branch']}`
179181
}
180182

181183
cd(tsValidationPath)
@@ -188,7 +190,7 @@ async function run () {
188190
} else {
189191
flags.push(`--${argv.type}`)
190192
}
191-
const output = await $`STACK_VERSION=${argv['stack-version']} node ${path.join(tsValidationPath, 'index.js')} --api ${argv.api} ${flags}`
193+
const output = await $`node ${path.join(tsValidationPath, 'index.js')} --api ${argv.api} --branch ${branchName} ${flags}`
192194

193195
cd(path.join(compilerPath, '..'))
194196
if (output.exitCode === 0) {

docs/validation-example.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The example assumes that you have already performed the necessary steps to run a
1616
if not, take a look at the [README](./README.md).
1717

1818
```sh
19-
make validate api=index type=request stack-version=8.1.0-SNAPSHOT
19+
make validate api=index type=request branch=main
2020
```
2121

2222
You will see an output like the following:
@@ -82,7 +82,7 @@ open it with your favourite editor and perform the fix
8282
Finally run the validation again:
8383

8484
```sh
85-
make validate api=index type=request stack-version=8.1.0-SNAPSHOT
85+
make validate api=index type=request branch=main
8686
```
8787

88-
If there are no more errors, open a pr with the fix.
88+
If there are no more errors, open a pull request with the fix.

0 commit comments

Comments
 (0)