mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-11-10 22:27:08 +01:00
Executing coursework has silently overwritten a submitted deliverable twice in
this campaign -- TRAK's outputs/output.png and SPD's results_*.png -- and both
times it was found by a later `git status`, not by the run. `course_main` now
snapshots what git sees under the course root before and after `_run`, and
fails with a diff naming the files if anything moved. Gitignored build output
does not show up there, which is why every runner already writes into build/.
Seen failing before being trusted: a stub whose `_run` appends a newline to
TRAK's config.ini exits 1 and names the file; the same stub without the append
exits 0; and a real `./run.sh run Programming/TRAK` still exits 0 after
rendering, because it writes into build/.
The notebook branch was the specific landmine. `nbconvert --execute --inplace`
rewrites the notebook it just ran, and all four notebooks here are tracked with
their outputs. It now executes to a temp --output-dir. That alone is not
enough, though: nbconvert runs the kernel with its cwd set to the notebook's
own directory, so a cell calling plt.savefig('x.png') still writes beside the
notebook. The tree check above is what actually catches that, which is why it
lives in course_main and applies to every course kind rather than to notebooks.
`_have jupyter` was also the wrong probe. jupyter on this machine is a pipx
shim whose interpreter is gone: `command -v` finds it, and running it exits
127. Both the probe and the runner now use `_works`, which runs `--version`.
`./Programming/twm_4/run.sh --probe` reports "needs jupyter" and exit 78
instead of failing confusingly mid-run.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
71 lines
2.7 KiB
Bash
71 lines
2.7 KiB
Bash
# shellcheck shell=bash
|
|
# Split out of course_lib.sh, which was over this repo's 250-line cap. Sourced
|
|
# by it, never on its own -- the helpers and constants it uses live there.
|
|
#
|
|
# Answers --probe: can this course run HERE, without running it.
|
|
|
|
# --- probes ------------------------------------------------------------------
|
|
|
|
_probe() {
|
|
case "$COURSE_KIND" in
|
|
none) _no_code "${COURSE_NOTE:-no executable code in this directory}" ;;
|
|
tex)
|
|
_probe_any "a LaTeX toolchain" latexmk pdflatex xelatex
|
|
_runnable "builds ${COURSE_ENTRY:-the report} with latexmk"
|
|
;;
|
|
python)
|
|
_have python3 || _blocked "needs python3"
|
|
[[ -n "$(_first_file '*.py')" ]] || _no_code "no .py files found"
|
|
_runnable "python3 ${COURSE_ENTRY:-the entry script}"
|
|
;;
|
|
node)
|
|
_have node || _blocked "needs node"
|
|
_have npm || _blocked "needs npm"
|
|
_runnable "npm install && npm start"
|
|
;;
|
|
maven)
|
|
_have mvn || _blocked "needs maven"
|
|
_have java || _blocked "needs a JDK"
|
|
_runnable "mvn package"
|
|
;;
|
|
make)
|
|
_have make || _blocked "needs make"
|
|
_probe_any "a C compiler" gcc cc clang
|
|
_runnable "make"
|
|
;;
|
|
dotnet)
|
|
_have dotnet || _blocked "needs the .NET SDK"
|
|
_runnable "dotnet build"
|
|
;;
|
|
unity)
|
|
_have unity-editor || _have unityhub \
|
|
|| _blocked "needs the Unity editor (GUI, not installable on a CI runner)"
|
|
_runnable "opens in the Unity editor"
|
|
;;
|
|
matlab)
|
|
_probe_any "MATLAB or Octave" matlab octave
|
|
_runnable "runs the .m scripts"
|
|
;;
|
|
cxx)
|
|
_probe_any "a C++ compiler" g++ clang++
|
|
[[ -n "$(_first_file '*.cpp')" ]] || _no_code "no .cpp files found"
|
|
_runnable "compiles each standalone .cpp"
|
|
;;
|
|
notebook)
|
|
_works jupyter || _blocked "needs jupyter"
|
|
# Being on PATH is not the same as working: this machine has a
|
|
# jupyter shim whose pipx venv interpreter is gone, so it fails
|
|
# with "bad interpreter". Probe by actually invoking it.
|
|
jupyter --version > /dev/null 2>&1 || _blocked "jupyter is on PATH but broken (bad interpreter)"
|
|
_runnable "jupyter nbconvert --execute"
|
|
;;
|
|
compose)
|
|
_have docker || _blocked "needs docker"
|
|
docker info > /dev/null 2>&1 || _blocked "docker is installed but the daemon is not running"
|
|
_runnable "docker compose up"
|
|
;;
|
|
*) _blocked "unknown COURSE_KIND '${COURSE_KIND:-unset}'" ;;
|
|
esac
|
|
}
|
|
|