Skip to content

Commit 819b72c

Browse files
author
Erik Soehnel
committed
static viewer app build and deploy
Results and the popularity json file stay at their current place. So if someone wanted to gather all the historical benchmark data, one wont have to deal with too many files moving around.
1 parent 82fd926 commit 819b72c

File tree

7 files changed

+74
-13
lines changed

7 files changed

+74
-13
lines changed

.github/workflows/pages.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ jobs:
2424
deploy:
2525
runs-on: ubuntu-latest
2626

27+
defaults:
28+
run:
29+
working-directory: "./docs"
30+
2731
steps:
2832
- name: Checkout
2933
uses: actions/checkout@v4
@@ -35,15 +39,15 @@ jobs:
3539
run: npm ci
3640

3741
- name: Build docs
38-
run: npm run docs:build
42+
run: npm run build
3943

4044
- name: Setup Pages
4145
uses: actions/configure-pages@v5
4246

4347
- name: Upload artifact
4448
uses: actions/upload-pages-artifact@v3
4549
with:
46-
path: 'docs'
50+
path: "docs/dist"
4751

4852
- name: Deploy to GitHub Pages
4953
id: deployment

.gitignore

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,6 @@ out
9999
.nuxt
100100
dist
101101

102-
# react / gatsby
103-
public/
104-
105102
# Gatsby files
106103
.cache/
107104
# Comment in the public line in if your project uses Gatsby and not Next.js
@@ -150,9 +147,6 @@ public/
150147

151148
# End of https://www.toptal.com/developers/gitignore/api/node
152149

153-
# docs build artifacts
154-
docs/dist
155-
156150
# spectype build artifacts
157151
cases/spectypes/build
158152

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,14 @@ It is deployed via github pages whenever something has been pushed to the main b
132132
```sh
133133
cd docs
134134

135-
npm run dev # develop
135+
npm run dev # develop / view results
136136
npm run build # build
137137
npm run preview # preview the build
138138
```
139139

140+
When viewing results locally, you need to restart the app whenever the results
141+
are updated.
142+
140143
#### Linting
141144

142145
* `npm run lint` - lint all files

docs/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# build artifacts
2+
dist
3+
4+
# copy of results accessible to the viewer app
5+
public/results
6+
public/packagesPopularity.json

docs/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"version": "0.0.0",
55
"type": "module",
66
"scripts": {
7-
"dev": "vite",
8-
"build": "tsc -b && vite build",
9-
"lint": "eslint .",
7+
"prepare-results": "node prepareResults.mjs",
8+
"dev": "npm run prepare-results && vite",
9+
"build": "npm run prepare-results && tsc -b && vite build",
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {

docs/prepareResults.mjs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Script to make the benchmark result files accessible to the benchmark viewer app
2+
//
3+
// - keeps them at their current place for easier access tp benchmark
4+
// history data in the future
5+
// - maybe preprocess and combine them into 1 single file?
6+
import * as fs from 'fs';
7+
import * as path from 'path';
8+
9+
function copyFileSync(src, dest) {
10+
console.log('copying', src, 'to', dest);
11+
fs.copyFileSync(src, dest);
12+
}
13+
14+
/* benchmark results */
15+
16+
// older benchmark app builds where based on publishing the whole
17+
// docs folder with github pages
18+
const sourceDir = 'results';
19+
20+
// everything in public can be fetched from the app
21+
const destDir = 'public/results';
22+
23+
if (!fs.existsSync(sourceDir)) {
24+
console.error('does not exist:', sourceDir);
25+
process.exit(1);
26+
}
27+
28+
if (!fs.existsSync(destDir)) {
29+
fs.mkdirSync(destDir, { recursive: true });
30+
}
31+
32+
const files = fs.readdirSync(sourceDir);
33+
34+
files.forEach(file => {
35+
const sourcePath = path.join(sourceDir, file);
36+
const destPath = path.join(destDir, file);
37+
const stats = fs.statSync(sourcePath);
38+
39+
if (stats.isDirectory()) {
40+
console.error('did not expect a directory here:', destPath);
41+
process.exit(1);
42+
}
43+
44+
copyFileSync(sourcePath, destPath);
45+
});
46+
47+
/* package popularity file */
48+
49+
copyFileSync('packagesPopularity.json', 'public/packagesPopularity.json');
50+
51+
console.log('done');
52+
process.exit(0);

docs/src/App.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,9 @@ export class App extends Component<
582582
}
583583

584584
async componentDidMount() {
585-
await loadPackagesPopularity();
585+
loadPackagesPopularity().catch(err => {
586+
console.error(`error while loading package popularity`, err);
587+
});
586588

587589
NODE_VERSIONS.forEach((v, i) => {
588590
fetch(`results/node-${v}.json`)

0 commit comments

Comments
 (0)