Skip to content

Commit

Permalink
dashboard: small enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
afinn12 committed Nov 7, 2024
1 parent 9b993f0 commit f9ad24c
Show file tree
Hide file tree
Showing 9 changed files with 652 additions and 265 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
NEXT_PUBLIC_BASE_PATH: ${{ vars.NEXT_PUBLIC_BASE_PATH }}

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
Expand Down Expand Up @@ -76,9 +79,14 @@ jobs:
- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}

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

- name: Build with Next.js (With base path)
if: ${{ env.NEXT_PUBLIC_BASE_PATH != '' }}
run: NEXT_PUBLIC_BASE_PATH=${{ env.NEXT_PUBLIC_BASE_PATH }} ${{ steps.detect-package-manager.outputs.runner }} next build

- name: Add .nojekyll to out directory
run: touch out/.nojekyll

Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ yarn-error.log*
*.tsbuildinfo
next-env.d.ts

/job_stats.json
# local dev data
/localData/*
!/localData/.gitkeep
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,19 @@ Follow these steps to set up the development environment for the Kata Containers

3. **Run the development server**:
Start the Next.js development server with hot-reloading enabled.

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.

Create the .env file:
```bash
node scripts/fetch-ci-nightly-data.js > job_stats.json
NODE_ENV=development
TOKEN=token <GITHUB_PAT_OR_OTHER_VALID_TOKEN>
```

Then, run:

```bash
node --require dotenv/config .\scripts\fetch-ci-nightly-data.js > localData\job_stats.json
npm run dev
```

Expand All @@ -97,5 +108,7 @@ Follow these steps to set up the development environment for the Kata Containers
- **Fetch CI Nightly Data**:
The `fetch-ci-nightly-data.js` script can be executed manually to pull the latest CI test data from the Kata Containers repository:
```bash
node scripts/fetch-ci-nightly-data.js > job_stats.json
```
node --require dotenv/config .\scripts\fetch-ci-nightly-data.js > localData\job_stats.json
```

The file is stored in the /localData directory, which is used for local development.
11 changes: 2 additions & 9 deletions components/weatherTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,22 @@ export const getWeatherIndex = (stat) => {
if (idx == icons.length) {
// edge case: if 100% failures, then we go past the end of icons[]
// back the idx down by 1
console.assert(fail_rate == 1.0);
idx -= 1;
}

// This error checks if there are zero runs.
// Currently, will display stormy weather.
if (isNaN(idx)) {
if (isNaN(idx) || idx > icons.length) {
idx = 4;
}
return idx;
};

const getWeatherIcon = (stat) => {
const idx = getWeatherIndex(stat);
return icons[idx];
};

export const weatherTemplate = (data) => {
const icon = getWeatherIcon(data);
return (
<div>
<Image
src={`${basePath}/${icon}`}
src={`${basePath}/${icons[getWeatherIndex(data)]}`}
alt="weather"
width={32}
height={32}
Expand Down
4 changes: 2 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
reactStrictMode: true,
output: 'export',
basePath: "",
// output: 'export',
basePath: process.env.NEXT_PUBLIC_BASE_PATH || "",
images: {
unoptimized: true,
},
Expand Down
Loading

0 comments on commit f9ad24c

Please sign in to comment.