deno.land / x / deno@v1.28.2 / tools / upload_wptfyi.js

upload_wptfyi.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// This script pushes new WPT results to wpt.fyi. When the `--ghstatus` flag is// passed, will automatically add a status check to the commit with a link to// the wpt.fyi page.
import { gzip } from "https://deno.land/x/compress@v0.4.1/gzip/mod.ts";
const user = Deno.env.get("WPT_FYI_USER");const password = Deno.env.get("WPT_FYI_PW");
const fromRawFile = Deno.args.includes("--from-raw-file");
const form = new FormData();form.set("labels", "master,actions");
if (fromRawFile) { const file = Deno.args[0]; const raw = Deno.readFileSync(file); const gzipped = gzip(raw); form.set("result_file", new Blob([gzipped]));} else { const commit = Deno.args[0]; form.set( "result_url", `https://dl.deno.land/wpt/${commit}-wptreport.json.gz`, );}
const basicAuthToken = btoa(`${user}:${password}`);
const resp = await fetch("https://wpt.fyi/api/results/upload", { method: "POST", body: form, headers: { authorization: `Basic ${basicAuthToken}`, },});
console.log(resp.status);console.log(resp.headers);const body = await resp.text();console.log(body);
if (!resp.ok) { Deno.exit(1);}
if (!fromRawFile && Deno.args.includes("--ghstatus")) { const githubToken = Deno.env.get("GITHUB_TOKEN"); const taskId = body.split(" ")[1]; const url = `https://wpt.fyi/results/?run_id=${taskId}`; const commit = Deno.args[0]; const resp = await fetch( `https://api.github.com/repos/denoland/deno/statuses/${commit}`, { method: "POST", body: JSON.stringify({ state: "success", target_url: url, context: "wpt.fyi", description: "View WPT results on wpt.fyi", }), headers: { authorization: `Bearer ${githubToken}`, }, }, ); console.log(resp.status); console.log(resp.headers); const body2 = await resp.text(); console.log(body2);
if (!resp.ok) { Deno.exit(1); }}
deno

Version Info

Tagged at
a year ago