Skip to content

Commit

Permalink
Auto merge of #29669 - sagudev:WPTagregated, r=mrobinson
Browse files Browse the repository at this point in the history
Fixes for running WPT tests in GitHub Actions

- [report aggregated WPT results based on layout](5ad1f24)
- [Run wpt only on try-wpt,try-wpt-2020 branches](0b30baf) fixes a bug introduced in #29662
  • Loading branch information
bors-servo committed Apr 27, 2023
2 parents 7eca93b + 219afcc commit ce35d3e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/linux.yml
Expand Up @@ -102,7 +102,7 @@ jobs:
path: target.tar.gz

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
runs-on: ubuntu-20.04
needs: ["build-linux"]
Expand Down Expand Up @@ -183,7 +183,7 @@ jobs:
report-test-results:
name: Reporting test results
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:
- "linux-wpt"
steps:
Expand All @@ -203,7 +203,7 @@ jobs:
path: |
unexpected-test-wpt.log
- 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:
GITHUB_CONTEXT: ${{ toJson(github) }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
29 changes: 18 additions & 11 deletions etc/ci/report_aggregated_expected_results.py
Expand Up @@ -17,7 +17,7 @@
import os
import re
import subprocess
import sys
import argparse
import textwrap
import xml.etree.ElementTree as ElementTree

Expand Down Expand Up @@ -99,9 +99,9 @@ def to_html(self, level: int = 0) -> ElementTree.Element:
return result


def get_results() -> Optional[Item]:
def get_results(filenames: list[str], tag: str = "") -> Optional[Item]:
unexpected = []
for filename in sys.argv[1:]:
for filename in filenames:
with open(filename, encoding="utf-8") as file:
unexpected += json.load(file)
unexpected.sort(key=lambda result: result["path"])
Expand Down Expand Up @@ -129,10 +129,13 @@ def add_children(children, results, filter_func, text):
"Stable unexpected results")

run_url = get_github_run_url()
text = "Test results"
if tag:
text += f" for {tag}"
text += " from try job"
if run_url:
text = f"Results from try job ({run_url}):"
else:
text = "Results from try job:"
text += f" ({run_url})"
text += ":"
return Item(text, "", children) if children else None


Expand All @@ -158,7 +161,7 @@ def get_pr_number() -> Optional[str]:
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
conclusion = 'neutral'
# get conclusion
Expand All @@ -178,14 +181,14 @@ def create_check_run(body: str):
return None
repo = github_context["repository"]
data = {
'name': 'WPT',
'name': tag,
'head_sha': github_context["sha"],
'status': 'completed',
'started_at': datetime.utcnow().replace(microsecond=0).isoformat() + "Z",
'conclusion': conclusion,
'completed_at': datetime.utcnow().replace(microsecond=0).isoformat() + "Z",
'output': {
'title': 'Aggregated WPT report',
'title': f'Aggregated {tag} report',
'summary': body,
# 'text': '',
'images': [{'alt': 'WPT logo', 'image_url': 'https://avatars.githubusercontent.com/u/37226233'}]
Expand All @@ -205,7 +208,11 @@ def create_check_run(body: str):


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:
print("Did not find any unexpected results.")
create_check_run("Did not find any unexpected results.")
Expand All @@ -216,7 +223,7 @@ def main():
pr_number = get_pr_number()
html_string = ElementTree.tostring(
results.to_html(), encoding="unicode")
create_check_run(html_string)
create_check_run(html_string, args.tag)

if pr_number:
process = subprocess.Popen(
Expand Down

0 comments on commit ce35d3e

Please sign in to comment.