Skip to content

Commit 8e09639

Browse files
committed
ci: add a local run script that is somewhat borked
Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
1 parent 135a1c8 commit 8e09639

1 file changed

Lines changed: 99 additions & 0 deletions

File tree

ci/local_run.sh

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2026, UNSW
4+
# SPDX-License-Identifier: BSD-2-Clause
5+
6+
set -e
7+
8+
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
9+
10+
if [ "$#" -ne 3 ]; then
11+
echo >&2 "Usage: $0 <microkit-sdk> <seL4/ci-actions checkout> <build-folder>"
12+
exit 1
13+
fi
14+
15+
export MICROKIT_SDK=$(readlink -f "$1")
16+
export CI_ACTIONS=$(readlink -f "$2")
17+
export GITHUB_WORKSPACE=$(readlink -f "$3")
18+
19+
run_ci_actions_steps() {
20+
export INPUT_ACTION_NAME="$1"
21+
action_script="${2:-steps.sh}"
22+
23+
export SCRIPTS="${CI_ACTIONS}/scripts"
24+
export PATH="${SCRIPTS}:${PATH}"
25+
26+
action_dir="${CI_ACTIONS}/${INPUT_ACTION_NAME}"
27+
28+
"${action_dir}/${action_script}"
29+
}
30+
31+
# secrets
32+
export HW_SSH=$(cat ~/.ssh/id_ed25519)
33+
# pseudo-sandbox
34+
export HOME="${GITHUB_WORKSPACE}"
35+
36+
# used for the job key in machine queue
37+
export GITHUB_REPOSITORY="microkit"
38+
export GITHUB_WORKFLOW="locally"
39+
export GITHUB_RUN_ID="local"
40+
export GITHUB_JOB="local"
41+
42+
# Make sudo a no-op
43+
sudo_tmpdir=$(mktemp -d)
44+
printf '#!/usr/bin/env bash\necho >&2 ignoring sudo "$@"\n' > "${sudo_tmpdir}/sudo"
45+
chmod +x "${sudo_tmpdir}/sudo"
46+
export PATH="${sudo_tmpdir}:${PATH}"
47+
48+
export GITHUB_OUTPUT=$(mktemp)
49+
export GITHUB_ENV=$(mktemp)
50+
51+
mkdir -p "${GITHUB_WORKSPACE}"
52+
53+
# Always create a log file in the build folder.
54+
# use -i so that tee always exits after this script
55+
mkdir -p "${GITHUB_WORKSPACE}/logs"
56+
LOGFILE="${GITHUB_WORKSPACE}/logs/local_run_$(date '+%Y-%m-%d-%H').txt"
57+
echo 2>&1 "Emitting logs to ${LOGFILE}"
58+
exec > >(tee -i "${LOGFILE}") 2>&1
59+
60+
unset PYTHONPATH
61+
python3 -m venv "${GITHUB_WORKSPACE}/venv"
62+
. "${GITHUB_WORKSPACE}/venv/bin/activate"
63+
64+
# don't create __pycache__ folders
65+
export PYTHONDONTWRITEBYTECODE=1
66+
67+
# Pretend microkit is installed here.
68+
mkdir -p "${GITHUB_WORKSPACE}/microkit"
69+
ln -sf "${SCRIPT_DIR}/../build_sdk.py" "${GITHUB_WORKSPACE}/microkit/build_sdk.py"
70+
ln -sf "${SCRIPT_DIR}/../VERSION" "${GITHUB_WORKSPACE}/microkit/VERSION"
71+
72+
cd "${GITHUB_WORKSPACE}"
73+
74+
run_ci_actions_steps "microkit-hw-matrix"
75+
76+
export TEST_CASES=$(cat "${GITHUB_OUTPUT}" | grep "test_cases" | cut -d "=" -f 2)
77+
78+
run_ci_actions_steps "microkit-hw-build"
79+
80+
# Note: This rarely works, because non-interactive bash assumes wait-for-coordinated
81+
# exit and most of our python scripts do not follow this protocol.
82+
trap_handler() {
83+
really_die() {
84+
# Implement Wait-and-Cooperative-Exit protocol
85+
trap - SIGINT
86+
kill -s SIGINT $$
87+
}
88+
89+
echo >&2 "Handling SIGINT signal"
90+
trap 'really_die' SIGINT
91+
92+
run_ci_actions_steps "microkit-hw-run" "post-steps.sh"
93+
94+
really_die
95+
}
96+
97+
trap 'trap_handler' SIGINT
98+
99+
run_ci_actions_steps "microkit-hw-run"

0 commit comments

Comments
 (0)