chore: add performance benchmark with hyperfine (#1089)

This commit is contained in:
Andrew Tatomyr
2023-05-22 15:31:39 +03:00
committed by GitHub
parent 2079ea681c
commit a94defec49
3 changed files with 67 additions and 94 deletions

View File

@@ -10,42 +10,23 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "14.x"
- name: cache node modules
uses: actions/cache@v1
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 i -g npm@7.0.2
- run: npm install
node-version: 18
cache: 'npm'
- run: npm ci
- run: npm test
deploy:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "14.x"
- name: cache node modules
uses: actions/cache@v1
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: Install npm@7.0.2
run: npm i -g npm@7.0.2
- name: Install dependencies
run: npm install
node-version: 18
cache: 'npm'
- run: npm ci
- name: Bundle into single file
run: npm run webpack-bundle
@@ -70,28 +51,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "14.x"
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'
node-version: 18
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- name: cache node modules
uses: actions/cache@v1
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: Install npm@7.0.2
run: npm i -g npm@7.0.2
- name: Install dependencies
run: npm install
- run: npm ci
- name: Publish to NPM
run: cd packages/core && npm publish && cd ../cli && npm publish
@@ -130,4 +97,4 @@ jobs:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
labels: ${{ steps.docker_meta.outputs.labels }}

36
.github/workflows/performance.yaml vendored Normal file
View File

@@ -0,0 +1,36 @@
name: Performance Benchmark
on:
pull_request:
branches:
- main
jobs:
hyperfine:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- name: Install Dependencies
run: npm ci
- name: Install External
run: npm i -g hyperfine @redocly/cli@latest
- name: Prepare
run: |
jq '.bin = {"redocly-next":"bin/cli.js"} | .name = "@redocly/cli-next"' packages/cli/package.json > __tmp__.json
mv __tmp__.json packages/cli/package.json
cat packages/cli/package.json
npm run pack:prepare
npm i -g redocly-cli.tgz
- run: redocly-next --version
- 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
- name: Comment PR
uses: thollander/actions-comment-pull-request@v2
with:
filePath: benchmark_check.md
comment_tag: hyperfine-comparison

View File

@@ -12,19 +12,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache dependencies
uses: actions/cache@v3
- uses: actions/setup-node@v3
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-${{ hashFiles('package-lock.json') }}
npm-
- name: Environments
run: |
echo
echo Using Node $(node -v), NPM $(npm -v)
echo
node-version: 18
cache: 'npm'
- name: Install dependencies
run: npm ci
env:
@@ -43,19 +34,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache dependencies
uses: actions/cache@v3
- uses: actions/setup-node@v3
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-${{ hashFiles('package-lock.json') }}
npm-
- name: Environments
run: |
echo
echo Using Node $(node -v), NPM $(npm -v)
echo
node-version: 18
cache: 'npm'
- name: Install dependencies
run: npm ci
env:
@@ -82,14 +64,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache dependencies
uses: actions/cache@v3
- uses: actions/setup-node@v3
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-${{ hashFiles('package-lock.json') }}
npm-
node-version: 18
cache: 'npm'
- name: Coverage Report
uses: artiomtr/jest-coverage-report-action@v2.0.8
continue-on-error: true
@@ -102,14 +80,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache dependencies
uses: actions/cache@v3
- uses: actions/setup-node@v3
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-${{ hashFiles('package-lock.json') }}
npm-
node-version: 18
cache: 'npm'
- name: Install dependencies
run: npm ci
env:
@@ -120,14 +94,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache dependencies
uses: actions/cache@v3
- uses: actions/setup-node@v3
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-${{ hashFiles('package-lock.json') }}
npm-
node-version: 18
cache: 'npm'
- name: Install dependencies
run: npm ci
env: