summaryrefslogtreecommitdiff
path: root/tools/upload_wptfyi.js
diff options
context:
space:
mode:
authorLuca Casonato <lucacasonato@yahoo.com>2021-06-07 17:41:33 +0200
committerGitHub <noreply@github.com>2021-06-07 17:41:33 +0200
commit7b9c59fd71f8aae60d7833a176f0566e1a8cfe4f (patch)
tree7305009c4cb31b59f38e2dca6a16df8f189f6dee /tools/upload_wptfyi.js
parentb6400a25a0ee60467a0287d725e61c876677e103 (diff)
tests: upload WPT reports to wpt.fyi (#10883)
Diffstat (limited to 'tools/upload_wptfyi.js')
-rw-r--r--tools/upload_wptfyi.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/tools/upload_wptfyi.js b/tools/upload_wptfyi.js
new file mode 100644
index 000000000..2eb4dcefa
--- /dev/null
+++ b/tools/upload_wptfyi.js
@@ -0,0 +1,60 @@
+// 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.
+
+const user = Deno.env.get("WPT_FYI_STAGING_USER");
+const password = Deno.env.get("WPT_FYI_STAGING_PW");
+
+const commit = Deno.args[0];
+
+const form = new FormData();
+form.set("labels", "experimental");
+form.set("result_url", `https://dl.deno.land/wpt/${commit}-wptreport.json.gz`);
+
+const basicAuthToken = btoa(`${user}:${password}`);
+
+const resp = await fetch("https://staging.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 (Deno.args.includes("--ghstatus")) {
+ const githubToken = Deno.env.get("GITHUB_TOKEN");
+ const taskId = body.split(" ")[1];
+ const url = `https://staging.wpt.fyi/results/?run_id=${taskId}`;
+ 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);
+ }
+}