Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions infra/test-all.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
import os
import subprocess
import sys
import uuid

EXTRA_FLAGS = {
"ios": ["--config=ios"],
"swift": ["--config=clang"],
}

# Must match --bes_results_url for --config=opal_bes in .bazelrc.
BES_RESULTS_URL = "https://opal.cluster.engflow.com/invocations/example-oss/"


def report_error(msg):
print(msg, file=sys.stderr)
Expand Down Expand Up @@ -69,13 +73,37 @@ def run_tests(package):
print(f"---------------\nTesting {package}...")
sys.stdout.flush()

invocation_id = str(uuid.uuid4())
flags.append(f"--invocation_id={invocation_id}")

args = ["bazel", "test"] + flags + ["--"] + targets
result = subprocess.run(args, check=False)
sys.stdout.flush()
sys.stderr.flush()
report_invocation(package, BES_RESULTS_URL + invocation_id, result.returncode)
return result.returncode


def report_invocation(package, url, returncode):
"""Surfaces the BES invocation link in the GitHub Actions UI."""
if not os.getenv("GITHUB_ACTIONS"):
return

execution_type = os.getenv("EXECUTION_TYPE")
status = "passed" if returncode == 0 else "failed"
level = "notice" if returncode == 0 else "error"
title = f"{package} ({execution_type}) {status}"

# Annotation: shown on the run summary page and in the Checks tab.
print(f"::{level} title={title}::Invocation results: {url}")

# Job summary: rendered as Markdown on the run summary page.
summary_file = os.getenv("GITHUB_STEP_SUMMARY")
if summary_file:
with open(summary_file, "a") as f:
f.write(f"### {title}\n\n[View invocation results]({url})\n")


def main():
parser = argparse.ArgumentParser(
description="Runs example test suites", fromfile_prefix_chars="@"
Expand Down
Loading