Skip to content

Commit cea1d44

Browse files
committed
dashboard: small enhancements
Updated fetch script to require access token, simplified/removed extra PR code, and added error message. Modified basePath, styling change to weatherTemplate/table, added default sort by most Fails. Added win-dev/localData, updated README/.gitignore. Fixes: #25 Signed-off-by: Anna Finn <[email protected]>
1 parent 054713a commit cea1d44

File tree

10 files changed

+667
-289
lines changed

10 files changed

+667
-289
lines changed

.github/workflows/deploy.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ on:
1515
# Allows you to run this workflow manually from the Actions tab
1616
workflow_dispatch:
1717

18+
env:
19+
NEXT_PUBLIC_BASE_PATH: ${{ vars.NEXT_PUBLIC_BASE_PATH }}
20+
1821
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1922
permissions:
2023
contents: read
@@ -76,9 +79,14 @@ jobs:
7679
- name: Install dependencies
7780
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
7881

79-
- name: Build with Next.js
82+
- name: Build with Next.js (No base path)
83+
if: ${{ env.NEXT_PUBLIC_BASE_PATH == '' }}
8084
run: ${{ steps.detect-package-manager.outputs.runner }} next build
8185

86+
- name: Build with Next.js (With base path)
87+
if: ${{ env.NEXT_PUBLIC_BASE_PATH != '' }}
88+
run: NEXT_PUBLIC_BASE_PATH=${{ env.NEXT_PUBLIC_BASE_PATH }} ${{ steps.detect-package-manager.outputs.runner }} next build
89+
8290
- name: Add .nojekyll to out directory
8391
run: touch out/.nojekyll
8492

.github/workflows/fetch-ci-nightly-data.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
- name: Checkout
2020
uses: actions/checkout@v4
2121
- name: Update dashboard data
22+
env:
23+
TOKEN: ${{ secrets.GITHUB_TOKEN }}
2224
# Use bash to fail fast:
2325
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell
2426
shell: bash

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ npm-debug.log*
2626
yarn-debug.log*
2727
yarn-error.log*
2828

29-
# local env files
30-
.env*.local
29+
# env files
30+
.env*
3131

3232
# vercel
3333
.vercel
@@ -36,4 +36,5 @@ yarn-error.log*
3636
*.tsbuildinfo
3737
next-env.d.ts
3838

39-
/job_stats.json
39+
# local dev data
40+
/localData/

README.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,21 @@ Follow these steps to set up the development environment for the Kata Containers
7171

7272
3. **Run the development server**:
7373
Start the Next.js development server with hot-reloading enabled.
74+
75+
To run the script to fetch the data, a .env file must be created with an access token. This is required to authenticate our calls and increase the rate limit. To get the token, click [here](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)
76+
77+
Create the .env file:
7478
```bash
75-
node scripts/fetch-ci-nightly-data.js > job_stats.json
76-
npm run dev
79+
NODE_ENV=development
80+
TOKEN=<GITHUB_PAT_OR_OTHER_VALID_TOKEN>
7781
```
7882

83+
Create the folder /localData. Then, run:
84+
85+
```bash
86+
node scripts/fetch-ci-nightly-data.js > localData/job_stats.json
87+
npm run dev # On Windows, run `npm run win-dev` instead.
88+
```
7989
The app will be available at [http://localhost:3000](http://localhost:3000).
8090

8191
### Production
@@ -92,10 +102,11 @@ Follow these steps to set up the development environment for the Kata Containers
92102
npm start
93103
```
94104

95-
### Scripts
96-
97-
- **Fetch CI Nightly Data**:
98-
The `fetch-ci-nightly-data.js` script can be executed manually to pull the latest CI test data from the Kata Containers repository:
99-
```bash
100-
node scripts/fetch-ci-nightly-data.js > job_stats.json
101-
```
105+
### Notes
106+
In deploy.yml:
107+
```bash
108+
env:
109+
NEXT_PUBLIC_BASE_PATH: ${{ vars.NEXT_PUBLIC_BASE_PATH }}
110+
```
111+
If the variable is undefined, it will use "" for the basePath and assume the site is being served at root.
112+
This makes it easier for people to fork the repo and deploy with GitHub pages such that they can have a preview for their PR.

components/weatherTemplate.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,28 @@ const icons = [
1111

1212
export const getWeatherIndex = (stat) => {
1313
let fail_rate = 0;
14-
fail_rate = (stat["fails"] + stat["skips"]) / stat["runs"];
14+
fail_rate = (stat["fails"]) / stat["runs"];
1515
// e.g. failing 3/9 runs is .33, or idx=1
1616
var idx = Math.floor((fail_rate * 10) / 2);
1717
if (idx == icons.length) {
1818
// edge case: if 100% failures, then we go past the end of icons[]
1919
// back the idx down by 1
20-
console.assert(fail_rate == 1.0);
2120
idx -= 1;
2221
}
2322

2423
// This error checks if there are zero runs.
2524
// Currently, will display stormy weather.
26-
if (isNaN(idx)) {
25+
if (isNaN(idx) || idx > icons.length) {
2726
idx = 4;
2827
}
2928
return idx;
3029
};
3130

32-
const getWeatherIcon = (stat) => {
33-
const idx = getWeatherIndex(stat);
34-
return icons[idx];
35-
};
36-
3731
export const weatherTemplate = (data) => {
38-
const icon = getWeatherIcon(data);
3932
return (
4033
<div>
4134
<Image
42-
src={`${basePath}/${icon}`}
35+
src={`${basePath}/${icons[getWeatherIndex(data)]}`}
4336
alt="weather"
4437
width={32}
4538
height={32}

next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
reactStrictMode: true,
33
output: 'export',
4-
basePath: "",
4+
basePath: process.env.NEXT_PUBLIC_BASE_PATH || "",
55
images: {
66
unoptimized: true,
77
},

0 commit comments

Comments
 (0)