Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Add tool to fetch aligned SHAs #13

Merged
merged 2 commits into from
Nov 27, 2019
Merged
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
261 changes: 261 additions & 0 deletions experimental-shas.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
2019-01-29T00:00:00Z,9c5701192b
2019-01-30T00:00:00Z,4139dfe3c5
2019-01-31T00:00:00Z,ac12b3e948
2019-02-01T00:00:00Z,b0020d5df1
2019-02-02T00:00:00Z,78c1544715
2019-02-03T00:00:00Z,18c828feb8
2019-02-04T00:00:00Z,7e48cd0990
2019-02-05T00:00:00Z,8f48bdf110
2019-02-06T00:00:00Z,de6f8fcf9b
2019-02-07T00:00:00Z,156d195398
2019-02-08T00:00:00Z,be8418c77f
2019-02-09T00:00:00Z,345300fad3
2019-02-10T00:00:00Z,01e5f08719
2019-02-11T00:00:00Z,48b9be82df
2019-02-12T00:00:00Z,265330b7d2
2019-02-13T00:00:00Z,2647e1e8f6
2019-02-14T00:00:00Z,8f7ccae78b
2019-02-15T00:00:00Z,2801597ed2
2019-02-16T00:00:00Z,2bed10ac31
2019-02-18T00:00:00Z,3a43f99a56
2019-02-19T00:00:00Z,34e6ee21a6
2019-02-20T00:00:00Z,7266a4200f
2019-02-21T00:00:00Z,91b1effe84
2019-02-22T00:00:00Z,8d7111a760
2019-02-23T00:00:00Z,70df598b89
2019-02-24T00:00:00Z,8805f23ef6
2019-02-25T00:00:00Z,1018695710
2019-02-26T00:00:00Z,1aa5413b0c
2019-02-27T00:00:00Z,de20bc32bb
2019-02-28T00:00:00Z,d3db00fbae
2019-03-01T00:00:00Z,04ad8dd6a1
2019-03-02T00:00:00Z,20715b3f6a
2019-03-03T00:00:00Z,20715b3f6a
2019-03-04T00:00:00Z,4dbc98b658
2019-03-05T00:00:00Z,b3ebabb771
2019-03-06T00:00:00Z,a69554e3d5
2019-03-07T00:00:00Z,405751fab6
2019-03-08T00:00:00Z,6693cdfab4
2019-03-11T00:00:00Z,e1f4b21055
2019-03-12T00:00:00Z,2c929b12d8
2019-03-13T00:00:00Z,5df243654f
2019-03-14T00:00:00Z,1b8bf0be8d
2019-03-15T00:00:00Z,96dd05afd4
2019-03-16T00:00:00Z,c9829b514d
2019-03-18T00:00:00Z,c7ec350b75
2019-03-19T00:00:00Z,e45bda7edd
2019-03-20T00:00:00Z,01e30febfa
2019-03-23T00:00:00Z,4cc42c364b
2019-03-24T00:00:00Z,3b0abc897b
2019-03-25T00:00:00Z,69e5802277
2019-03-26T00:00:00Z,a960bbaf56
2019-03-27T00:00:00Z,cffb370530
2019-03-28T00:00:00Z,7d7b6f3c50
2019-03-29T00:00:00Z,11d0520935
2019-03-30T00:00:00Z,ecb5ceb84a
2019-03-31T00:00:00Z,d4f8820261
2019-04-01T00:00:00Z,a8e6f75e3f
2019-04-02T00:00:00Z,e7befa33a9
2019-04-03T00:00:00Z,56a8b65c49
2019-04-04T00:00:00Z,3b92b9b595
2019-04-05T00:00:00Z,c3c423be44
2019-04-06T00:00:00Z,923923a01f
2019-04-07T00:00:00Z,b624370228
2019-04-08T00:00:00Z,81ae7085cc
2019-04-09T00:00:00Z,687b6cba33
2019-04-10T00:00:00Z,54e83cba22
2019-04-11T00:00:00Z,0fbaeb4dbb
2019-04-12T00:00:00Z,ced5ebaab3
2019-04-13T00:00:00Z,3efff9b2d6
2019-04-15T00:00:00Z,d4e101b70e
2019-04-16T00:00:00Z,0d32c192cb
2019-04-17T00:00:00Z,0b9bdba212
2019-04-18T00:00:00Z,09f6a85b2a
2019-04-19T00:00:00Z,4657e10253
2019-04-23T00:00:00Z,c874e70e5a
2019-04-24T00:00:00Z,54086c0655
2019-04-25T00:00:00Z,a7ca70d95f
2019-04-27T00:00:00Z,301ce26e6c
2019-04-29T00:00:00Z,e71f917165
2019-04-30T00:00:00Z,301babcfa7
2019-05-01T00:00:00Z,8da1cdcae2
2019-05-02T00:00:00Z,a327f9285b
2019-05-03T00:00:00Z,1466fae2a6
2019-05-06T00:00:00Z,06e1dfffbc
2019-05-07T00:00:00Z,921a5dad0d
2019-05-08T00:00:00Z,aa929d12a0
2019-05-09T00:00:00Z,1dc0f0ac3a
2019-05-10T00:00:00Z,143172719a
2019-05-11T00:00:00Z,0c79d0d99c
2019-05-12T00:00:00Z,127f2d619d
2019-05-13T00:00:00Z,dbbcf11534
2019-05-14T00:00:00Z,c73e256ab0
2019-05-15T00:00:00Z,35f192b9ed
2019-05-16T00:00:00Z,a44abc74a6
2019-05-17T00:00:00Z,52cf6b3cff
2019-05-18T00:00:00Z,163424c5e7
2019-05-19T00:00:00Z,6777c592f4
2019-05-20T00:00:00Z,9ddcc7352b
2019-05-21T00:00:00Z,e8a896ba53
2019-05-22T00:00:00Z,e426a6933a
2019-05-23T00:00:00Z,137ac6db98
2019-05-24T00:00:00Z,098e651c57
2019-05-25T00:00:00Z,ac3d096a59
2019-05-26T00:00:00Z,a4df0fa7be
2019-05-27T00:00:00Z,ecf36e0069
2019-05-28T00:00:00Z,a6a3a634c4
2019-05-29T00:00:00Z,eeb34a17fa
2019-05-30T00:00:00Z,f1782b2b45
2019-06-03T00:00:00Z,33dcb4b31a
2019-06-04T00:00:00Z,3e07a6ab68
2019-06-05T00:00:00Z,78171013d9
2019-06-06T00:00:00Z,3840f46213
2019-06-07T00:00:00Z,6e850694b1
2019-06-08T00:00:00Z,a2ed321bcc
2019-06-10T00:00:00Z,6ba1179816
2019-06-11T00:00:00Z,1bdd1b1901
2019-06-12T00:00:00Z,293630965d
2019-06-13T00:00:00Z,b06ef73185
2019-06-14T00:00:00Z,e698502a7d
2019-06-15T00:00:00Z,4100d1d51b
2019-06-16T00:00:00Z,fc5cf5b4f4
2019-06-17T00:00:00Z,dbaf4c77b6
2019-06-18T00:00:00Z,2b29767a9f
2019-06-19T00:00:00Z,17de974a80
2019-06-20T00:00:00Z,5303a4e841
2019-06-22T00:00:00Z,693543f729
2019-06-24T00:00:00Z,ec977dea05
2019-06-25T00:00:00Z,ecc43f56d1
2019-06-26T00:00:00Z,88bac6b712
2019-06-27T00:00:00Z,8bdb4e17cd
2019-06-28T00:00:00Z,f0ed587427
2019-06-29T00:00:00Z,c0a3e93389
2019-07-02T00:00:00Z,ec636b58e8
2019-07-03T00:00:00Z,27bc3bada8
2019-07-04T00:00:00Z,7de7666607
2019-07-05T00:00:00Z,a0747c8d65
2019-07-08T00:00:00Z,a8d8e612cc
2019-07-09T00:00:00Z,9d23e22e54
2019-07-10T00:00:00Z,e4b8a06127
2019-07-11T00:00:00Z,ee75c68c4e
2019-07-12T00:00:00Z,9919d0f042
2019-07-13T00:00:00Z,79688a36f8
2019-07-14T00:00:00Z,719721f655
2019-07-15T00:00:00Z,ab9626fa6b
2019-07-16T00:00:00Z,63459a30a6
2019-07-17T00:00:00Z,9a4d479ed1
2019-07-18T00:00:00Z,b4b36aef39
2019-07-19T00:00:00Z,def6e8698c
2019-07-20T00:00:00Z,f4903ae6f4
2019-07-22T00:00:00Z,dfac707fc3
2019-07-23T00:00:00Z,d906dcacdf
2019-07-24T00:00:00Z,44f332d449
2019-07-25T00:00:00Z,eb705a2c13
2019-07-26T00:00:00Z,10f3317909
2019-07-27T00:00:00Z,e079873c1f
2019-07-28T00:00:00Z,690df50e04
2019-07-29T00:00:00Z,9bca3a3de1
2019-07-30T00:00:00Z,28d7981ed8
2019-07-31T00:00:00Z,fa29865c65
2019-08-01T00:00:00Z,1cb5f2830a
2019-08-02T00:00:00Z,684b142728
2019-08-03T00:00:00Z,097043b336
2019-08-04T00:00:00Z,32fc57874b
2019-08-05T00:00:00Z,dcdebb1b8e
2019-08-06T00:00:00Z,a140f239fa
2019-08-07T00:00:00Z,66b4fab488
2019-08-08T00:00:00Z,5c61f2493f
2019-08-15T00:00:00Z,004dc3d548
2019-08-16T00:00:00Z,936827a652
2019-08-17T00:00:00Z,cf56c201d4
2019-08-19T00:00:00Z,5fc1b5c33a
2019-08-20T00:00:00Z,d8c23c9a0c
2019-08-21T00:00:00Z,92f88af298
2019-08-22T00:00:00Z,d1d8d8b4fa
2019-08-23T00:00:00Z,ef77ba9ca4
2019-08-24T00:00:00Z,3bac98b37f
2019-08-25T00:00:00Z,6933aa6626
2019-08-26T00:00:00Z,23f463a0cc
2019-08-27T00:00:00Z,49b0aca116
2019-08-28T00:00:00Z,7cbcb4b083
2019-08-29T00:00:00Z,274abf218e
2019-08-30T00:00:00Z,9e6ba13980
2019-08-31T00:00:00Z,8509904597
2019-09-01T00:00:00Z,629e3ba6a9
2019-09-02T00:00:00Z,c05529a9df
2019-09-03T00:00:00Z,f4dd549238
2019-09-04T00:00:00Z,4490750ec4
2019-09-05T00:00:00Z,d86745dade
2019-09-06T00:00:00Z,ff403bcc13
2019-09-07T00:00:00Z,756a676d64
2019-09-09T00:00:00Z,5ac316ef83
2019-09-10T00:00:00Z,73837c92a6
2019-09-11T00:00:00Z,e2498db8b0
2019-09-12T00:00:00Z,7b5f9a2795
2019-09-13T00:00:00Z,46ebc162a2
2019-09-14T00:00:00Z,8df929fdf1
2019-09-15T00:00:00Z,c850921dd5
2019-09-16T00:00:00Z,91985c1463
2019-09-17T00:00:00Z,8b04cca826
2019-09-18T00:00:00Z,e076f285b8
2019-09-19T00:00:00Z,59d5350b14
2019-09-20T00:00:00Z,6d3088b17a
2019-09-21T00:00:00Z,42b4a3fa60
2019-09-22T00:00:00Z,e2f106dd72
2019-09-23T00:00:00Z,42b82765b8
2019-09-24T00:00:00Z,2478ed1b80
2019-09-27T00:00:00Z,c3c56f5ba3
2019-09-29T00:00:00Z,0106544dac
2019-09-30T00:00:00Z,563a1ecea1
2019-10-01T00:00:00Z,1eb937d840
2019-10-02T00:00:00Z,e9ba032171
2019-10-03T00:00:00Z,3564c21f26
2019-10-04T00:00:00Z,f4483de684
2019-10-05T00:00:00Z,6c1b9ea175
2019-10-07T00:00:00Z,819a234d3d
2019-10-08T00:00:00Z,62ee04cd0e
2019-10-09T00:00:00Z,4c1bbd4b27
2019-10-10T00:00:00Z,a879756282
2019-10-11T00:00:00Z,33fa44546c
2019-10-12T00:00:00Z,52024c8e73
2019-10-13T00:00:00Z,79c38259f4
2019-10-14T00:00:00Z,c7abd94317
2019-10-15T00:00:00Z,47f50fdf18
2019-10-16T00:00:00Z,5afa7f6c33
2019-10-17T00:00:00Z,65e501af61
2019-10-18T00:00:00Z,378b84eb6e
2019-10-19T00:00:00Z,fbc0925b2a
2019-10-20T00:00:00Z,43aa377085
2019-10-21T00:00:00Z,670f3ef16f
2019-10-22T00:00:00Z,237825fc22
2019-10-23T00:00:00Z,f87822f99f
2019-10-24T00:00:00Z,b529e77cc4
2019-10-25T00:00:00Z,9ceef5af8b
2019-10-26T00:00:00Z,5eebc927c5
2019-10-27T00:00:00Z,1092d667b0
2019-10-28T00:00:00Z,436bf31561
2019-10-29T00:00:00Z,5ec0a20616
2019-10-30T00:00:00Z,ae12c77713
2019-10-31T00:00:00Z,71aff5b243
2019-11-01T00:00:00Z,e86dd95bfe
2019-11-02T00:00:00Z,d4a7c5c8ff
2019-11-03T00:00:00Z,b3a2d4f7f5
2019-11-04T00:00:00Z,5450f27792
2019-11-05T00:00:00Z,62f2717d21
2019-11-06T00:00:00Z,2d18475e25
2019-11-07T00:00:00Z,dc15bcc862
2019-11-08T00:00:00Z,186457c2f6
2019-11-09T00:00:00Z,ff6c692c5a
2019-11-11T00:00:00Z,bce5534f6a
2019-11-12T00:00:00Z,87f0b74825
2019-11-13T00:00:00Z,52f470f583
2019-11-14T00:00:00Z,945cb42ce6
2019-11-15T00:00:00Z,7f931f0a01
2019-11-16T00:00:00Z,89aa3f4213
2019-11-17T00:00:00Z,fb96a45f85
2019-11-18T00:00:00Z,b624f9b794
2019-11-19T00:00:00Z,dc9e34aed7
2019-11-20T00:00:00Z,5d71a0085e
2019-11-21T00:00:00Z,8e98be7324
2019-11-22T00:00:00Z,09869954bf
2019-11-23T00:00:00Z,0c3a6b1df6
124 changes: 124 additions & 0 deletions generate-aligned-shas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
'use strict';

