Skip to content

Commit

Permalink
chore: update issue template and add changesets validation, improve b…
Browse files Browse the repository at this point in the history
…enchmark output (#1679)
  • Loading branch information
tatomyr authored Aug 28, 2024
1 parent b53b648 commit 8d3d990
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ At a minimum, please state the specification version(s) you're using (e.g. 2.0,

<!-- What version of `node.js` are you using? -->

**OS, environment**

<!-- What OS are you using? -->

**Additional context**

<!-- Add any other context about the problem here. -->
2 changes: 1 addition & 1 deletion .github/workflows/docs-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/performance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions benchmark/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ package-lock.json
test-command.txt
benchmark_check.md
benchmark_check.json
benchmark_chart.md
26 changes: 26 additions & 0 deletions benchmark/chart.mjs
Original file line number Diff line number Diff line change
@@ -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);
3 changes: 3 additions & 0 deletions benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -26,6 +27,8 @@
"cli-1.17": "npm:@redocly/[email protected]",
"cli-1.18": "npm:@redocly/[email protected]",
"cli-1.19": "npm:@redocly/[email protected]",
"cli-1.20": "npm:@redocly/[email protected]",
"cli-1.21": "npm:@redocly/[email protected]",
"cli-next": "file:../redocly-cli.tgz"
}
}

1 comment on commit 8d3d990

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 77.5% 4739/6115
🟡 Branches 65.84% 1968/2989
🟡 Functions 71.78% 781/1088
🟡 Lines 77.69% 4471/5755

Test suite run success

765 tests passing in 108 suites.

Report generated by 🧪jest coverage report action from 8d3d990

Please sign in to comment.