Skip to content
Merged
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
179 changes: 138 additions & 41 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,11 @@ jobs:
- name: Linux
id: linux
os: ubuntu-24.04
pdf: true
- name: macOS
id: macos
os: macos-15
pdf: false
env:
# PDF reports are written on Linux only; the other platforms write Markdown.
PDF_OPTION: ${{ !matrix.pdf && '--no-pdf' || '' }}
# The reports are written as Markdown here; the test-reports job converts
# those of every platform to PDF.
steps:
- name: Check out the source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down Expand Up @@ -331,30 +328,23 @@ jobs:
--output-junit test-results/external.xml

# ---- Full suites (see FULL_SUITES above) ----
# With pandoc on PATH, ctest_suite.sh also writes each report as a PDF.
- name: Install pandoc and LaTeX
if: ${{ !cancelled() && steps.build.conclusion == 'success' && env.FULL_SUITES == 'true' && matrix.pdf }}
run: |
sudo apt-get install --yes --no-install-recommends \
pandoc texlive-xetex texlive-latex-recommended texlive-fonts-recommended lmodern

- name: Run the verification tests
if: ${{ !cancelled() && steps.build.conclusion == 'success' && env.FULL_SUITES == 'true' }}
run: >
./scripts/unix/ctest_suite.sh verification -j "${CTEST_JOBS}" ${PDF_OPTION}
./scripts/unix/ctest_suite.sh verification -j "${CTEST_JOBS}" --no-pdf
--junit test-results/verification.xml

- name: Run the comparison tests
if: ${{ !cancelled() && steps.build.conclusion == 'success' && env.FULL_SUITES == 'true' }}
run: >
./scripts/unix/ctest_suite.sh comparison -j "${CTEST_JOBS}" ${PDF_OPTION}
./scripts/unix/ctest_suite.sh comparison -j "${CTEST_JOBS}" --no-pdf
--junit test-results/comparison.xml

# Runs last of the CTest suites, so the regression report describes the long run.
- name: Run the long regression tests
if: ${{ !cancelled() && steps.build.conclusion == 'success' && env.FULL_SUITES == 'true' }}
run: >
./scripts/unix/ctest_suite.sh regression --long -j "${CTEST_JOBS}" ${PDF_OPTION}
./scripts/unix/ctest_suite.sh regression --long -j "${CTEST_JOBS}" --no-pdf
--junit test-results/regression-long.xml

- name: Run the demo cases against their baselines
Expand All @@ -370,24 +360,6 @@ jobs:
continue-on-error: true
run: ./scripts/unix/ctest_suite.sh benchmark --junit test-results/benchmark.xml

# The report generators keep going when the PDF conversion fails.
- name: Check that the PDF reports were written
if: ${{ !cancelled() && steps.build.conclusion == 'success' && env.FULL_SUITES == 'true' && matrix.pdf }}
run: |
status=0
for report in \
regression/report/regression_test_report.pdf \
verification/report/verification_report.pdf \
comparison/report/comparison_test_report.pdf; do
if [[ -s "build/bin/Release/results/tests/${report}" ]]; then
echo "[OK] ${report}"
else
echo "::error::PDF report missing or empty: ${report}"
status=1
fi
done
exit "${status}"

# CTest exits with 0 when a test is skipped. Fail unless every test ran.
- name: Check that every test ran and passed
if: ${{ !cancelled() && steps.build.conclusion == 'success' }}
Expand All @@ -403,6 +375,21 @@ jobs:
done
exit "${status}"

# The summary of measured values against their limits, from each report,
# on the page of the workflow run.
- name: Show the checks against limits on the run page
if: ${{ !cancelled() && steps.build.conclusion == 'success' }}
run: |
reports="regression/report/regression_test_report.md"
if [[ "${FULL_SUITES}" == "true" ]]; then
reports="${reports} verification/report/verification_report.md comparison/report/comparison_test_report.md"
fi
for report in ${reports}; do
python3 scripts/ci/report_section.py "build/bin/Release/results/tests/${report}" \
--title "${report%%/*} checks against limits (${{ matrix.name }})" \
--summary "${GITHUB_STEP_SUMMARY}" || true
done

- name: Record disk use
if: ${{ !cancelled() }}
run: |
Expand All @@ -421,17 +408,18 @@ jobs:
if-no-files-found: warn
retention-days: 14

