diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2023-05-31 10:01:19 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2023-05-31 10:07:55 +0000 |
commit | 009504d7f4cab8c43324d7966bd40c69792f2a41 (patch) | |
tree | 88c0ac6f59ae4982e850ceaf4672b965ea012782 | |
parent | 9f78c79ccbe692e11daad009edd9a703cf2f6a64 (diff) |
start-container-docker.sh: Add "--task precommit"precommit
Configure container for precommit testing:
- use tcwg-build user instead of tcwg-buildslave;
- disable ssh agent forwarding;
- use scratch docker volume for $WORKSPACE instead of bind-mounting from host;
-- use ++rsync_to and ++rsync_from options to transfer data to and from
precommit container -- this is handled in docker-run.sh;
- mount everything else as read-only (e.g., ccache, snapshots-ref, etc.);
- translate absolute /home/* paths
Change-Id: I864174b3a3b3a89a8da15f52a8a0da7f0d948cb7
-rw-r--r-- | jenkins-helpers.sh | 15 | ||||
-rwxr-xr-x | start-container-docker.sh | 35 |
2 files changed, 48 insertions, 2 deletions
diff --git a/jenkins-helpers.sh b/jenkins-helpers.sh index 5fffda0c..a6603b8c 100644 --- a/jenkins-helpers.sh +++ b/jenkins-helpers.sh @@ -720,7 +720,7 @@ print_memory_limit () local memlimit="$4" local memory case "$task" in - build) + build|precommit) if [ "$memlimit" -lt "4000" ]; then # Don't limit memory on machines with less than 4GB RAM. memory="unlimited" @@ -790,6 +790,14 @@ print_mounts () bench|build) echo "$WORKSPACE:$WORKSPACE" ;; + precommit) + # Note the difference between "-v $WORKSPACE:$WORKSPACE" above + # and "-v $WORKSPACE" here. In the above case $WORKSPACE is + # bind-mounted from the host; but in this case a scratch volume + # is created and mounted inside container. + echo "$WORKSPACE" + echo "$WORKSPACE/base-artifacts:$WORKSPACE/base-artifacts:ro" + ;; esac fi @@ -829,12 +837,17 @@ print_mounts () volume_id=$(print_docker_name "$prefix$suffix") local readonly="" + if [ "$task" = "precommit" ]; then + readonly=":ro" + fi echo "ccache-$volume_id:$HOME/.ccache$readonly" ;; esac case "$job" in tcwg_bmk*) + assert_with_msg "Precommit benchmarking requires more thought" \ + [ "$task" != "precommit" ] # Add scratch mount for tcwg-benchmark's $HOME. # tcwg_bmk-* jobs trigger tcwg-benchmark jenkins jobs, which # then ssh to the build container to compile benchmark objects diff --git a/start-container-docker.sh b/start-container-docker.sh index 93ff8543..a54965d6 100755 --- a/start-container-docker.sh +++ b/start-container-docker.sh @@ -126,7 +126,7 @@ do --task) task=$2 case "${task}" in - build|bench|test) ;; + build|precommit|bench|test) ;; *) usage ;; esac shift 2 @@ -228,6 +228,29 @@ SSH="ssh -Snone -oForwardAgent=no" pwd_translate=(cat) +# Configure container for precommit testing: +# - use tcwg-build user instead of tcwg-buildslave; +# - disable ssh agent forwarding; +# - use scratch docker volume for $WORKSPACE instead of bind-mounting from host; +# -- use ++rsync_to and ++rsync_from options to transfer data to and from +# precommit container -- this is handled in docker-run.sh; +# - mount everything else as read-only (e.g., ccache, snapshots-ref, etc.); +# - translate absolute /home/* paths +if [ "$task" = "precommit" ]; then + if [ "$newuser" = "" ]; then + newuser=tcwg-build + fi + if [ "$user" = "" ]; then + user="$newuser" + fi + + if [ "${WORKSPACE+set}" = "set" ]; then + # Translate /home/tcwg-buildslave/* paths to /home/tcwg-build/* paths. + dst_workspace=$(echo "$WORKSPACE" | sed -e "s#^$HOME#/home/$user#") + pwd_translate=(sed -e "s#^$WORKSPACE#$dst_workspace#") + fi +fi + assert_with_msg "user and USER variables should not be set to the same value" \ [ x"$user" != x"$USER" ] @@ -438,6 +461,16 @@ if [ "$user" != "" ]; then git config --global --add safe.directory "$dir" done + if [ "$user" = "tcwg-build" ]; then + # FIXME: Hack -- use tcwg-buildslave's key while tcwg-build's + # is unavailable. + $DOCKER exec "$session_id" cp \ + /home/tcwg-buildslave/.ssh/authorized_keys \ + /home/tcwg-build/.ssh/authorized_keys + $DOCKER exec "$session_id" chown $user \ + /home/tcwg-build/.ssh/authorized_keys + fi + # Below $user is used as a prefix for $session_host user="$user@" fi |