Skip to content

Commit

Permalink
[BACKPORT 2.21.1.3269][PLAT-13690] Fix openapi bundle failure due to …
Browse files Browse the repository at this point in the history
…redocly dependency on openapi-sampler

Summary:
Original commit: 1333618 / D34498
https://yugabyte.slack.com/archives/C048Z7EDH0F/p1713971854833549

The jenkins builds started failing with an error:
```
[2024-04-24T14:52:24.048Z] /share/jenkins/workspace/github-yugabyte-db-alma8-master-clang17-release/yugabyte-db/managed/src/main/resources/openapi /share/jenkins/workspace/github-yugabyte-db-alma8-master-clang17-release/yugabyte-db/managed/scripts
[2024-04-24T14:52:24.048Z] Running bundle on openapi spec ...
[2024-04-24T14:52:24.048Z] npx: installed 197 in 12.668s
[2024-04-24T14:52:24.048Z] Unexpected token '?'
[2024-04-24T14:52:24.048Z] cp: cannot stat 'tmp/openapi_bundle.yaml': No such file or directory
```
Could reproduce locally after switching to `nvm use v12.22.12`:
```
[sneelakantan@dev-server-sneelakantan ~]$ redocly
/nfusr/dev-server/sneelakantan/.nvm/versions/node/v12.22.12/lib/node_modules/openapi-sampler/dist/openapi-sampler.js:791
    pattern = ((_pattern$match = pattern.match(/\/(.+?)\//)) === null || _pattern$match === void 0 ? void 0 : _pattern$match[1]) ?? ''; // Remove frontslash from front and back of RegExp
                                                                                                                                  ^

SyntaxError: Unexpected token '?'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at /nfusr/dev-server/sneelakantan/.nvm/versions/node/v12.22.12/lib/node_modules/@redocly/cli/node_modules/redoc/bundles/redoc.lib.js:41:72746
    at /nfusr/dev-server/sneelakantan/.nvm/versions/node/v12.22.12/lib/node_modules/@redocly/cli/node_modules/redoc/bundles/redoc.lib.js:1807:3444
    at /nfusr/dev-server/sneelakantan/.nvm/versions/node/v12.22.12/lib/node_modules/@redocly/cli/node_modules/redoc/bundles/redoc.lib.js:1807:3449
```
Figured out a recent change in [email protected] (dependency of redocly/cli) that is causing above error (Redocly/openapi-sampler#153). So forcing to use the older version of [email protected] here to workaround this build error.

Test Plan: Ran build locally. Will monitor jenkins phab pipeline.

Reviewers: skurapati, rmadhavan, steve.varnau, dshubin, daniel, svarshney

Reviewed By: daniel

Subscribers: yugaware, dshubin

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D34867
  • Loading branch information
subramanian-neelakantan committed May 8, 2024
1 parent e32f226 commit 806c286
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions managed/scripts/openapi_bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ echo "Running bundle on openapi spec ..."
tmp_out_file=tmp/openapi_bundle.yaml
rm -f $tmp_out_file
# using redocly version 1.0.2 since 1.1.0 onwards requires node version >=14.19.0
# but jenkins runs node v12.22.12
$NPM_BIN/npx @redocly/[email protected] bundle openapi_split.yaml --output $tmp_out_file
# but jenkins runs node v12.22.12.
# Faced an issue with a newly released [email protected] on node v12.22.12.
# So picking the older version [email protected] explicitly.
$NPM_BIN/npx -p [email protected] -p @redocly/[email protected] \
redocly bundle openapi_split.yaml --output $tmp_out_file
cmp -s $tmp_out_file ../openapi.yaml
if [ $? -ne 0 ]; then
cp $tmp_out_file ../openapi.yaml
Expand Down
6 changes: 4 additions & 2 deletions managed/scripts/openapi_lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ for file in $OPENAPI_PATH $OPENAPI_PUBLIC_PATH
do
echo "Running lint on openapi spec: ${file}"
# using redocly version 1.0.2 since 1.1.0 onwards requires node version >=14.19.0
# but jenkins runs node v12.22.12
$NPM_BIN/npx @redocly/[email protected] lint \
# but jenkins runs node v12.22.12.
# Faced an issue with a newly released [email protected] on node v12.22.12.
# So picking the older version [email protected] explicitly.
$NPM_BIN/npx -p [email protected] -p @redocly/[email protected] redocly lint \
--format=stylish --config=../src/main/resources/openapi_lint.yaml ${file}
if [ $? -ne 0 ];
then
Expand Down

0 comments on commit 806c286

Please sign in to comment.