Auto merge of #29669 - sagudev:WPTagregated, r=mrobinson

Fixes for running WPT tests in GitHub Actions

- [report aggregated WPT results based on layout](5ad1f241e2)
- [Run wpt only on try-wpt,try-wpt-2020 branches](0b30baf9a4) fixes a bug introduced in #29662
This commit is contained in:
bors-servo 2023-04-27 09:49:59 +02:00 committed by GitHub
commit ce35d3e8fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 14 deletions

View file

@ -102,7 +102,7 @@ jobs:
path: target.tar.gz path: target.tar.gz
linux-wpt: linux-wpt:
if: ${{ contains(github.ref_name, 'wpt') || inputs.wpt }} if: ${{ github.ref_name == 'try-wpt' || github.ref_name == 'try-wpt-2020' || inputs.wpt }}
name: Linux WPT Tests name: Linux WPT Tests
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
needs: ["build-linux"] needs: ["build-linux"]
@ -183,7 +183,7 @@ jobs:
report-test-results: report-test-results:
name: Reporting test results name: Reporting test results
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ always() && !cancelled() && success('build-linux') && (contains(github.ref_name, 'wpt') || inputs.wpt == 'test') }} if: ${{ always() && !cancelled() && success('build-linux') && (github.ref_name == 'try-wpt' || github.ref_name == 'try-wpt-2020' || inputs.wpt == 'test') }}
needs: needs:
- "linux-wpt" - "linux-wpt"
steps: steps:
@ -203,7 +203,7 @@ jobs:
path: | path: |
unexpected-test-wpt.log unexpected-test-wpt.log
- name: Comment on PR with results - name: Comment on PR with results
run: etc/ci/report_aggregated_expected_results.py wpt-filtered-results-linux/*.json run: etc/ci/report_aggregated_expected_results.py --tag="linux-wpt-${{ env.LAYOUT }}" wpt-filtered-results-linux/*.json
env: env:
GITHUB_CONTEXT: ${{ toJson(github) }} GITHUB_CONTEXT: ${{ toJson(github) }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -17,7 +17,7 @@ import json
import os import os
import re import re
import subprocess import subprocess
import sys import argparse
import textwrap import textwrap
import xml.etree.ElementTree as ElementTree import xml.etree.ElementTree as ElementTree
@ -99,9 +99,9 @@ class Item:
return result return result
def get_results() -> Optional[Item]: def get_results(filenames: list[str], tag: str = "") -> Optional[Item]:
unexpected = [] unexpected = []
for filename in sys.argv[1:]: for filename in filenames:
with open(filename, encoding="utf-8") as file: with open(filename, encoding="utf-8") as file:
unexpected += json.load(file) unexpected += json.load(file)
unexpected.sort(key=lambda result: result["path"]) unexpected.sort(key=lambda result: result["path"])
@ -129,10 +129,13 @@ def get_results() -> Optional[Item]:
"Stable unexpected results") "Stable unexpected results")
run_url = get_github_run_url() run_url = get_github_run_url()
text = "Test results"
if tag:
text += f" for {tag}"
text += " from try job"
if run_url: if run_url:
text = f"Results from try job ({run_url}):" text += f" ({run_url})"
else: text += ":"
text = "Results from try job:"
return Item(text, "", children) if children else None return Item(text, "", children) if children else None
@ -158,7 +161,7 @@ def get_pr_number() -> Optional[str]:
return match.group(1) if match else None return match.group(1) if match else None
def create_check_run(body: str): def create_check_run(body: str, tag: str):
# https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#create-a-check-runs # https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#create-a-check-runs
conclusion = 'neutral' conclusion = 'neutral'
# get conclusion # get conclusion
@ -178,14 +181,14 @@ def create_check_run(body: str):
return None return None
repo = github_context["repository"] repo = github_context["repository"]
data = { data = {
'name': 'WPT', 'name': tag,
'head_sha': github_context["sha"], 'head_sha': github_context["sha"],
'status': 'completed', 'status': 'completed',
'started_at': datetime.utcnow().replace(microsecond=0).isoformat() + "Z", 'started_at': datetime.utcnow().replace(microsecond=0).isoformat() + "Z",
'conclusion': conclusion, 'conclusion': conclusion,
'completed_at': datetime.utcnow().replace(microsecond=0).isoformat() + "Z", 'completed_at': datetime.utcnow().replace(microsecond=0).isoformat() + "Z",
'output': { 'output': {
'title': 'Aggregated WPT report', 'title': f'Aggregated {tag} report',
'summary': body, 'summary': body,
# 'text': '', # 'text': '',
'images': [{'alt': 'WPT logo', 'image_url': 'https://avatars.githubusercontent.com/u/37226233'}] 'images': [{'alt': 'WPT logo', 'image_url': 'https://avatars.githubusercontent.com/u/37226233'}]
@ -205,7 +208,11 @@ def create_check_run(body: str):
def main(): def main():
results = get_results() parser = argparse.ArgumentParser()
parser.add_argument("--tag", default="wpt", action="store",
help="A string tag used to distinguish the results.")
args, filenames = parser.parse_known_args()
results = get_results(filenames, args.tag)
if not results: if not results:
print("Did not find any unexpected results.") print("Did not find any unexpected results.")
create_check_run("Did not find any unexpected results.") create_check_run("Did not find any unexpected results.")
@ -216,7 +223,7 @@ def main():
pr_number = get_pr_number() pr_number = get_pr_number()
html_string = ElementTree.tostring( html_string = ElementTree.tostring(
results.to_html(), encoding="unicode") results.to_html(), encoding="unicode")
create_check_run(html_string) create_check_run(html_string, args.tag)
if pr_number: if pr_number:
process = subprocess.Popen( process = subprocess.Popen(