Skip to content

Commit

Permalink
Merged with main, moved package.json to the root.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed May 13, 2024
1 parent 7971664 commit c4546f3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 20 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/test.yml → .github/workflows/tests-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ env:
OPENSEARCH_INITIAL_ADMIN_PASSWORD: BobgG7YrtsdKf9M

jobs:
integ-tests:
name: Build and Test
tests-spec:
name: Build and Test Spec
runs-on: ubuntu-latest
permissions: write-all

Expand All @@ -21,12 +21,11 @@ jobs:
node-version: '20'

- name: Build
working-directory: ./tools
run: |-
mkdir -p ../build
npm install
npm run merge -- --source ../spec --output ../build/opensearch-openapi.yaml
npm run merge -- --source ../spec --output ../build/opensearch-openapi-tested.yaml --x-include=x-tested
npm run merge -- --source ./spec --output ./build/opensearch-openapi.yaml
npm run merge -- --source ./spec --output ./build/opensearch-openapi-tested.yaml --x-include=x-tested
- name: Build and Run Docker Container
run: |
Expand All @@ -39,9 +38,8 @@ jobs:
curl -ks -u "admin:$OPENSEARCH_INITIAL_ADMIN_PASSWORD" https://localhost:9200/ | jq
- name: Test
working-directory: ./tools
run: |-
npm run dredd -- --user "admin:$OPENSEARCH_INITIAL_ADMIN_PASSWORD" ../build/opensearch-openapi-tested.yaml https://localhost:9200
npm run dredd -- --user "admin:$OPENSEARCH_INITIAL_ADMIN_PASSWORD" ./build/opensearch-openapi-tested.yaml https://localhost:9200
- name: Gather Test Coverage
id: test-coverage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tools Testing
name: Test Tools

on:
push:
Expand All @@ -11,7 +11,7 @@ on:
- 'tools/**'

jobs:
tools-tests:
tests-tools:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint:spec": "ts-node tools/src/linter/lint.ts",
"lint": "eslint .",
"test": "jest",
"dredd": "dredd --hookfiles=../tests/**/*.js"
"dredd": "dredd --hookfiles=./tests/**/*.js"
},
"dependencies": {
"@apidevtools/swagger-parser": "^10.1.0",
Expand Down
6 changes: 3 additions & 3 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ docker run -d -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" -e "OPEN
Generate the spec and run `dredd` from inside [tools](../tools).

```
npm run merge -- --source ../spec --output ../build/opensearch-openapi-tested.yaml --x-include=x-tested
npm run dredd -- --user "admin:BobgG7YrtsdKf9M" ../build/opensearch-openapi-tested.yaml https://localhost:9200
npm run merge -- --source ./spec --output ../build/opensearch-openapi-tested.yaml --x-include=x-tested
npm run dredd -- --user "admin:BobgG7YrtsdKf9M" ./build/opensearch-openapi-tested.yaml https://localhost:9200
```

## Writing Tests
Expand Down Expand Up @@ -60,4 +60,4 @@ For `GET` APIs, provide an example for the default response (`cat.help@200` in t

## Github Actions

Tests run on pull requests via [test.yml](../.github/workflows/test.yml).
Tests run on pull requests via [tests-spec.yml](../.github/workflows/tests-spec.yml).
4 changes: 2 additions & 2 deletions tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ npm run merge -- --source ./spec --output ./build/opensearch-openapi.yaml

As a shortcut, if those parameters are not provided, the tool will use the default values:

- `../spec` as the root path (i.e. the repo's [spec folder](../spec))
- `./build/opensearch-openapi.yaml` as the output path
- `spec` as the root path (i.e. the repo's [spec folder](../spec))
- `build/opensearch-openapi.yaml` as the output path

```bash
npm run merge
Expand Down
10 changes: 5 additions & 5 deletions tools/tests/merger/OpenApiMerger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ test('merge()', async () => {
})

test('merge(x-xyz)', async () => {
const merger = new OpenApiMerger('./test/merger/fixtures/spec/', { x_include: ['x-xyz'] })
merger.merge('./test/merger/opensearch-openapi-x-xyz.yaml')
expect(fs.readFileSync('./test/merger/opensearch-openapi-x-xyz.yaml', 'utf8'))
.toEqual(fs.readFileSync('./test/merger/fixtures/expected-x-xyz.yaml', 'utf8'))
fs.unlinkSync('./test/merger/opensearch-openapi-x-xyz.yaml')
const merger = new OpenApiMerger('./tools/tests/merger/fixtures/spec/', { x_include: ['x-xyz'] })
merger.merge('./tools/tests/merger/opensearch-openapi-x-xyz.yaml')
expect(fs.readFileSync('./tools/tests/merger/opensearch-openapi-x-xyz.yaml', 'utf8'))
.toEqual(fs.readFileSync('./tools/tests/merger/fixtures/expected-x-xyz.yaml', 'utf8'))
fs.unlinkSync('./tools/tests/merger/opensearch-openapi-x-xyz.yaml')
})

0 comments on commit c4546f3

Please sign in to comment.