/**
* A helper script to generate a set of SHAs for aligned runs over time.
*
* The goal is to generate a comparable, representative set of SHAs that can be
* used to compare results from browsers over time.
*/

const fetch = require('node-fetch');
const flags = require('flags');
const fs = require('fs');
const moment = require('moment');

flags.defineString('from', '2017-08-19', 'Starting date for SHAs');
flags.defineString('to', moment().format('YYYY-MM-DD'), 'Ending date for SHAs');
flags.defineString('output', null, 'Output file to write SHAs to. Defaults to {stable, experimental}-shas.txt');
flags.defineStringList('products', ['chrome', 'safari', 'firefox'], 'Products that must align in the returned SHAs');
flags.defineBoolean('experimental', false, 'Fetch SHAs for experimental runs rather than stable');
flags.parse();

const SHAS_API = 'https://wpt.fyi/api/shas?aligned=true';

async function readShasFromFile(output) {
let shas = new Map();

// Check whether the file exists; on failure just return the empty map.
try {
await fs.promises.access(output);
} catch (error) {
return shas;
}

// Otherwise, read the file and then attempt to parse it as a list of
// [date,sha] pairs, newline separated.
let data = await fs.promises.readFile(output, 'utf-8');
let lines = data.split('\n');
for (const line of lines) {
if (!line)
continue;
const parts = line.split(',');
shas.set(parts[0], parts[1]);
}

console.log(`Reusing ${shas.size} SHAs from ${output}`);
return shas;
}

