64 lines
2.8 KiB
Bash
64 lines
2.8 KiB
Bash
#!/bin/sh
|
|
# The same stages are used by Jenkins and explicitly labelled SSH rehearsals.
|
|
set -eu
|
|
phase=${1:?choose native, report, architecture or package}
|
|
root=$(pwd)
|
|
out="$root/build/demo"
|
|
if [ "$phase" = native ]; then python3 demo/ci/reset-output.py; fi
|
|
# The Docker daemon resolves bind sources on the host. Jenkins' workspace lives
|
|
# inside its named volume, so its container-visible path is not a host path.
|
|
case "$root" in
|
|
/home/jenkins/agent/*)
|
|
volume_root=$(docker volume inspect -f '{{.Mountpoint}}' ssw590-delivery-workspace)
|
|
host_root="$volume_root/${root#/home/jenkins/agent/}"
|
|
;;
|
|
*) host_root="$root";;
|
|
esac
|
|
mkdir -p "$out/artifacts" "$out/reports"
|
|
python3 demo/ci/verify-snapshot.py
|
|
test -s demo/toolchain.json || { echo 'Prepare and verify the host images before this pipeline.' >&2; exit 1; }
|
|
python3 - <<'PY'
|
|
import json, subprocess
|
|
for name, expected in json.load(open('demo/toolchain.json')).items():
|
|
actual=subprocess.check_output(['docker','image','inspect','-f','{{.Id}}',name],text=True).strip()
|
|
assert actual==expected, (name, 'local toolchain changed')
|
|
PY
|
|
toolchain=ssw590-demo-toolchain:20261125
|
|
python3 demo/ci/sample-load.py "$out/reports/$phase-load.csv" &
|
|
sampler=$!
|
|
trap 'kill "$sampler" 2>/dev/null || true; wait "$sampler" 2>/dev/null || true' EXIT HUP INT TERM
|
|
run() {
|
|
docker run --rm --network none --read-only --cap-drop ALL \
|
|
--security-opt no-new-privileges --memory=768m --memory-swap=1536m \
|
|
--cpus=0.75 --pids-limit=256 --user "$(id -u):$(id -g)" \
|
|
--tmpfs /tmp:rw,nosuid,nodev,size=128m -e HOME=/tmp -e QT_QPA_PLATFORM=offscreen \
|
|
-e GIT_CONFIG_COUNT=1 -e GIT_CONFIG_KEY_0=safe.directory -e GIT_CONFIG_VALUE_0=/workspace \
|
|
--mount "type=bind,source=$host_root,target=/workspace,readonly" \
|
|
--mount "type=bind,source=$host_root/build/demo,target=/output" \
|
|
-w /workspace "$toolchain" sh -eu -c "$1"
|
|
}
|
|
case "$phase" in
|
|
native)
|
|
echo '=== Build C++/Qt application and provider; run all registered CTests ==='
|
|
run 'cmake -S demo/tikzrefinery/code -B /output/native -G Ninja -DCMAKE_BUILD_TYPE=Release
|
|
cmake --build /output/native --parallel 1
|
|
ctest --test-dir /output/native --output-on-failure --output-junit /output/reports/tests.xml
|
|
cp /opt/demo-toolchain/packages.txt /output/reports/toolchain-packages.txt'
|
|
;;
|
|
report)
|
|
echo '=== Compile both authored report editions ==='
|
|
run 'sh demo/ci/build-report.sh'
|
|
;;
|
|
architecture)
|
|
echo '=== Extract architecture from the frozen C++ source ==='
|
|
run 'python3 demo/ci/extract-architecture.py'
|
|
;;
|
|
package)
|
|
echo '=== Package versioned deployable application image and reports ==='
|
|
python3 demo/ci/package.py
|
|
python3 demo/ci/verify-artifacts.py
|
|
;;
|
|
*) echo 'Unknown phase' >&2; exit 1;;
|
|
esac
|
|
python3 demo/ci/verify-snapshot.py
|