Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Hi! We're really excited that you are interested in contributing to Redoc. Befor
- [Issue Reporting Guidelines](#issue-reporting-guidelines)
- [Pull Request Guidelines](#pull-request-guidelines)
- [Development Setup](#development-setup)
- [Commonly used NPM scripts](#commonly-used-npm-scripts)
- [Commonly used pnpm scripts](#commonly-used-pnpm-scripts)
- [Project Structure](#project-structure)

## Issue Reporting Guidelines
Expand All @@ -17,58 +17,58 @@ Hi! We're really excited that you are interested in contributing to Redoc. Befor
Before submitting a pull request, please make sure the following is done:

1. Fork the repository and create your branch from main.
2. Run `npm install` in the repository root.
2. Run `pnpm install` in the repository root.
3. If you’ve fixed a bug or added code that should be tested, add tests!
4. Ensure the test suite passes (`npm test`). Tip: `npm test -- --watch TestName` is helpful in development.
5. Format your code with prettier (`npm run prettier`).
4. Ensure the test suite passes (`pnpm test`). Tip: `pnpm test -- --watch TestName` is helpful in development.
5. Format your code with prettier (`pnpm run prettier`).

## Development Setup

You need [Node.js](http://nodejs.org) at `v12.0.0+`.
You need [Node.js](http://nodejs.org) at `v18.0.0+`.

After cloning the repo, run:

```bash
$ npm install # or npm
pnpm install
```

### Commonly used NPM scripts
### Commonly used pnpm scripts

``` bash
# dev-server, watch and auto reload playground
$ npm start
$ pnpm start

# start playground app in production environment
$ npm run start:prod
$ pnpm run start:prod

# runt tslint
$ npm run lint
$ pnpm run lint

# try autofix tslint issues
$ npm run lint -- --fix
$ pnpm run lint -- --fix

# run unit tests
$ npm run unit
$ pnpm run unit

# run e2e tests
$ npm run e2e
$ pnpm run e2e
# Make sure you have created bundle before running e2e test
# E.g. run `npm run bundle` and wait for the finishing process.
# E.g. run `pnpm run bundle` and wait for the finishing process.

# open cypress UI to debug e2e test
$ npm run cy:open
$ pnpm run cy:open

# run the unit tests (includes linting and license checks)
$ npm test
$ pnpm test

# prepare bundles
$ npm run bundle
$ pnpm run bundle

# format the code using prettier
$ npm run prettier
$ pnpm run prettier

# auto-generate changelog
$ npm run changelog
$ pnpm run changelog
```

There are some other scripts available in the `scripts` section of the `package.json` file.
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/docs-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
name: markdownlint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DavidAnson/markdownlint-cli2-action@v15
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: DavidAnson/markdownlint-cli2-action@07035fd053f7be764496c0f8d8f9f41f98305101 # v22.0.0
with:
config: .markdownlint.yaml
globs: |
Expand All @@ -20,7 +20,7 @@ jobs:
name: vale action
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: errata-ai/vale-action@reviewdog
with:
files: '["README.md", "docs"]'
Expand All @@ -30,8 +30,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Markup Link Checker (mlc)
uses: becheran/mlc@v0.16.1
uses: becheran/mlc@7ec24825cefe0c9c8c6bac48430e1f69e3ec356e # v1.2.0
with:
args: ./docs
24 changes: 19 additions & 5 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
name: Tests e2e

on: [push]
on: [push, pull_request]

jobs:
build-and-e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm ci
- run: npm run bundle
- run: npm run e2e
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: 18
cache: "pnpm"

- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
with:
version: 10

- run: pnpm install --frozen-lockfile

- run: pnpm run bundle

- run: pnpm run e2e
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
uses: crazy-max/ghaction-docker-meta@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: redocly/redoc

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0

- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
context: .
file: ./config/docker/Dockerfile
Expand Down
85 changes: 41 additions & 44 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,42 @@ jobs:
bundle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Cache node modules
uses: actions/cache@v3
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-${{ hashFiles('package-lock.json') }}
npm-
- run: npm ci
- run: npm run bundle
node-version: 18
cache: "pnpm"
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
with:
version: 10
- run: pnpm install --frozen-lockfile
- run: pnpm run bundle
- name: Store bundle artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: bundles
path: bundles
retention-days: 1
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm ci
- run: npm test
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- run: pnpm install --frozen-lockfile
- run: pnpm test
e2e-tests:
needs: [bundle]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm ci
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- run: pnpm install --frozen-lockfile
- name: Download bundled artifact
uses: actions/download-artifact@v4
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: bundles
path: bundles
- run: npm run e2e
- run: pnpm run e2e
check-version:
name: Check Version
runs-on: ubuntu-latest
Expand All @@ -52,43 +52,40 @@ jobs:
changed: ${{ steps.check.outputs.changed }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
- name: Check if version has been updated
id: check
uses: EndBug/version-check@v2.0.1
uses: EndBug/version-check@5102328418c0130d66ca712d755c303e93368ce2 # v2.1.7
with:
file-url: https://cdn.jsdelivr.net/npm/redoc/package.json
file-url: https://cdn.jsdelivr.net/pnpm/redoc/package.json
static-checking: localIsNew
publish:
name: Publish to NPM
needs: [check-version]
if: needs.check-version.outputs.changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: 18
cache: "pnpm"
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
- uses: actions/checkout@v3
version: 10
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Download bundled artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: bundles
path: bundles
- name: Cache node modules
uses: actions/cache@v3
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-${{ hashFiles('package-lock.json') }}
npm-
- name: Before deploy
run: npm ci && npm run declarations
run: pnpm install --frozen-lockfile && pnpm run declarations
- name: Publish to NPM
run: npm publish
run: pnpm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Expand All @@ -99,17 +96,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Configure AWS
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v6.0.0
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Download all artifact
uses: actions/download-artifact@v4
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
- name: Publish to S3
run: npm run publish-cdn
run: pnpm run publish-cdn

invalidate-cache:
name: Clear cache
Expand All @@ -118,9 +115,9 @@ jobs:
if: needs.check-version.outputs.changed == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Configure AWS
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v6.0.0
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand Down
22 changes: 17 additions & 5 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
name: Unit Tests

on: [push]
on: [push, pull_request]

jobs:
build-and-unit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm ci
- run: npm run bundle
- run: npm test
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: 18
cache: "pnpm"

- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
with:
version: 10

- run: pnpm install --frozen-lockfile

- run: pnpm test
6 changes: 3 additions & 3 deletions benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const localDistDir = './benchmark/revisions/local/bundles';
sh.rm('-rf', localDistDir);
console.log(`Building local dist: ${localDistDir}`);
sh.mkdir('-p', localDistDir);
exec(`npm run bundle:lib --output-path ${localDistDir}`);
exec(`pnpm run bundle:lib --output-path ${localDistDir}`);

const revisions = [];
for (const arg of args) {
Expand All @@ -33,7 +33,7 @@ console.log(`Writing config "${configDir}"`);
fs.writeFileSync(configDir, configFile);

console.log('Starting benchmark server');
const proc = spawn('npm', ['run', 'start:benchmark']);
const proc = spawn('pnpm', ['run', 'start:benchmark']);

proc.stdout.on('data', data => {
if (data.toString().indexOf('Compiled successfully') > -1) {
Expand Down Expand Up @@ -119,7 +119,7 @@ function buildRevisionDist(revision) {

const pwd = sh.pwd();
sh.cd(buildDir);
exec('npm uninstall cypress puppeteer && npm install && npm run bundle:lib');
exec('pnpm uninstall cypress puppeteer && pnpm install && pnpm run bundle:lib');
sh.cd(pwd);
return distDir;
}
Loading