Skip to content
Closed
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
76 changes: 76 additions & 0 deletions .github/workflows/hosted-math-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Hosted learning overview

on:
pull_request:
paths:
- '.github/workflows/hosted-math-validation.yml'

permissions:
contents: read

jobs:
capture:
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-24.04
timeout-minutes: 8
env:
SCIENCE_REVISION: f5d48bfa9be85801e2d745b6deefb5c724455e4d
MILESTONES_PAGE: learning/MILESTONES.md
steps:
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: '22'
- name: Prepare Chromium
run: |
npm install --prefix "$RUNNER_TEMP/math-runtime" playwright@1.56.1
node "$RUNNER_TEMP/math-runtime/node_modules/playwright/cli.js" install chromium
- name: Capture the top of the pinned milestone page
shell: bash
run: |
set -euo pipefail
mkdir captures
export NODE_PATH="$RUNNER_TEMP/math-runtime/node_modules"
node <<'JS'
const {chromium}=require('playwright');
const fs=require('node:fs');
(async()=>{
const url='https://github.com/'+process.env.GITHUB_REPOSITORY+'/blob/'+process.env.SCIENCE_REVISION+'/'+process.env.MILESTONES_PAGE;
const browser=await chromium.launch({headless:true});
try {
const observations=[];
for(const width of [760,1440]){
const page=await browser.newPage({viewport:{width,height:1100}});
const navOptions={waitUntil:'domcontentloaded',timeout:45000};
let response=await page.goto(url,navOptions);
if([502,503,504].includes(response.status())) {
await new Promise(resolve=>setTimeout(resolve,3000));
response=await page.goto(url,navOptions);
}
if(response.status()!==200||page.url()!==url) throw Error('Expected exact GitHub page, got '+response.status());
const article=page.locator('article.markdown-body');
await article.getByRole('heading',{name:'Project understanding map'}).waitFor();
await page.evaluate(async()=>{
window.scrollTo({top:0,left:0,behavior:'instant'});
await new Promise(resolve=>requestAnimationFrame(()=>requestAnimationFrame(resolve)));
});
const y=await page.evaluate(()=>window.scrollY);
if(y!==0) throw Error('Expected top viewport');
const overview=article.locator('table').first();
const rows=await overview.locator('tr').count();
const bounds=await overview.boundingBox();
if(rows<4||!bounds||bounds.y<0||bounds.y+bounds.height>1100) throw Error('Overview not fully within viewport');
const screenshot='overview-'+width+'.png';
await page.screenshot({path:'captures/'+screenshot,fullPage:false,animations:'disabled'});
observations.push({width,url,rows,y,screenshot});
await page.close();
}
fs.writeFileSync('captures/observations.json',JSON.stringify(observations,null,2)+'\n');
} finally {await browser.close();}
})().catch(error=>{console.error(error);process.exitCode=1});
JS
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: hosted-learning-overview-${{ env.SCIENCE_REVISION }}
path: captures
if-no-files-found: error
retention-days: 7
Loading
Loading