Skip to content

fix: align remaining public basic tests with session semantics #6

fix: align remaining public basic tests with session semantics

fix: align remaining public basic tests with session semantics #6

Workflow file for this run

name: Basic Tests
on:
push:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Check source file exists
id: check
run: |
if [ ! -f mini_tmux.cpp ]; then
echo "::notice::mini_tmux.cpp not found — create this file to start the lab."
echo "## Basic Test Results" >> "$GITHUB_STEP_SUMMARY"
echo "**mini_tmux.cpp not found.** Create this file and push to run tests." >> "$GITHUB_STEP_SUMMARY"
echo "skip=true" >> "$GITHUB_OUTPUT"
fi
- name: Install system dependencies
if: steps.check.outputs.skip != 'true'
run: sudo apt-get update && sudo apt-get install -y build-essential
- name: Build student binary
if: steps.check.outputs.skip != 'true'
run: make
- name: Build harness helpers
if: steps.check.outputs.skip != 'true'
run: make -C harness/helpers
- name: Set up Python
if: steps.check.outputs.skip != 'true'
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install harness dependencies
if: steps.check.outputs.skip != 'true'
run: pip install pexpect pyyaml psutil
- name: Run basic public tests
if: steps.check.outputs.skip != 'true'
run: |
python harness/run_tests.py \
--binary "${{ github.workspace }}/mini-tmux" \
--workloads "${{ github.workspace }}/workloads/public" \
--report "${{ github.workspace }}/report.json"
- name: Show results
if: always() && steps.check.outputs.skip != 'true'
run: |
if [ ! -f report.json ]; then
echo "No report.json found." >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
python3 - <<'PYEOF'
import json, os
with open("report.json") as f:
report = json.load(f)
lines = []
lines.append("## Basic Test Results\n")
total = report.get("total_count", 0)
passed = report.get("pass_count", 0)
lines.append(f"**Passed {passed}/{total} tests**\n")
lines.append("| Test | Status |")
lines.append("|------|--------|")
for w in report.get("workloads", []):
icon = "\u2705" if w["passed"] else "\u274c"
detail = ""
if not w["passed"] and w.get("failed_step"):
detail = f" \u2014 {w['failed_step']}"
lines.append(f"| {w['name']} | {icon}{detail} |")
summary_path = os.environ.get("GITHUB_STEP_SUMMARY", "")
if summary_path:
with open(summary_path, "a") as f:
f.write("\n".join(lines) + "\n")
else:
print("\n".join(lines))
PYEOF
- name: Upload report
if: always() && steps.check.outputs.skip != 'true'
uses: actions/upload-artifact@v4
with:
name: test-report
path: report.json