Skip to content

make validate: Download recordings using branch, not version #2690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
SHELL := /bin/bash

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

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

generate: ## Generate the output spec
@echo ">> generating the spec .."
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,16 @@ git clone https://github.com/elastic/elasticsearch-specification.git
git clone https://github.com/elastic/clients-flight-recorder.git

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

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

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

Once you see the errors, you can fix the original definition in `/specification`
and then run the command again until the types validator does not trigger any new error.
Expand Down
4 changes: 2 additions & 2 deletions compiler/run-validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ async function run () {

spinner.text = 'Running validations'

const branchName = argv['stack-version'].startsWith('7.') ? '7.x' : argv['stack-version'].slice(0, 3)
const branchName = argv['branch'].startsWith('7.') ? '7.x' : argv['branch']

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

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

cd(tsValidationPath)
Expand Down
6 changes: 3 additions & 3 deletions docs/validation-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The example assumes that you have already performed the necessary steps to run a
if not, take a look at the [README](./README.md).

```sh
make validate api=index type=request stack-version=8.1.0-SNAPSHOT
make validate api=index type=request branch=main
```

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

```sh
make validate api=index type=request stack-version=8.1.0-SNAPSHOT
make validate api=index type=request branch=main
```

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