Skip to content

Commit 6b36951

Browse files
authored
Use the standard src/tests paths, move package.json to the root. (#292)
* Moved package.json to root. Signed-off-by: dblock <[email protected]> * Use standard src/tests paths. Signed-off-by: dblock <[email protected]> * Moved source into tools/src and tests into tools/tests. Signed-off-by: dblock <[email protected]> --------- Signed-off-by: dblock <[email protected]>
1 parent 52463ce commit 6b36951

File tree

94 files changed

+100
-109
lines changed

Some content is hidden

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

94 files changed

+100
-109
lines changed

.github/workflows/build.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ jobs:
2121
node-version: '20'
2222

2323
- name: Build
24-
working-directory: ./tools
2524
run: |-
26-
mkdir -p ../build
25+
mkdir -p ./build
2726
npm install
28-
npm run merge -- --source ../spec --output ../build/opensearch-openapi.yaml
27+
npm run merge -- --source ./spec --output ./build/opensearch-openapi.yaml
2928
3029
- name: Extract Branch Name
3130
id: branch

.github/workflows/coverage-gather.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ jobs:
1515
- name: Checkout Repo
1616
uses: actions/checkout@v2
1717
- name: Build Spec
18-
working-directory: ./tools
1918
run: |-
20-
mkdir -p ../build
19+
mkdir -p ./build
2120
npm install
22-
npm run merge -- --source ../spec --output ../build/opensearch-openapi.yaml
21+
npm run merge -- --source ./spec --output ./build/opensearch-openapi.yaml
2322
- name: Build and Run Docker Container
2423
run: |
2524
docker build coverage --tag opensearch-with-api-plugin

.github/workflows/links.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ jobs:
1414
uses: lycheeverse/lychee-action@v1
1515
with:
1616
fail: true
17-
args: --base . --verbose --no-progress './**/*.yaml' './**/*.yml' './**/*.md' './**/*.json' './**/*.ts' --exclude-path ./tools/package-lock.json
17+
args: --base . --verbose --no-progress './**/*.yaml' './**/*.yml' './**/*.md' './**/*.json' './**/*.ts' --exclude-path ./package-lock.json

.github/workflows/lint.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,21 @@ on:
55
branches: ['**']
66
paths:
77
- 'spec/**'
8-
- 'tools/linter/**'
8+
- 'tools/src/linter/**'
99
pull_request:
1010
branches: ['**']
1111
paths:
1212
- 'spec/**'
13-
- 'tools/linter/**'
13+
- 'tools/src/linter/**'
1414

1515
jobs:
1616
lint-spec:
1717
runs-on: ubuntu-latest
18-
defaults:
19-
run:
20-
working-directory: tools
2118
steps:
2219
- uses: actions/checkout@v3
2320
- uses: actions/setup-node@v3
2421
with:
2522
node-version: 20.10.0
2623
- run: npm install
2724
- run: |
28-
npm run lint:spec -- --source ../spec
25+
npm run lint:spec -- --source ./spec

.github/workflows/tools.yml

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ on:
1313
jobs:
1414
tools-tests:
1515
runs-on: ubuntu-latest
16-
defaults:
17-
run:
18-
working-directory: tools
1916
steps:
2017
- uses: actions/checkout@v3
2118
- uses: actions/setup-node@v3

DEVELOPER_GUIDE.md

+1-1

_plugins/openapi.rb

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ module OpenAPI
22
def self.generate(_site, _payload)
33
return if @generated
44

5-
Dir.chdir('tools') do
6-
system 'npm install'
7-
system 'npm run merge -- --source ../spec --output ../_site/opensearch-openapi.yaml'
8-
end
5+
system 'npm install'
6+
system 'npm run merge -- --source ./spec --output ./_site/opensearch-openapi.yaml'
97

108
@generated = true
119
end
File renamed without changes.
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/** @type {import('ts-jest').JestConfigWithTsJest} */
22
module.exports = {
33
preset: 'ts-jest',
4-
testEnvironment: 'node'
4+
testEnvironment: 'node',
5+
moduleDirectories: ['node_modules', './tools/src']
56
}
File renamed without changes.

tools/package.json package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"author": "opensearch-project",
66
"license": "Apache-2.0",
77
"scripts": {
8-
"merge": "ts-node merger/merge.ts",
9-
"lint:spec": "ts-node linter/lint.ts",
8+
"merge": "ts-node tools/src/merger/merge.ts",
9+
"lint:spec": "ts-node tools/src/linter/lint.ts",
1010
"lint": "eslint .",
1111
"test": "jest"
1212
},

spec/_info.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$schema: ../json_schemas/_info.schema.yaml
1+
$schema: ./json_schemas/_info.schema.yaml
22

33
title: OpenSearch API Specification
44
version: 1.0.0

spec/_superseded_operations.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$schema: ../json_schemas/_superseded_operations.schema.yaml
1+
$schema: ./json_schemas/_superseded_operations.schema.yaml
22

33
/_opendistro/_alerting/destinations:
44
superseded_by: /_plugins/_alerting/destinations

tools/README.md

+7-7

tools/linter/InlineObjectSchemaValidator.ts tools/src/linter/InlineObjectSchemaValidator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type NamespacesFolder from './components/NamespacesFolder'
22
import type SchemasFolder from './components/SchemasFolder'
3-
import { type ValidationError } from '../types'
3+
import { type ValidationError } from 'types'
44
import { SchemaVisitor } from './utils/SpecificationVisitor'
55
import { is_ref, type MaybeRef, SpecificationContext } from './utils'
66
import { type OpenAPIV3 } from 'openapi-types'

tools/linter/SchemaRefsValidator.ts tools/src/linter/SchemaRefsValidator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type NamespacesFolder from './components/NamespacesFolder'
22
import type SchemasFolder from './components/SchemasFolder'
3-
import { type ValidationError } from '../types'
3+
import { type ValidationError } from 'types'
44

55
export default class SchemaRefsValidator {
66
namespaces_folder: NamespacesFolder

tools/linter/SpecValidator.ts tools/src/linter/SpecValidator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import SchemasFolder from './components/SchemasFolder'
22
import NamespacesFolder from './components/NamespacesFolder'
3-
import { type ValidationError } from '../types'
3+
import { type ValidationError } from 'types'
44
import SchemaRefsValidator from './SchemaRefsValidator'
55
import SupersededOperationsFile from './components/SupersededOperationsFile'
66
import InfoFile from './components/InfoFile'
File renamed without changes.

tools/linter/components/NamespaceFile.ts tools/src/linter/components/NamespaceFile.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { type OpenAPIV3 } from 'openapi-types'
2-
import { type OperationSpec, type ValidationError } from '../../types'
2+
import { type OperationSpec, type ValidationError } from 'types'
33
import OperationGroup from './OperationGroup'
44
import _ from 'lodash'
55
import Operation from './Operation'
6-
import { resolve_ref } from '../../helpers'
6+
import { resolve_ref } from '../../../helpers'
77
import FileValidator from './base/FileValidator'
88

99
const HTTP_METHODS = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace']

tools/linter/components/NamespacesFolder.ts tools/src/linter/components/NamespacesFolder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import NamespaceFile from './NamespaceFile'
2-
import { type ValidationError } from '../../types'
2+
import { type ValidationError } from 'types'
33
import FolderValidator from './base/FolderValidator'
44

55
export default class NamespacesFolder extends FolderValidator<NamespaceFile> {

tools/linter/components/Operation.ts tools/src/linter/components/Operation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type OperationSpec, type ValidationError } from '../../types'
1+
import { type OperationSpec, type ValidationError } from 'types'
22
import _ from 'lodash'
33
import ValidatorBase from './base/ValidatorBase'
44

tools/linter/components/OperationGroup.ts tools/src/linter/components/OperationGroup.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type Operation from './Operation'
2-
import { type ValidationError } from '../../types'
2+
import { type ValidationError } from 'types'
33
import ValidatorBase from './base/ValidatorBase'
44

55
export default class OperationGroup extends ValidatorBase {

tools/linter/components/Schema.ts tools/src/linter/components/Schema.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import ValidatorBase from './base/ValidatorBase'
22
import { type OpenAPIV3 } from 'openapi-types'
3-
import { type ValidationError } from '../../types'
3+
import { type ValidationError } from 'types'
44

55
const NAME_REGEX = /^[A-Za-z0-9]+$/
66

tools/linter/components/SchemaFile.ts tools/src/linter/components/SchemaFile.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import FileValidator from './base/FileValidator'
2-
import { type ValidationError } from '../../types'
2+
import { type ValidationError } from 'types'
33
import Schema from './Schema'
44
import { type OpenAPIV3 } from 'openapi-types'
55

tools/linter/components/SchemasFolder.ts tools/src/linter/components/SchemasFolder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import SchemaFile from './SchemaFile'
22
import FolderValidator from './base/FolderValidator'
3-
import { type ValidationError } from '../../types'
3+
import { type ValidationError } from 'types'
44

55
export default class SchemasFolder extends FolderValidator<SchemaFile> {
66
constructor (folder_path: string) {

tools/linter/components/base/FileValidator.ts tools/src/linter/components/base/FileValidator.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import ValidatorBase from './ValidatorBase'
2-
import { type ValidationError } from '../../../types'
2+
import { type ValidationError } from 'types'
33
import { type OpenAPIV3 } from 'openapi-types'
4-
import { read_yaml } from '../../../helpers'
4+
import { read_yaml } from '../../../../helpers'
55
import AJV from 'ajv'
66
import addFormats from 'ajv-formats'
77

tools/linter/components/base/FolderValidator.ts tools/src/linter/components/base/FolderValidator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'fs'
22
import ValidatorBase from './ValidatorBase'
33
import type FileValidator from './FileValidator'
4-
import { type ValidationError } from '../../../types'
4+
import { type ValidationError } from 'types'
55

66
export default class FolderValidator<F extends FileValidator> extends ValidatorBase {
77
folder_path: string

tools/linter/components/base/ValidatorBase.ts tools/src/linter/components/base/ValidatorBase.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type ValidationError } from '../../../types'
1+
import { type ValidationError } from 'types'
22
export default class ValidatorBase {
33
file: string
44
location: string | undefined

tools/linter/lint.ts tools/src/linter/lint.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { resolve } from 'path'
44

55
const command = new Command()
66
.description('Validate the OpenSearch multi-file spec.')
7-
.addOption(new Option('-s, --source <path>', 'path to the root folder of the multi-file spec').default(resolve(__dirname, '../../spec')))
7+
.addOption(new Option('-s, --source <path>', 'path to the root folder of the multi-file spec').default(resolve(__dirname, '../../../spec')))
88
.allowExcessArguments(false)
99
.parse()
1010

tools/linter/utils/index.ts tools/src/linter/utils/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type OpenAPIV3 } from 'openapi-types'
2-
import { type ValidationError } from '../../types'
2+
import { type ValidationError } from 'types'
33

44
export function is_ref<O extends object> (o: MaybeRef<O>): o is OpenAPIV3.ReferenceObject {
55
return '$ref' in o

tools/merger/GlobalParamsGenerator.ts tools/src/merger/GlobalParamsGenerator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { type OpenAPIV3 } from 'openapi-types'
22
import _ from 'lodash'
3-
import { read_yaml } from '../helpers'
3+
import { read_yaml } from '../../helpers'
44

55
export default class GlobalParamsGenerator {
66
global_params: Record<string, OpenAPIV3.ParameterObject>

tools/merger/OpenApiMerger.ts tools/src/merger/OpenApiMerger.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { type OpenAPIV3 } from 'openapi-types'
22
import fs from 'fs'
33
import _ from 'lodash'
4-
import { read_yaml, write_yaml } from '../helpers'
4+
import { read_yaml, write_yaml } from '../../helpers'
55
import SupersededOpsGenerator from './SupersededOpsGenerator'
66
import GlobalParamsGenerator from './GlobalParamsGenerator'
77

tools/merger/OpenDistro.ts tools/src/merger/OpenDistro.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { type HttpVerb, type OperationPath, type SupersededOperationMap } from '../types'
2-
import { read_yaml, write_yaml } from '../helpers'
1+
import { type HttpVerb, type OperationPath, type SupersededOperationMap } from 'types'
2+
import { read_yaml, write_yaml } from '../../helpers'
33

44
// One-time script to generate _superseded_operations.yaml file for OpenDistro
55
// Keeping this for now in case we need to update the file in the near future. Can be removed after a few months.

tools/merger/SupersededOpsGenerator.ts tools/src/merger/SupersededOpsGenerator.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { type OperationSpec, type SupersededOperationMap } from '../types'
1+
import { type OperationSpec, type SupersededOperationMap } from 'types'
22
import _ from 'lodash'
3-
import { read_yaml } from '../helpers'
3+
import { read_yaml } from '../../helpers'
44

55
export default class SupersededOpsGenerator {
66
superseded_ops: SupersededOperationMap

tools/merger/merge.ts tools/src/merger/merge.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { resolve } from 'path'
44

55
const command = new Command()
66
.description('Merges the multi-file OpenSearch spec into a single file for programmatic use.')
7-
.addOption(new Option('-s, --source <path>', 'path to the root folder of the multi-file spec').default(resolve(__dirname, '../../spec')))
8-
.addOption(new Option('-o, --output <path>', 'output file name').default(resolve(__dirname, '../../build/opensearch-openapi.yaml')))
7+
.addOption(new Option('-s, --source <path>', 'path to the root folder of the multi-file spec').default(resolve(__dirname, '../../../spec')))
8+
.addOption(new Option('-o, --output <path>', 'output file name').default(resolve(__dirname, '../../../build/opensearch-openapi.yaml')))
99
.allowExcessArguments(false)
1010
.parse()
1111

tools/types.ts tools/src/types.ts

File renamed without changes.

tools/test/linter/SupersededOperationsFile.test.ts

-11
This file was deleted.

tools/test/linter/fixtures/empty/_info.yaml

-4
This file was deleted.

tools/test/linter/fixtures/empty/_superseded_operations.yaml

-1
This file was deleted.

tools/test/merger/OpenApiMerger.test.ts

-10
This file was deleted.

tools/test/linter/InfoFile.test.ts tools/tests/linter/InfoFile.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import InfoFile from '../../linter/components/InfoFile'
1+
import InfoFile from 'linter/components/InfoFile'
22

33
test('validate()', () => {
4-
const validator = new InfoFile('./test/linter/fixtures/_info.yaml')
4+
const validator = new InfoFile('./tools/tests/linter/fixtures/_info.yaml')
55
expect(validator.validate()).toEqual([
66
{
77
file: 'fixtures/_info.yaml',

tools/test/linter/InlineObjectSchemaValidator.test.ts tools/tests/linter/InlineObjectSchemaValidator.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import SchemasFolder from '../../linter/components/SchemasFolder'
2-
import NamespacesFolder from '../../linter/components/NamespacesFolder'
3-
import InlineObjectSchemaValidator from '../../linter/InlineObjectSchemaValidator'
1+
import SchemasFolder from 'linter/components/SchemasFolder'
2+
import NamespacesFolder from 'linter/components/NamespacesFolder'
3+
import InlineObjectSchemaValidator from 'linter/InlineObjectSchemaValidator'
44

55
test('validate()', () => {
6-
const root_folder = './test/linter/fixtures/inline_object_schema_validator'
6+
const root_folder = './tools/tests/linter/fixtures/inline_object_schema_validator'
77
const namespaces_folder = new NamespacesFolder(`${root_folder}/namespaces`)
88
const schemas_folder = new SchemasFolder(`${root_folder}/schemas`)
99
const validator = new InlineObjectSchemaValidator(namespaces_folder, schemas_folder)

0 commit comments

Comments
 (0)