Skip to content
Closed
Show file tree
Hide file tree
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
56 changes: 56 additions & 0 deletions .github/scripts/summarize-junit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env python3
"""Summarize JUnit XML reports as GitHub-flavored markdown on stdout.

Usage: summarize-junit.py <dir-of-junit-xml>
Exits 0 even when tests failed; this is a reporting tool, not a gate.
"""

import glob
import os
import sys
import xml.etree.ElementTree as ET


def main(xml_dir):
paths = sorted(glob.glob(os.path.join(xml_dir, '*.xml')))
if not paths:
print(f'No JUnit XML found in `{xml_dir}`.')
return 0

tests = failures = skipped = 0
seconds = 0.0
failed_names = []

for path in paths:
root = ET.parse(path).getroot()
tests += int(root.get('tests', 0))
failures += int(root.get('failures', 0)) + int(root.get('errors', 0))
skipped += int(root.get('skipped', 0))
seconds += float(root.get('time', 0))
for case in root.iter('testcase'):
# An <failure> element with text but no children is falsy in
# ElementTree, so compare against None explicitly.
bad = next(case.iter('failure'), None)
if bad is None:
bad = next(case.iter('error'), None)
if bad is not None:
cls = (case.get('classname') or '').split('.')[-1]
failed_names.append(f'{cls}.{case.get("name")}')

print(f'Java: **{tests}** tests, **{failures}** failed, '
f'**{skipped}** skipped, {seconds:.0f}s')
print()

if failed_names:
print('<details><summary>Failed Java tests</summary>')
print()
for name in sorted(failed_names):
print(f'- `{name}`')
print()
print('</details>')

return 0


if __name__ == '__main__':
sys.exit(main(sys.argv[1] if len(sys.argv) > 1 else '.'))
79 changes: 79 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Tests

# Toolchain versions track docker/Dockerfile. This repo has no Gradle wrapper,
# so the Gradle version has to be pinned here.
on:
pull_request:
branches: [dev]

permissions:
contents: read

concurrency:
group: tests-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
test:
name: unit tests (advisory)
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- uses: actions/checkout@v5

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21

- name: Set up Node
uses: actions/setup-node@v5
with:
node-version: 26
cache: yarn

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: '8.10'

# Separate steps so each suite reports on its own. `!cancelled()` so a red
# jest run still lets the Java suite report, while a superseded run stops promptly.
# -Xmx4g is the Gradle daemon heap, overriding gradle.properties' 8 GB;
# the forked test JVM is capped separately at 2 GB by buildScript/tasks.gincl.
- name: JavaScript tests (jest)
id: js-tests
run: gradle --no-daemon -Dorg.gradle.jvmargs=-Xmx4g :firefly:jsTest

- name: Java tests (junit)
id: java-tests
if: '!cancelled()'
run: gradle --no-daemon -Dorg.gradle.jvmargs=-Xmx4g --continue :firefly:test -x jsTest

- name: Upload reports
if: '!cancelled()'
uses: actions/upload-artifact@v4
with:
name: test-reports
path: build/dist/reports/firefly/
if-no-files-found: warn
retention-days: 14

- name: Summarize
if: '!cancelled()'
run: |
set -uo pipefail
{
echo "## Test results"
echo
echo "| suite | result |"
echo "| --- | --- |"
echo "| JavaScript (jest) | ${{ steps.js-tests.outcome }} |"
echo "| Java (junit) | ${{ steps.java-tests.outcome }} |"
echo
} >> "$GITHUB_STEP_SUMMARY"

python3 .github/scripts/summarize-junit.py \
build/dist/reports/firefly/xml >> "$GITHUB_STEP_SUMMARY"
Loading