async function main() {
const experimental = flags.get('experimental');

let output = flags.get('output');
if (!output)
output = experimental ? 'experimental-shas.txt' : 'stable-shas.txt';

let shas = await readShasFromFile(output);

let labels = '&labels=master,';
labels += experimental ? 'experimental' : 'stable';

let products = '';
for (const product of flags.get('products')) {
products += `&product=${product}`;
}
const shasUrl = `${SHAS_API}${labels}${products}`;
console.log(`Base URL: ${shasUrl}`);

let from = moment(flags.get('from'));
let to = moment(flags.get('to'));
console.log(`Fetching SHAs from ${from.format('YYYY-MM-DD')} to ${to.format('YYYY-MM-DD')}`);

// TODO(smcgruer): This loop is surprisingly slow even when all the SHAs are
// cached. I suspect both formatting and incrementing dates may be quite slow.
let cachedCount = 0;
let before = moment();
while (from < to) {
const formatted_from = from.format('YYYY-MM-DDT[00:00:00Z]');
const formatted_to = from.format('YYYY-MM-DDT[23:59:59Z]');
stephenmcgruer marked this conversation as resolved.
Show resolved Hide resolved

// Walk the date forward here so later code can bail without having to check
// whether they have updated it.
from.add(1, 'days');

// Check whether our cache already has this date.
if (shas.has(formatted_from)) {
cachedCount++;
continue;
}

// Fetch the list of SHAs from the server.
const url = `${shasUrl}&from=${formatted_from}&to=${formatted_to}`;
let response = await fetch(url);
let json = await response.json();

// Many days do not have an aligned run.
if (json.length == 0) {
continue;
}

// Otherwise, pick a random SHA for the day.
shas.set(formatted_from, json[Math.floor(Math.random() * json.length)]);
}
let after = moment();
console.log(`Fetched ${shas.size} SHAs in ${after - before} ms (${cachedCount} cached)`);

// Sort the SHAs for writing to the file, otherwise the cached entries will be
// before earlier (in date) entries.
shas = new Map([...shas].sort((a, b) => {
// Keys should never be equal.
return a[0] < b[0] ? '-1' : '1';
}));

console.log(`Writing SHAs to ${output}`);
let data = '';
shas.forEach((value, key) => {
data += key + ',' + value + '\n';
});
await fs.promises.writeFile(output, data, 'utf-8');
}

main().catch(reason => {
console.error(reason);
process.exit(1);
});
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading