diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 85ab976..56fab20 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,16 +80,13 @@ jobs: - name: Generate Summary run: | cd scripts - npm start -- --results ../artifact > summary.txt - cat summary.txt + npm start -- --results ../artifact + cat summary.md - name: Create Release uses: softprops/action-gh-release@v1 with: tag_name: ${{ github.run_number }} - body_path: scripts/summary.txt + body_path: scripts/summary.md files: artifact/*.json draft: false prerelease: false - - uses: actions/upload-artifact@v3 - with: - path: scripts/summary.txt diff --git a/.gitignore b/.gitignore index 9b35f66..7f8a616 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ count java/ kotlin/ scala/ +scripts/summary.md CMD VERSION STATS \ No newline at end of file diff --git a/scripts/package-lock.json b/scripts/package-lock.json index c65b832..166db48 100644 --- a/scripts/package-lock.json +++ b/scripts/package-lock.json @@ -6,6 +6,7 @@ "": { "dependencies": { "human-readable": "^0.2.1", + "markdown-table": "^3.0.3", "minimist": "^1.2.8", "pretty-bytes": "^6.1.1", "pretty-time": "^1.1.0" @@ -35,6 +36,15 @@ "resolved": "https://registry.npmjs.org/human-readable/-/human-readable-0.2.1.tgz", "integrity": "sha512-uFtz4WZlB1M5xI45MZ5AjyAzfrrgLOdty4363Jd0LQ5NGXa+UiKaD0EQXQeDfCinodrpePFk/vKjzBlDTZdZQQ==" }, + "node_modules/markdown-table": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-3.0.3.tgz", + "integrity": "sha512-Z1NL3Tb1M9wH4XESsCDEksWoKTdlUafKc4pt0GRwjUyXaCFZ+dc3g2erqB6zm3szA2IUSi7VnPI+o/9jnxh9hw==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/minimist": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", diff --git a/scripts/package.json b/scripts/package.json index 754559a..5674d09 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -1,10 +1,11 @@ { "type": "module", "scripts": { - "start": "npm install && node summary.js" + "start": "npm install >/dev/null && node summary.js" }, "dependencies": { "human-readable": "^0.2.1", + "markdown-table": "^3.0.3", "minimist": "^1.2.8", "pretty-bytes": "^6.1.1", "pretty-time": "^1.1.0" diff --git a/scripts/summary.js b/scripts/summary.js index 76518ff..0a57a75 100644 --- a/scripts/summary.js +++ b/scripts/summary.js @@ -1,6 +1,7 @@ -import { readFile } from 'fs/promises'; +import { readFile, writeFile } from 'fs/promises'; import { readdirSync } from 'fs'; import { join } from 'path'; +import { markdownTable } from 'markdown-table'; import formatTime from 'pretty-time'; import formatSize from 'pretty-bytes'; import minimist from 'minimist'; @@ -18,29 +19,31 @@ const results = await Promise.all( }) ); -console.table( - results +await writeFile( + 'summary.md', + ` +${markdownTable([ + ['name', 'command', 'version'], + ...results .slice() .sort((a, b) => a.name.localeCompare(b.name)) - .map(({ name, command, version }) => ({ name, command, version })) -); + .map(({ name, command, version }) => [name, command, version]), +])} -console.table( - results +${markdownTable([ + ['name', 'mean'], + ...results .slice() .sort((a, b) => a.mean - b.mean) - .map(({ name, mean }) => ({ - name, - mean: formatTime(Math.floor(mean * 1_000_000_000), undefined, 5), - })) -); + .map(({ name, mean }) => [name, formatTime(Math.floor(mean * 1_000_000_000), undefined, 5)]), +])} -console.table( - results +${markdownTable([ + ['name', 'max_rss'], + ...results .slice() .sort((a, b) => a.max_rss - b.max_rss) - .map(({ name, max_rss }) => ({ - name, - max_rss: formatSize(max_rss, { minimumFractionDigits: 7 }), - })) + .map(({ name, max_rss }) => [name, formatSize(max_rss, { minimumFractionDigits: 7 })]), +])} +`.trim() );