# Markdown and PDF reports with the figures they refer to.
- name: Upload test reports
# Markdown reports with their figures, for the test-reports job, which
# converts them to PDF and then deletes this artifact.
- name: Hand over the reports
if: ${{ !cancelled() && steps.build.conclusion == 'success' }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: chrono-${{ matrix.id }}-reports
name: report-sources-${{ matrix.id }}
path: |
build/bin/Release/results/tests/*/report/
build/bin/Release/results/tests/**/plots/
if-no-files-found: warn
retention-days: 30
retention-days: 1

# The Windows jobs use the PowerShell entry points under scripts/windows.
# Eigen and HDF5 come from the vcpkg checkout on the runner image.
Expand Down Expand Up @@ -794,6 +782,21 @@ jobs:
}
exit $status

# The summary of measured values against their limits, from each report,
# on the page of the workflow run.
- name: Show the checks against limits on the run page
if: ${{ !cancelled() && steps.build.conclusion == 'success' }}
run: |
$reports = @('regression/report/regression_test_report.md')
if ($env:FULL_SUITES -eq 'true') {
$reports += 'verification/report/verification_report.md', 'comparison/report/comparison_test_report.md'
}
foreach ($report in $reports) {
$suite = ($report -split '/')[0]
python scripts/ci/report_section.py "build/bin/Release/results/tests/$report" --title "$suite checks against limits (Windows)" --summary $env:GITHUB_STEP_SUMMARY
}
exit 0

- name: Upload test results
if: ${{ !cancelled() }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
Expand All @@ -807,25 +810,119 @@ jobs:
if-no-files-found: warn
retention-days: 14

# Markdown reports with the figures they refer to.
- name: Upload test reports
# Markdown reports with their figures, for the test-reports job, which
# converts them to PDF and then deletes this artifact.
- name: Hand over the reports
if: ${{ !cancelled() && steps.build.conclusion == 'success' }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: chrono-windows-reports
name: report-sources-windows
path: |
build/bin/Release/results/tests/*/report/
build/bin/Release/results/tests/**/plots/
if-no-files-found: warn
retention-days: 1

# Converts the reports of all three platforms to PDF on one Linux runner,
# where pandoc and LaTeX are installed, and uploads them as one artifact,
# test-reports: <platform>/<suite>_test_report.pdf with the figures resampled
# to 150 dpi (lossless) for reading on screen. The regression reports are
# always included; verification and comparison with the full suites.
test-reports:
name: PDF test reports
if: ${{ !cancelled() }}
needs: [chrono, chrono-windows]
runs-on: ubuntu-24.04
timeout-minutes: 30
permissions:
contents: read
# To delete the report-sources-* artifacts once they are converted.
actions: write
steps:
- name: Check out the source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ env.CHECKOUT_REF }}
persist-credentials: false

- name: Install pandoc, LaTeX and Ghostscript
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends \
pandoc texlive-xetex texlive-latex-recommended texlive-fonts-recommended lmodern ghostscript

- name: Download the reports of each platform
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: report-sources-*
path: report-sources

# The download makes one folder per artifact, report-sources/report-sources-<platform>.
- name: Convert the reports to PDF
run: |
mkdir -p sources
for folder in report-sources/report-sources-*; do
[[ -d "${folder}" ]] && mv "${folder}" "sources/${folder##*/report-sources-}"
done
ls sources
required="regression"
if [[ "${FULL_SUITES}" == "true" ]]; then
required="regression verification comparison"
fi
# A platform whose Chrono job failed has no reports; that job already
# fails the run, so only the platforms present are checked.
python3 scripts/ci/render_reports.py sources full-resolution --require ${required}

