-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Theo Truong <[email protected]>
- Loading branch information
Showing
38 changed files
with
10,271 additions
and
1,040 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Generate API from Spec | ||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "0 0 * * 0" # Every Sunday at midnight GMT | ||
jobs: | ||
generate-api: | ||
if: ${{ github.repository == 'opensearch-project/opensearch-js' }} | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./api_generator | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
fetch-depth: 0 | ||
|
||
- name: Config git to rebase | ||
run: git config --global pull.rebase true | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Generate API | ||
run: |- | ||
npm run download_spec | ||
npm run generate_api | ||
- name: Get current date | ||
id: date | ||
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | ||
|
||
- name: GitHub App token | ||
id: github_app_token | ||
uses: tibdex/[email protected] | ||
with: | ||
app_id: ${{ secrets.APP_ID }} | ||
private_key: ${{ secrets.APP_PRIVATE_KEY }} | ||
|
||
- name: Create pull request | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
token: ${{ steps.github_app_token.outputs.token }} | ||
commit-message: "Updated opensearch-js to reflect the latest OpenSearch API spec (${{ env.date }})" | ||
title: "[AUTOCUT] Update opensearch-js to reflect the latest OpenSearch API spec" | ||
body: | | ||
Update `opensearch-js` to reflect the latest [OpenSearch API spec](https://github.com/opensearch-project/opensearch-api-specification/releases/download/main-latest/opensearch-openapi.yaml). | ||
Date: ${{ env.date }} | ||
branch: update-api-from-spec | ||
base: main | ||
signoff: true | ||
labels: | | ||
autocut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Lint API Generator | ||
on: | ||
pull_request: | ||
paths: | ||
- 'api_generator/**' | ||
- '.github/workflows/lint_api_generator.yml' | ||
jobs: | ||
lint-api-generator: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./api_generator | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
fetch-depth: 0 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Lint API Generator | ||
run: npm run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
opensearch-openapi.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import path from 'path' | ||
import { fileURLToPath } from 'url' | ||
import { FlatCompat } from '@eslint/eslintrc' | ||
import pluginJs from '@eslint/js' | ||
import licenseHeader from 'eslint-plugin-license-header' | ||
|
||
// mimic CommonJS variables -- not needed if using CommonJS | ||
const _filename = fileURLToPath(import.meta.url) | ||
const _dirname = path.dirname(_filename) | ||
const compat = new FlatCompat({ baseDirectory: _dirname, recommendedConfig: pluginJs.configs.recommended }) | ||
|
||
export default [ | ||
pluginJs.configs.recommended, | ||
...compat.extends('standard-with-typescript'), | ||
{ | ||
files: ['**/*.{js,ts}'], | ||
plugins: { | ||
'license-header': licenseHeader | ||
}, | ||
rules: { | ||
'@typescript-eslint/consistent-indexed-object-style': 'error', | ||
'@typescript-eslint/consistent-type-assertions': 'error', | ||
'@typescript-eslint/dot-notation': 'error', | ||
'@typescript-eslint/explicit-function-return-type': 'error', | ||
'@typescript-eslint/naming-convention': ['error', | ||
{ selector: 'classProperty', modifiers: ['static', 'readonly'], format: ['UPPER_CASE'], leadingUnderscore: 'allow' }, | ||
{ selector: 'memberLike', modifiers: ['public'], format: ['snake_case'], leadingUnderscore: 'forbid' }, | ||
{ selector: 'memberLike', modifiers: ['private', 'protected'], format: ['snake_case'], leadingUnderscore: 'require' }, | ||
{ selector: 'variableLike', format: ['snake_case', 'UPPER_CASE'], leadingUnderscore: 'allow' }, | ||
{ selector: 'typeLike', format: ['PascalCase'] }, | ||
{ selector: 'objectLiteralProperty', format: null }, | ||
{ selector: 'typeProperty', format: null } | ||
], | ||
'@typescript-eslint/no-confusing-void-expression': 'error', | ||
'@typescript-eslint/no-dynamic-delete': 'error', | ||
'@typescript-eslint/no-invalid-void-type': 'error', | ||
'@typescript-eslint/no-non-null-assertion': 'error', | ||
'@typescript-eslint/no-unnecessary-type-assertion': 'error', | ||
'@typescript-eslint/no-unsafe-argument': 'error', | ||
'@typescript-eslint/prefer-nullish-coalescing': 'error', | ||
'@typescript-eslint/require-array-sort-compare': 'error', | ||
'@typescript-eslint/strict-boolean-expressions': ['error', | ||
{ | ||
allowString: true, | ||
allowNumber: true, | ||
allowNullableObject: true, | ||
allowNullableBoolean: true, | ||
allowNullableString: false, | ||
allowNullableNumber: false, | ||
allowNullableEnum: false, | ||
allowAny: false, | ||
allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false | ||
} | ||
], | ||
'array-callback-return': 'off', | ||
'new-cap': 'off', | ||
'no-return-assign': 'error', | ||
'object-shorthand': 'error', | ||
'license-header/header': [ | ||
'error', | ||
[ | ||
'/*', | ||
' * Copyright OpenSearch Contributors', | ||
' * SPDX-License-Identifier: Apache-2.0', | ||
' *', | ||
' * The OpenSearch Contributors require contributions made to', | ||
' * this file be licensed under the Apache-2.0 license or a', | ||
' * compatible open source license.', | ||
' *', | ||
' */' | ||
] | ||
] | ||
} | ||
} | ||
] |
Oops, something went wrong.