Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dashboard: Add single PR view #31

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
name: Fetch CI Nightly Data
run-name: Fetch CI Nightly Data
name: Fetch CI Data
run-name: Fetch CI Data
on:
schedule:
- cron: '0 4 * * *'
- cron: '0 */2 * * *'
workflow_dispatch:
push:
branches:
- main
paths:
- 'scripts/fetch-ci-nightly-data.js'
- '.github/workflows/fetch-ci-nightly-data.yaml'

jobs:
fetch-and-commit-data:
Expand All @@ -19,22 +13,25 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Update dashboard data
# Use bash to fail fast:
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell
shell: bash
run: |
Comment on lines -22 to -24
Copy link
Contributor

Choose a reason for hiding this comment

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

We should definitely keep this to prevent false workflow passes

# fetch ci nightly data as temporary file
node scripts/fetch-ci-nightly-data.js | tee tmp-data.json
TOKEN=${{ secrets.GITHUB_TOKEN }} node scripts/fetch-ci-nightly-data.js | tee tmp-data.json
TOKEN=${{ secrets.GITHUB_TOKEN }} node scripts/fetch-ci-pr-data.js | tee tmp-data2.json

# switch to a branch specifically for holding latest data
git config --global user.name "GH Actions Workflow"
git config --global user.email "<gha@runner>"
git fetch --all
git checkout latest-dashboard-data

# back out whatever data was there
git reset HEAD~1

# overwrite the old data
mkdir -p data/
mv tmp-data.json data/job_stats.json
mv tmp-data2.json data/check_stats.json

# commit
git add data
git commit -m '[skip ci] latest ci nightly data'
Expand Down
15 changes: 4 additions & 11 deletions components/weatherTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,33 @@ const icons = [

export const getWeatherIndex = (stat) => {
let fail_rate = 0;
fail_rate = (stat["fails"] + stat["skips"]) / stat["runs"];
fail_rate = (stat["fails"]) / stat["runs"];
// e.g. failing 3/9 runs is .33, or idx=1
var idx = Math.floor((fail_rate * 10) / 2);
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}
// priority
/>
</div>
);
};
};
Loading
Loading