From 8d3d99045a98f09fea08f283c95ab491439b03ce Mon Sep 17 00:00:00 2001 From: Andrew Tatomyr Date: Wed, 28 Aug 2024 12:44:50 +0300 Subject: [PATCH] chore: update issue template and add changesets validation, improve benchmark output (#1679) --- .github/ISSUE_TEMPLATE/bug_report.md | 4 ++++ .github/workflows/docs-tests.yaml | 2 +- .github/workflows/performance.yaml | 3 ++- CONTRIBUTING.md | 12 ++++++------ benchmark/.gitignore | 1 + benchmark/chart.mjs | 26 ++++++++++++++++++++++++++ benchmark/package.json | 3 +++ 7 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 benchmark/chart.mjs diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 9cb8d660..d2e8abbe 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -39,6 +39,10 @@ At a minimum, please state the specification version(s) you're using (e.g. 2.0, +**OS, environment** + + + **Additional context** diff --git a/.github/workflows/docs-tests.yaml b/.github/workflows/docs-tests.yaml index ea1fef7f..6b8cb1ec 100644 --- a/.github/workflows/docs-tests.yaml +++ b/.github/workflows/docs-tests.yaml @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v4 - uses: errata-ai/vale-action@reviewdog with: - files: '["README.md", "docs"]' + files: '["README.md", "docs", ".changeset"]' filter_mode: file fail_on_error: true diff --git a/.github/workflows/performance.yaml b/.github/workflows/performance.yaml index 9c21758a..dd952e87 100644 --- a/.github/workflows/performance.yaml +++ b/.github/workflows/performance.yaml @@ -66,6 +66,7 @@ jobs: cd benchmark/ 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 @@ -74,5 +75,5 @@ jobs: if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} uses: thollander/actions-comment-pull-request@v2 with: - filePath: benchmark/benchmark_check.md + filePath: benchmark/benchmark_chart.md comment_tag: historical-versions-comparison diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 847522e9..a3c788ed 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -122,7 +122,7 @@ 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` 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 `builtInRulesList` in [the config types tree](../packages/core/src/types/redocly-yaml.ts). Separately, open a merge request with the corresponding documentation changes. @@ -149,11 +149,11 @@ The **redocly.yaml** file is the most flexible way of providing arguments. Pleas The application maintains the following exit codes. -| Exit code | Description | -| --------- | ------------------------ | -| 0 | Success | -| 1 | Command execution error | -| 2 | Config resolving failure | +| Exit code | Description | +| --------- | ------------------------- | +| 0 | Success | +| 1 | Command execution error | +| 2 | Config resolution failure | ## Tests diff --git a/benchmark/.gitignore b/benchmark/.gitignore index 0dcbb7e1..7d90fe0b 100644 --- a/benchmark/.gitignore +++ b/benchmark/.gitignore @@ -4,3 +4,4 @@ package-lock.json test-command.txt benchmark_check.md benchmark_check.json +benchmark_chart.md diff --git a/benchmark/chart.mjs b/benchmark/chart.mjs new file mode 100644 index 00000000..e6caee62 --- /dev/null +++ b/benchmark/chart.mjs @@ -0,0 +1,26 @@ +import fs from 'node:fs'; + +const content = fs.readFileSync('benchmark_check.json', 'utf8'); +const json = JSON.parse(content); +const arr = json.results.map((r) => [ + r.command.replace(/^node node_modules\/([^/]+)\/.*/, (_, cliVersion) => cliVersion), + r.mean, +]); +const min = Math.min(...arr.map(([_, mean]) => mean)); +const max = Math.max(...arr.map(([_, mean]) => mean)); + +const constructBarForChart = (x) => { + const length = Math.floor(x * 30); + return '▓' + '▓'.repeat(length); +}; + +const output = [ + '| CLI Version | Performance benchmark (test duration) |', + '|---|---|', + ...arr.map( + ([cliVersion, mean]) => + `| ${cliVersion} | ${constructBarForChart((mean - min) / (max - min))} |` + ), +].join('\n'); + +process.stdout.write(output); diff --git a/benchmark/package.json b/benchmark/package.json index 7b6d23ea..9bb7001e 100644 --- a/benchmark/package.json +++ b/benchmark/package.json @@ -3,6 +3,7 @@ "version": "1.0.0", "description": "Test benchmark for Redocly CLI", "scripts": { + "chart": "node chart.mjs > benchmark_chart.md", "make-test": "bash make-test-command.sh" }, "dependencies": { @@ -26,6 +27,8 @@ "cli-1.17": "npm:@redocly/cli@1.17.1", "cli-1.18": "npm:@redocly/cli@1.18.1", "cli-1.19": "npm:@redocly/cli@1.19.0", + "cli-1.20": "npm:@redocly/cli@1.20.1", + "cli-1.21": "npm:@redocly/cli@1.21.1", "cli-next": "file:../redocly-cli.tgz" } }