[HTTP/OAS] Commit OAS snapshot#183338
Conversation
| expect(result.status).toBe(200); | ||
| expect(result.body).toMatchObject(includes); | ||
| expect(result.body).not.toMatchObject(excludes); | ||
| excludes.forEach((exclude) => { |
There was a problem hiding this comment.
So... this test was not working as expected 🙈
| title: 'Kibana HTTP APIs', | ||
| version: '0.0.0', // TODO get a better version here | ||
| pathStartsWith, | ||
| filters: { pathStartsWith, excludePathsMatching, access, version }, |
There was a problem hiding this comment.
Added a few more filtering options. Most notably: excludePathsMatching, access and version
| * (dodges issues with open handles), and so that we can harvest logs and feed them into | ||
| * the logger when debugging. | ||
| */ | ||
| export function kibana(log: SomeDevLog) { |
There was a problem hiding this comment.
Mostly copy-pasta from packages/kbn-check-mappings-update-cli/src/compatibility/extract_mappings_from_plugins.ts
There was a problem hiding this comment.
Oh yeah, that whole forking the process logic again 🙈.
Note blocker in any way, but shall we try to factorize the process forking / worker code at some point (do we know how many time that code got duplicated)?
There was a problem hiding this comment.
Just this time again to my knowledge, I guess we could factorize some parts of it. Do you think they could live in something like @kbn/dev-utils?
packages/kbn-capture-oas-snapshot-cli/src/run_capture_oas_snapshot_cli.ts
Outdated
Show resolved
Hide resolved
| const getRouterDefaults = () => ({ | ||
| isVersioned: false, | ||
| path: '/foo/{id}', | ||
| path: '/foo/{id}/{path*}', |
There was a problem hiding this comment.
Test special * syntax
There was a problem hiding this comment.
❯ jq ".paths | length" ./oas_docs/bundle.json
141
There was a problem hiding this comment.
Might want to consider starting smaller...
There was a problem hiding this comment.
If size becomes an issue, we could always consider storing it in a different repo as long as we could also figure out the cadence for publishing it
There was a problem hiding this comment.
I just meant it's a lot of paths that need to be audited/quality controlled 😅 . Pretty sure there is a lot of room to grow here. For a start we can just include the paths that are ready for docs.
|
When I run linters on the bundled.json file, I get some errors that I think are noteworthy. For example:
This relates to the required field described in https://spec.openapis.org/oas/v3.0.3#response-object
I think is just related to the placement of the
These seem to have missing definitions. |
|
/ci |
|
@elasticmachine merge upstream |
| const schemas = handler ? extractValidationSchemaFromVersionedHandler(handler) : undefined; | ||
| let version: undefined | string; | ||
| let handler: undefined | VersionedRouterRoute['handlers'][0]; | ||
| let versions: string[] = route.handlers.map(({ options: { version: v } }) => v).sort(); |
There was a problem hiding this comment.
Not sure if relevant, but for internal versions, I think just using sort() may be too naive? E.g [1, 2, ...., 10].sort() => 1, 10, 2, 3...
And it seems we're then using that sorting for slicing L47
const versionIdx = versions.indexOf(filters.version);
if (versionIdx === -1) return { paths };
versions = versions.slice(0, versionIdx + 1);(but are we even generating for internal APIs?)
There was a problem hiding this comment.
Yea, you found a bug in the logic, will fix!
| packages/kbn-calculate-auto @elastic/obs-ux-management-team | ||
| packages/kbn-calculate-width-from-char-count @elastic/kibana-visualizations | ||
| x-pack/plugins/canvas @elastic/kibana-presentation | ||
| packages/kbn-capture-oas-snapshot-cli @elastic/kibana-core |
There was a problem hiding this comment.
Hum, this is strange, the files under that new packages aren't considered as owned by Core for the PR review 🤔. I had to remove the code owner filtering.... IIRC it used to work.
| * (dodges issues with open handles), and so that we can harvest logs and feed them into | ||
| * the logger when debugging. | ||
| */ | ||
| export function kibana(log: SomeDevLog) { |
There was a problem hiding this comment.
Oh yeah, that whole forking the process logic again 🙈.
Note blocker in any way, but shall we try to factorize the process forking / worker code at some point (do we know how many time that code got duplicated)?
| * @example Given 'internal' versions ["1", "10", "2"] it will return ["1", "2", "10] | ||
| * @example Given 'public' versions ["2023-01-01", "2002-10-10", "2005-01-01"] it will return ["2002-10-10", "2005-01-01", "2023-01-01"] | ||
| */ | ||
| export const sort = (versions: string[], access: 'public' | 'internal') => { |
There was a problem hiding this comment.
Sort of related to this PR, @pgayvallet found a bug in this logic that was not treating internal versions correctly. Updated and tried to preserve existing APIs as far as possible.
| * Provide a TS file as the src of a NodeJS Worker with some built-in handling | ||
| * of std streams and debugging. | ||
| */ | ||
| export function startTSWorker<Message>({ log, src, cwd = REPO_ROOT }: StartTSWorkerArgs) { |
There was a problem hiding this comment.
New utility that does all the RX piping and starting of a node js worker for us.
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Unknown metric groupsAPI count
History
To update your PR or re-run it, just comment with: |
It's not an actual dependency of downstream steps, but was added more to provide as a cost cutting gate. However, there are times it delays downstream steps without any added value. Here's the provenance for `check_oas_snapshot` in the pull-request pipeline. ### 1. OAS snapshot capture first added to CI (inside "Checks") - [PR #183338](#183338) / commit [`975eeed255d0`](975eeed255d0) (May 30, 2024) — "[HTTP/OAS] Commit OAS snapshot" - Added `.buildkite/scripts/steps/capture_oas_snapshot.sh` and wired it into `.buildkite/scripts/steps/checks.sh` (so it ran as part of the Checks step, not a standalone pipeline step yet). ### 2. Standalone "Check OAS Snapshot" step added to PR pipeline - [PR #196534](#196534) / commit [`2fbc843e0d69`](2fbc843e0d69) (Oct 17, 2024) — "[ci] Extract OAS check + add retry" - Motivation (from the PR summary): the capture step was flaky and was breaking Checks; they extracted it into its own heavy step (starts ES+Kibana) and added retries. - This is where it gets added as its own step in `.buildkite/pipelines/pull_request/base.yml`, running `.buildkite/scripts/steps/checks/capture_oas_snapshot.sh`. ### 3. `depends_on: check_oas_snapshot` added across PR test suite pipelines - [PR #198452](#198452) / commit [`cbb211abe0cd`](cbb211abe0cd) (Nov 4, 2024) — "[ci] Run checks before tests" - This commit added `key: check_oas_snapshot` in `.buildkite/pipelines/pull_request/base.yml` and updated many PR suite pipeline YAMLs to depend on it (and on `checks`) before running. - Example change: `.buildkite/pipelines/pull_request/response_ops.yml` adds `- check_oas_snapshot` under `depends_on` in that commit. Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
It's not an actual dependency of downstream steps, but was added more to provide as a cost cutting gate. However, there are times it delays downstream steps without any added value. Here's the provenance for `check_oas_snapshot` in the pull-request pipeline. ### 1. OAS snapshot capture first added to CI (inside "Checks") - [PR elastic#183338](elastic#183338) / commit [`975eeed255d0`](elastic@975eeed255d0) (May 30, 2024) — "[HTTP/OAS] Commit OAS snapshot" - Added `.buildkite/scripts/steps/capture_oas_snapshot.sh` and wired it into `.buildkite/scripts/steps/checks.sh` (so it ran as part of the Checks step, not a standalone pipeline step yet). ### 2. Standalone "Check OAS Snapshot" step added to PR pipeline - [PR elastic#196534](elastic#196534) / commit [`2fbc843e0d69`](elastic@2fbc843e0d69) (Oct 17, 2024) — "[ci] Extract OAS check + add retry" - Motivation (from the PR summary): the capture step was flaky and was breaking Checks; they extracted it into its own heavy step (starts ES+Kibana) and added retries. - This is where it gets added as its own step in `.buildkite/pipelines/pull_request/base.yml`, running `.buildkite/scripts/steps/checks/capture_oas_snapshot.sh`. ### 3. `depends_on: check_oas_snapshot` added across PR test suite pipelines - [PR elastic#198452](elastic#198452) / commit [`cbb211abe0cd`](elastic@cbb211abe0cd) (Nov 4, 2024) — "[ci] Run checks before tests" - This commit added `key: check_oas_snapshot` in `.buildkite/pipelines/pull_request/base.yml` and updated many PR suite pipeline YAMLs to depend on it (and on `checks`) before running. - Example change: `.buildkite/pipelines/pull_request/response_ops.yml` adds `- check_oas_snapshot` under `depends_on` in that commit. Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
It's not an actual dependency of downstream steps, but was added more to provide as a cost cutting gate. However, there are times it delays downstream steps without any added value. Here's the provenance for `check_oas_snapshot` in the pull-request pipeline. ### 1. OAS snapshot capture first added to CI (inside "Checks") - [PR elastic#183338](elastic#183338) / commit [`975eeed255d0`](elastic@975eeed255d0) (May 30, 2024) — "[HTTP/OAS] Commit OAS snapshot" - Added `.buildkite/scripts/steps/capture_oas_snapshot.sh` and wired it into `.buildkite/scripts/steps/checks.sh` (so it ran as part of the Checks step, not a standalone pipeline step yet). ### 2. Standalone "Check OAS Snapshot" step added to PR pipeline - [PR elastic#196534](elastic#196534) / commit [`2fbc843e0d69`](elastic@2fbc843e0d69) (Oct 17, 2024) — "[ci] Extract OAS check + add retry" - Motivation (from the PR summary): the capture step was flaky and was breaking Checks; they extracted it into its own heavy step (starts ES+Kibana) and added retries. - This is where it gets added as its own step in `.buildkite/pipelines/pull_request/base.yml`, running `.buildkite/scripts/steps/checks/capture_oas_snapshot.sh`. ### 3. `depends_on: check_oas_snapshot` added across PR test suite pipelines - [PR elastic#198452](elastic#198452) / commit [`cbb211abe0cd`](elastic@cbb211abe0cd) (Nov 4, 2024) — "[ci] Run checks before tests" - This commit added `key: check_oas_snapshot` in `.buildkite/pipelines/pull_request/base.yml` and updated many PR suite pipeline YAMLs to depend on it (and on `checks`) before running. - Example change: `.buildkite/pipelines/pull_request/response_ops.yml` adds `- check_oas_snapshot` under `depends_on` in that commit. Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
Close #181992
Summary
First iteration of a CLI to capture an OAS snapshot.
How to test
Run
node ./scripts/capture_oas_snapshot.js --update --include-path /api/statusand see result inoas_docs/bundle.json.If you have the bump CLI installed you can preview the hosted output with
bump preview ./oas_docs/bundle.jsonNotes
version,access(public/internal) and excluding paths explicitly to the OAS generation libpackages/kbn-check-mappings-update-cli/api/statusfor now, waiting for other paths to add missing parts