- name: Resample the figures for reading on screen
run: |
mkdir -p test-reports
for source_pdf in full-resolution/*/*.pdf; do
platform="$(basename "$(dirname "${source_pdf}")")"
screen_pdf="test-reports/${platform}/$(basename "${source_pdf}")"
mkdir -p "$(dirname "${screen_pdf}")"
if ! gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite \
-dDownsampleColorImages=true -dColorImageDownsampleType=/Bicubic \
-dColorImageResolution=150 -dColorImageDownsampleThreshold=1.0 \
-dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode \
-dDownsampleGrayImages=true -dGrayImageDownsampleType=/Bicubic \
-dGrayImageResolution=150 -dGrayImageDownsampleThreshold=1.0 \
-dAutoFilterGrayImages=false -dGrayImageFilter=/FlateEncode \
-sOutputFile="${screen_pdf}" "${source_pdf}" || [[ ! -s "${screen_pdf}" ]]; then
echo "::warning::could not resample ${source_pdf}; uploading it at full resolution"
cp "${source_pdf}" "${screen_pdf}"
fi
echo "[OK] ${platform}/$(basename "${source_pdf}"): $(du -h "${source_pdf}" | cut -f1) -> $(du -h "${screen_pdf}" | cut -f1)"
done

- name: Upload the PDF reports
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: test-reports
path: test-reports/
if-no-files-found: error
retention-days: 30

# Best effort: a pull request from a fork gets a read-only token, and the
# artifacts then expire after one day instead.
- name: Delete the converted report sources
if: ${{ always() }}
env:
GH_TOKEN: ${{ github.token }}
run: |
ids="$(gh api "repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts" --paginate \
--jq '.artifacts[] | select(.name | startswith("report-sources-")) | .id')" || ids=""
for id in ${ids}; do
gh api -X DELETE "repos/${GITHUB_REPOSITORY}/actions/artifacts/${id}" \
|| echo "::warning::could not delete artifact ${id}"
done

# One status for branch protection: passes only if every job above passed.
# Requiring this job means the list of platforms can change without editing
# the repository settings.
all-checks:
name: All checks
if: ${{ always() }}
needs: [chrono-free, chrono, chrono-free-windows, chrono-windows]
needs: [chrono-free, chrono, chrono-free-windows, chrono-windows, test-reports]
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
Expand Down
84 changes: 84 additions & 0 deletions scripts/ci/render_reports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env python3
"""Render the Markdown test reports of several platforms as PDF.

Usage:
python3 scripts/ci/render_reports.py <sources> <output> [--require SUITE ...]

<sources> holds one folder per platform (linux, macos, windows), each with the
layout of build/bin/<Config>/results/tests: <suite>/report/<report>.md and the
figures that the report refers to. For every report found, this writes
<output>/<platform>/<suite>_test_report.pdf with the same PDF settings as the
report generators (tests/utilities/report_generator.py), and the platform
added to the subtitle.

The continuous integration workflow uses this to make the PDFs of all three
platforms on one Linux runner, where pandoc and LaTeX are installed.

--require names suites whose report must exist for every platform folder;
a missing one fails the run. A report that is found but cannot be converted
always fails the run.

Exit code 0 = all reports converted, 1 = a conversion failed or a required
report is missing, 2 = usage error.
"""
from __future__ import annotations

import argparse
import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "tests" / "utilities"))
from report_generator import generate_pdf # noqa: E402

# Suite -> (report path under the suite folder, title, subtitle); as in the
# generate_*_report.py scripts under tests/.
REPORTS = {
"regression": ("report/regression_test_report.md", "SEA-Stack Regression Test Report",
"Compares current outputs to stored reference data for core cases."),
"verification": ("report/verification_report.md", "SEA-Stack Verification Test Report",
"Cross-code verification of hydrodynamic simulation capabilities"),
"comparison": ("report/comparison_test_report.md", "SEA-Stack Comparison Test Report",
"Internal method comparisons within SEA-Stack"),
}
PLATFORM_NAMES = {"linux": "Linux", "macos": "macOS", "windows": "Windows"}


def main() -> int:
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
parser.add_argument("sources", type=Path, help="folder with one sub-folder per platform")
parser.add_argument("output", type=Path, help="folder for <platform>/<suite>_test_report.pdf")
parser.add_argument("--require", nargs="*", default=[], choices=sorted(REPORTS),
help="suites whose report must exist for every platform")
args = parser.parse_args()

platforms = sorted(p for p in args.sources.iterdir() if p.is_dir()) if args.sources.is_dir() else []
if not platforms:
print(f"[FAIL] no platform folders in {args.sources}", file=sys.stderr)
return 1

problems = []
for platform_dir in platforms:
platform = platform_dir.name
label = PLATFORM_NAMES.get(platform, platform)
for suite, (relative, title, subtitle) in REPORTS.items():
markdown = platform_dir / suite / relative
if not markdown.is_file():
if suite in args.require:
problems.append(f"{platform}: {suite} report not found ({markdown})")
continue
pdf = args.output / platform / f"{suite}_test_report.pdf"
pdf.parent.mkdir(parents=True, exist_ok=True)
result = generate_pdf(markdown, pdf, quiet=True, report_title=title,
report_subtitle=f"{subtitle} ({label})")
if result is None or not pdf.is_file() or pdf.stat().st_size == 0:
problems.append(f"{platform}: {suite} report could not be converted to PDF")
else:
print(f"[OK] {platform}/{pdf.name} ({pdf.stat().st_size / 1e6:.1f} MB)")

for problem in problems:
print(f"::error::{problem}")
return 1 if problems else 0


if __name__ == "__main__":
raise SystemExit(main())
Loading
Loading