From b4c465e6a2d14c57a9214b3d773988cb2ec3894a Mon Sep 17 00:00:00 2001 From: sagudev <16504129+sagudev@users.noreply.github.com> Date: Wed, 26 Apr 2023 09:00:00 +0200 Subject: [PATCH 1/2] Run wpt only on try-wpt,try-wpt-2020 branches --- .github/workflows/linux.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 6a9561d4a36..4f07c080bea 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -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"] @@ -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: From 219afcc9a813022c053ee746e34774c8eb2e6023 Mon Sep 17 00:00:00 2001 From: sagudev <16504129+sagudev@users.noreply.github.com> Date: Thu, 27 Apr 2023 09:05:02 +0200 Subject: [PATCH 2/2] WPT results aggregating based on layout --- .github/workflows/linux.yml | 2 +- etc/ci/report_aggregated_expected_results.py | 29 ++++++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 4f07c080bea..6fd5da175a0 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -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 }} diff --git a/etc/ci/report_aggregated_expected_results.py b/etc/ci/report_aggregated_expected_results.py index e5990f24f2f..9b6f3e1bccd 100755 --- a/etc/ci/report_aggregated_expected_results.py +++ b/etc/ci/report_aggregated_expected_results.py @@ -17,7 +17,7 @@ import json import os import re import subprocess -import sys +import argparse import textwrap import xml.etree.ElementTree as ElementTree @@ -99,9 +99,9 @@ class Item: 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"]) @@ -129,10 +129,13 @@ def get_results() -> Optional[Item]: "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 @@ -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 @@ -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'}] @@ -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.") @@ -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(