Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: wip, introduce "respect" #1910

Draft
wants to merge 49 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
50fe753
feat: add respect to cli
DmitryAnansky Feb 17, 2025
c4bd1f8
chore: prettier
DmitryAnansky Feb 17, 2025
9da1361
chore: changes to e2e and rename to respect-core
DmitryAnansky Feb 18, 2025
93eea33
feat: remove respect auth
DmitryAnansky Feb 18, 2025
4120c13
fix: add ignored module
DmitryAnansky Feb 18, 2025
d5237a4
chore: add files
DmitryAnansky Feb 18, 2025
4255688
fix: type issue in utils
DmitryAnansky Feb 18, 2025
4d6c58b
fix: update all e2e tests
DmitryAnansky Feb 18, 2025
d0808a1
chore: renaming
DmitryAnansky Feb 18, 2025
dcfda54
chore: fix and simplify go-to logic
RomanHotsiy Feb 18, 2025
56b3065
chore: fix lint and unit tests
RomanHotsiy Feb 18, 2025
1811b2b
chore: fix e2e for new goto
RomanHotsiy Feb 18, 2025
9c8d3bb
chore: fix scripts to support respect-core
tatomyr Feb 18, 2025
cfea176
fix parser:generate
tatomyr Feb 18, 2025
af5d36d
chore: rename ResultObject type
RomanHotsiy Feb 18, 2025
87b909a
chore: remove todos
DmitryAnansky Feb 18, 2025
359acbe
chore: sync package-lock
RomanHotsiy Feb 18, 2025
181ced2
chore: fix some lint errors
RomanHotsiy Feb 18, 2025
a1ce4dc
chore: add secret
RomanHotsiy Feb 18, 2025
fb33e5f
chore: prettier fix
DmitryAnansky Feb 18, 2025
fd12f38
chore: add abnf-parser to prettierignore
RomanHotsiy Feb 18, 2025
433476e
chore: publish respect-core snaphot to npm
tatomyr Feb 18, 2025
ce0b758
chore: comment ignored e2e snapshot and update regexp
DmitryAnansky Feb 18, 2025
47efc31
fix: update cert regexp
DmitryAnansky Feb 18, 2025
b15e97f
chore: try fixing publish and yarn smokes
tatomyr Feb 18, 2025
6afb2e3
chore: try fixing publish
tatomyr Feb 18, 2025
0aef0be
chore: try fixing publish and remove smokes for node 14 and 16
tatomyr Feb 18, 2025
0f69ed8
chore: fix docker smoke test
tatomyr Feb 18, 2025
2dcbe9d
chore: improve README and CONTRIBUTING files
tatomyr Feb 18, 2025
cfa0d98
fix: cookies from workflows and step are not set to the request (#1918)
DmitryAnansky Feb 19, 2025
6e620ff
chore: update respect command handler (#1920)
tatomyr Feb 19, 2025
c9ebd0e
fix: the $file decorator resolves wrong path to the file (#1921)
DmitryAnansky Feb 19, 2025
422a9a4
chore: improve performance (#1924)
tatomyr Feb 20, 2025
8fca0e4
fix: kebab case command options & mtls path & remove residensy (#1925)
DmitryAnansky Feb 20, 2025
365516c
chore: cleanup resources folder (#1926)
DmitryAnansky Feb 20, 2025
467836f
fix: revert dynamic imports
DmitryAnansky Feb 20, 2025
154f0a2
chore: add dynamic import back
DmitryAnansky Feb 20, 2025
c822d0e
chore: rename workflowId to workflowName and also targetWorkflow (#1927)
RomanHotsiy Feb 20, 2025
61b3877
chore: update package lock (#1929)
tatomyr Feb 20, 2025
7cd0a37
feat: remove extendend option from generate-arazzo command (#1930)
DmitryAnansky Feb 20, 2025
1ff444f
chore: fix e2e snapshots escape seq
RomanHotsiy Feb 21, 2025
6f78ff4
chore: simplify nested workflows output and flow
RomanHotsiy Feb 21, 2025
6a32a97
chore: verbose flag was lost for nested workflows (#1934)
RomanHotsiy Feb 21, 2025
3b5ea04
chore: refactor types, descriptions and names (#1932)
tatomyr Feb 21, 2025
a2f95ac
chore: improve tests (#1935)
tatomyr Feb 21, 2025
656c429
feat: resolve server url (#1936)
DmitryAnansky Feb 21, 2025
fda76db
chore: implement new json output and improve counting of steps
RomanHotsiy Feb 21, 2025
f92ec30
chore: use json server test (#1937)
tatomyr Feb 21, 2025
dec8062
chore: improve performance (#1941)
tatomyr Feb 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 4 additions & 6 deletions .github/workflows/performance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches:
- main

env:
CI: true
REDOCLY_TELEMETRY: off

jobs:
latest-vs-next:
runs-on: ubuntu-latest
Expand All @@ -29,9 +33,6 @@ jobs:
- run: redocly --version
- name: Run Benchmark
run: hyperfine -i --warmup 3 'redocly lint packages/core/src/benchmark/benches/rebilly.yaml' 'redocly-next lint packages/core/src/benchmark/benches/rebilly.yaml' --export-markdown benchmark_check.md --export-json benchmark_check.json
env:
CI: true
REDOCLY_TELEMETRY: off

- name: Comment PR
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
Expand Down Expand Up @@ -67,9 +68,6 @@ jobs:
npm test # This command is generated and injected into package.json in the previous step.
cat benchmark_check.md
npm run chart # Creates benchmark_chart.md with the performance bar chart.
env:
CI: true
REDOCLY_TELEMETRY: off

- name: Comment PR
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
Expand Down
28 changes: 1 addition & 27 deletions .github/workflows/smoke-plugins.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Plugins smoke tests
name: Smoke tests

on:
pull_request:
Expand Down Expand Up @@ -64,29 +64,3 @@ jobs:
with:
node-version: 18
- run: bash ./__tests__/smoke-plugins/run-smoke.sh

run-smoke-plugins--npm--node-16:
needs: prepare-smoke-plugins
runs-on: ubuntu-latest
steps:
- uses: actions/cache@v3
with:
path: __tests__/smoke-plugins/
key: cache-plugins-${{ github.run_id }}-${{ github.run_attempt }}
- uses: actions/setup-node@v3
with:
node-version: 16
- run: bash ./__tests__/smoke-plugins/run-smoke.sh

run-smoke-plugins--npm--node-14:
needs: prepare-smoke-plugins
runs-on: ubuntu-latest
steps:
- uses: actions/cache@v3
with:
path: __tests__/smoke-plugins/
key: cache-plugins-${{ github.run_id }}-${{ github.run_attempt }}
- uses: actions/setup-node@v3
with:
node-version: 14
- run: bash ./__tests__/smoke-plugins/run-smoke.sh
25 changes: 25 additions & 0 deletions .github/workflows/smoke-rebilly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Smoke tests

on:
pull_request:
types: [opened, synchronize, reopened]

env:
CI: true
REDOCLY_TELEMETRY: off

jobs:
run-smoke-rebilly:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 22
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run Rebilly smoke test
run: npm run smoke:rebilly
env:
SANDBOX_REBILLY_TOKEN: ${{ secrets.SANDBOX_REBILLY_TOKEN }}
13 changes: 12 additions & 1 deletion .github/workflows/snapshot-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ jobs:
# Update Core package version
jq ".version = \"$VERSION\"" packages/core/package.json > tmp.json && mv tmp.json packages/core/package.json

# Update CLI package version and the Core dependency
# Update Respect Core package version and dependencies
jq ".version = \"$VERSION\"" packages/respect-core/package.json > tmp.json && mv tmp.json packages/respect-core/package.json
jq ".dependencies[\"@redocly/openapi-core\"] = \"$VERSION\"" packages/respect-core/package.json > tmp.json && mv tmp.json packages/respect-core/package.json

# Update CLI package version and dependencies
jq ".version = \"$VERSION\"" packages/cli/package.json > tmp.json && mv tmp.json packages/cli/package.json
jq ".dependencies[\"@redocly/openapi-core\"] = \"$VERSION\"" packages/cli/package.json > tmp.json && mv tmp.json packages/cli/package.json
jq ".dependencies[\"@redocly/respect-core\"] = \"$VERSION\"" packages/cli/package.json > tmp.json && mv tmp.json packages/cli/package.json

# Add comment with installation instructions
COMMENT="📦 A new experimental version **v$VERSION** of Redocly CLI has been published for testing.
Expand Down Expand Up @@ -66,5 +71,11 @@ jobs:

cd packages/core
npm publish --tag snapshot
sleep 10

cd ../respect-core
npm publish --tag snapshot
sleep 10

cd ../cli
npm publish --tag snapshot
12 changes: 4 additions & 8 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
branches:
- main

env:
CI: true
REDOCLY_TELEMETRY: off

jobs:
build-and-unit:
runs-on: ubuntu-latest
Expand All @@ -18,16 +22,12 @@ jobs:
cache: 'npm'
- name: Install dependencies
run: npm ci
env:
CI: true
- name: Typecheck
run: npm run typecheck
- name: Unit Tests
run: npm run unit
- name: E2E Tests
run: npm run e2e
env:
CI: true

cli-package-test:
runs-on: ubuntu-latest
Expand All @@ -39,8 +39,6 @@ jobs:
cache: 'npm'
- name: Install dependencies
run: npm ci
env:
CI: true
- name: Prepare CLI and Core packages
run: npm run pack:prepare
- name: Install CLI Package
Expand Down Expand Up @@ -76,7 +74,5 @@ jobs:
cache: 'npm'
- name: Install dependencies
run: npm ci
env:
CI: true
- run: npm run eslint
- run: npm run prettier:check
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ output/
*.tgz
redoc-static.html
packages/cli/README.md
.env
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ lib/
output/
*snapshot.js
packages/core/src/rules/__tests__/fixtures/invalid-yaml.yaml
packages/respect-core/src/modules/runtime-expressions/abnf-parser.js
__tests__/webpack-bundle/bundle-workflows/metafile.json
benchmark/api-definitions/
LICENSE.md
55 changes: 41 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Redocly CLI Contributing Guide

Hi! We're really excited that you are interested in contributing to Redocly CLI. Before submitting your contribution though, please make sure to take a moment and read through the following guidelines.
Hi! We're really excited that you are interested in contributing to Redocly CLI.
Before submitting your contribution though, please make sure to take a moment and read through the following guidelines.

- [Issue reporting guidelines](#issue-reporting-guidelines)
- [Pull request guidelines](#pull-request-guidelines)
Expand Down Expand Up @@ -48,7 +49,8 @@ npm install # or npm i

To compile the code, run `npm run compile`. To do that on the fly, run `npm run watch` in a separate thread.

To run a specific CLI command, use `npm run cli`, e.g. `npm run cli -- lint resources/museum.yaml --format=stylish`. Please notice that the extra `--` is required to pass arguments to the CLI rather than to NPM itself.
To run a specific CLI command, use `npm run cli`, e.g. `npm run cli -- lint resources/museum.yaml --format=stylish`.
Please notice that the extra `--` is required to pass arguments to the CLI rather than to NPM itself.

Format your code with `npm run prettier` before committing.

Expand All @@ -70,15 +72,15 @@ To test local changes as a package, you can use the following steps:

1. Optionally, bump the version of the packages ([see details](#version-updating)).

1. Run `npm run pack:prepare` in the repository's root. This generates **redocly-cli.tgz** and **openapi-core.tgz** files and makes some changes to **packages/cli/package.json** file.
1. Run `npm run pack:prepare` in the repository's root.
This generates **redocly-cli.tgz**, **respect-core.tgz**, and **openapi-core.tgz** files.

1. Copy **redocly-cli.tgz** file to a destination folder and then run `npm install redocly-cli.tgz` there to install Redocly CLI. To install `openapi-core` do the same but with **openapi-core.tgz** file.

Don't forget to revert the changes to **package.json** files later.
1. Copy those **.tgz** files to a destination folder and then run `npm install redocly-cli.tgz` there to install Redocly CLI. To install `openapi-core` do the same but with **openapi-core.tgz** file.

## Contribute documentation

Additions and updates to our documentation are very welcome. You can find the documentation in the `docs/` folder, and this is published to https://redocly.com/docs/cli/ as part of our main website.
Additions and updates to our documentation are very welcome.
You can find the documentation in the `docs/` folder, and this is published to https://redocly.com/docs/cli/ as part of our main website.

To preview your documentation changes locally:

Expand All @@ -92,11 +94,14 @@ redocly preview

By default, you can access the docs preview at http://localhost:4000 or http://127.0.0.1:4000.

> Please note that currently the custom markdoc tags used in the main website are not available in the local preview version, and links that point to the wider website do show as errors when using a local platform. The pull request workflows generate a full preview, so rest assured that you are able to check everything is in good shape before we review and merge your changes.
> Please note that currently the custom markdoc tags used in the main website are not available in the local preview version, and links that point to the wider website do show as errors when using a local platform.
> The pull request workflows generate a full preview, so rest assured that you are able to check everything is in good shape before we review and merge your changes.

### Prose linting

We are proud of our docs. When you open a pull request, we lint the prose using [Vale](https://vale.sh/). You can also install this tool locally and run it from the root of the project with:
We are proud of our docs.
When you open a pull request, we lint the prose using [Vale](https://vale.sh/).
You can also install this tool locally and run it from the root of the project with:

```bash
vale docs/
Expand All @@ -112,7 +117,9 @@ We use [Markdownlint](https://github.com/DavidAnson/markdownlint) to check that

### Markdown link checking

We use [`mlc`](https://github.com/becheran/mlc) to check the links in the `docs/` folder. This tool runs automatically on every pull request, but you can also run it locally if you want to. Visit the project homepage to find the installation instructions for your platform, and then run the command like this:
We use [`mlc`](https://github.com/becheran/mlc) to check the links in the `docs/` folder.
This tool runs automatically on every pull request, but you can also run it locally if you want to.
Visit the project homepage to find the installation instructions for your platform, and then run the command like this:

```bash
mlc docs/
Expand All @@ -122,7 +129,8 @@ It only checks links within the local docs (it can't check links to other docs s

## Built-in rules changes

After adding a new rule, make sure it is added to the `minimal`, `recommended`, `recommended-strict` (the same as the previous but with warnings turned into error) and `all` rulesets with appropriate severity levels. The defaults are `off` for `minimal` and `recommended` and `error` for `all`.
After adding a new rule, make sure it is added to the `minimal`, `recommended`, `recommended-strict` (the same as the previous but with warnings turned into error) and `all` rulesets with appropriate severity levels.
The defaults are `off` for `minimal` and `recommended` and `error` for `all`.
Also add the rule to the built-in rules list in [the config types tree](./packages/core/src/types/redocly-yaml.ts).

Separately, open a merge request with the corresponding documentation changes.
Expand All @@ -139,11 +147,16 @@ Environment variables should not affect the **core** package logic.

### Command line arguments

Use them to provide some arguments that are specific to a certain command. Think of them as modifiers. They should not affect the **core** package logic.
Use them to provide some arguments that are specific to a certain command.
Think of them as modifiers.
They should not affect the **core** package logic.

### Configuration file

The **redocly.yaml** file is the most flexible way of providing arguments. Please use it to provide arguments that are common for all the commands, for a specific command, or for a specific API. It could be used for providing arguments for both **cli** and **core** packages. Please refer to the [configuration file](https://redocly.com/docs/cli/configuration/) documentation for more details.
The **redocly.yaml** file is the most flexible way of providing arguments.
Please use it to provide arguments that are common for all the commands, for a specific command, or for a specific API.
It could be used for providing arguments for both **cli** and **core** packages.
Please refer to the [configuration file](https://redocly.com/docs/cli/configuration/) documentation for more details.

## Exit codes

Expand Down Expand Up @@ -183,6 +196,17 @@ To update snapshots, run `npm run e2e -- -u`.

If you made any changes, make sure to compile the code before running the tests.

### Performance benchmark

To run the performance benchmark locally, you should have `hyperfine` (v1.16.1+) installed on your machine.
Prepare the local build, go to the `benchmark` folder, clean it up, do the preparations, and run the actual benchmark:

```sh
(npm run compile && npm run pack:prepare && cd benchmark/ && git clean -dX -f . && git clean -dX -ff . && npm i && npm run make-test && npm test)
```

You might need to adjust the CLI versions that need to be tested in the `benchmark/package.json` file.

## Project structure

- **`__mocks__`**: contains basic mocks for e2e tests.
Expand Down Expand Up @@ -217,14 +241,17 @@ If you made any changes, make sure to compile the code before running the tests.
- **`packages/core/src/types`**: contains the common types for several OpenAPI versions.
- **`packages/core/src/typings`**: contains the common Typescript typings.

- **`packages/respect-core`**: contains the Respect core package.

- **`resources`**: contains some example API descriptions and configuration files that might be useful for testing.

## Release flow

We use [Changesets](https://github.com/changesets/changesets) flow.
After merging a PR with a changeset, the release PR is automatically created.

If the pipelines are not starting, close and reopen the PR. Merging that PR triggers the release process.
If the pipelines are not starting, close and reopen the PR.
Merging that PR triggers the release process.

### Revert a release

Expand Down
42 changes: 13 additions & 29 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
FROM node:alpine

WORKDIR /build

# Copy files required for npm install only
COPY package.json package-lock.json /build/
COPY packages/cli/package.json /build/packages/cli/
COPY packages/core/package.json /build/packages/core/
COPY packages/cli/bin/ /build/packages/cli/bin/

RUN npm ci --no-optional --ignore-scripts

# Copy rest of the files
COPY . /build/
RUN npm run prepare

# Install redocly-cli globally, similar to npm install --global @redocly/cli
# but the local package is used here
RUN apk update && apk add jq && \
apk add git && \
COPY . .
RUN apk add --no-cache jq git && \
npm ci --no-optional --ignore-scripts && \
npm run prepare && \
npm run pack:prepare && \
npm install --global redocly-cli.tgz

# npm pack in the previous RUN command does not include these assets
RUN cp packages/cli/src/commands/preview-docs/preview-server/default.hbs /usr/local/lib/node_modules/@redocly/cli/lib/commands/preview-docs/preview-server/default.hbs && \
cp packages/cli/src/commands/preview-docs/preview-server/hot.js /usr/local/lib/node_modules/@redocly/cli/lib/commands/preview-docs/preview-server/hot.js && \
cp packages/cli/src/commands/build-docs/template.hbs /usr/local/lib/node_modules/@redocly/cli/lib/commands/build-docs/template.hbs

# Clean up to reduce image size
RUN npm cache clean --force && rm -rf /build
npm install --global redocly-cli.tgz && \
cp packages/cli/src/commands/preview-docs/preview-server/default.hbs \
packages/cli/src/commands/preview-docs/preview-server/hot.js \
/usr/local/lib/node_modules/@redocly/cli/lib/commands/preview-docs/preview-server/ && \
cp packages/cli/src/commands/build-docs/template.hbs \
/usr/local/lib/node_modules/@redocly/cli/lib/commands/build-docs/ && \
# Clean up to reduce image size
npm cache clean --force && rm -rf /build

WORKDIR /spec

ENTRYPOINT [ "redocly" ]

ENTRYPOINT ["redocly"]
ENV REDOCLY_ENVIRONMENT=docker
Loading
Loading