mirror of
https://github.com/denoland/deno.git
synced 2025-01-03 04:48:52 -05:00
tests: upload WPT reports to wpt.fyi (#10883)
This commit is contained in:
parent
b6400a25a0
commit
7b9c59fd71
2 changed files with 76 additions and 1 deletions
17
.github/workflows/ci.yml
vendored
17
.github/workflows/ci.yml
vendored
|
@ -308,6 +308,7 @@ jobs:
|
|||
run: |
|
||||
deno run --unstable --allow-write --allow-read --allow-net --allow-env --allow-run ./tools/wpt.ts setup
|
||||
deno run --unstable --allow-write --allow-read --allow-net --allow-env --allow-run ./tools/wpt.ts run --quiet --release --json=wpt.json --wptreport=wptreport.json
|
||||
gzip ./wptreport.json
|
||||
|
||||
- name: Upload wpt results to dl.deno.land
|
||||
if: |
|
||||
|
@ -318,10 +319,24 @@ jobs:
|
|||
github.ref == 'refs/heads/main'
|
||||
run: |
|
||||
gsutil cp ./wpt.json gs://dl.deno.land/wpt/$(git rev-parse HEAD).json
|
||||
gsutil cp ./wptreport.json gs://dl.deno.land/wpt/$(git rev-parse HEAD)-wptreport.json
|
||||
gsutil cp ./wptreport.json.gz gs://dl.deno.land/wpt/$(git rev-parse HEAD)-wptreport.json.gz
|
||||
echo $(git rev-parse HEAD) > wpt-latest.txt
|
||||
gsutil cp wpt-latest.txt gs://dl.deno.land/wpt-latest.txt
|
||||
|
||||
- name: Upload wpt results to wpt.fyi
|
||||
if: |
|
||||
runner.os == 'Linux' &&
|
||||
matrix.kind == 'test' &&
|
||||
matrix.profile == 'release' &&
|
||||
github.repository == 'denoland/deno' &&
|
||||
github.ref == 'refs/heads/main'
|
||||
env:
|
||||
WPT_FYI_STAGING_USER: ${{ secrets.WPT_FYI_STAGING_USER }}
|
||||
WPT_FYI_STAGING_PW: ${{ secrets.WPT_FYI_STAGING_PW }}
|
||||
GITHUB_TOKEN: ${{ secrets.DENOBOT_PAT }}
|
||||
run: |
|
||||
deno run -A ./tools/upload_wptfyi.js $(git rev-parse HEAD) --ghstatus
|
||||
|
||||
- name: Run web platform tests (debug)
|
||||
if: startsWith(matrix.os, 'ubuntu') && matrix.kind == 'test' && matrix.profile == 'debug'
|
||||
run: |
|
||||
|
|
60
tools/upload_wptfyi.js
Normal file
60
tools/upload_wptfyi.js
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue