Skip to content

Commit

Permalink
update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
FDSoftware committed Oct 31, 2024
1 parent b752767 commit 2030686
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 41 deletions.
15 changes: 12 additions & 3 deletions configure_ci.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
#!/bin/bash
echo "--------------------------------------------------------------"
echo "Step 1/5, OS setup"

source scripts/01_setup_OS.sh || { exit 1; }
echo "--------------------------------------------------------------"

echo "--------------------------------------------------------------"
echo "Step 2/5, pulling/creating base runner container"

source scripts/02_setup_runner_container.sh || { exit 1; }

echo "--------------------------------------------------------------"
echo "Step 3/5, updating udev rules"
source scripts/03_setup_udev_rules.sh || { exit 1; }

echo "--------------------------------------------------------------"
echo "Step 4/5, select rusefi board for the runner"
source scripts/04_clone_rusefi_board_definitions.sh || { exit 1; }

echo "--------------------------------------------------------------"
echo "Step 5/5, create the runner"
source scripts/05_create_new_runner.sh || { exit 1; }
9 changes: 6 additions & 3 deletions scripts/02_setup_runner_container.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

docker pull ghcr.io/fdsoftware/rusefi-ci
# should build the image locally if the pull fails?
#docker build --build-arg GID=$(getent group docker | cut -d ':' -f 3) -t rusefi-ci .
if docker pull ghcr.io/fdsoftware/rusefi-ci:main; then
echo "remote docker container pull succeeded"
else
echo "remote docker container pull failed, building image locally"
docker build --build-arg GID=$(getent group docker | cut -d ':' -f 3) -t rusefi-ci:main .
fi
14 changes: 14 additions & 0 deletions scripts/03_setup_udev_rules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

if [ -e "/etc/udev/rules.d/70-rusefi.rules" ]; then
echo "creating udev rules"
cat >/etc/udev/rules.d/70-rusefi.rules <<EOL
SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", GROUP="docker"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5740", GROUP="docker"
EOL
sudo service udev restart

else
echo "skipping, udev rules already installed"

fi
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,4 @@ done
# https://stackoverflow.com/questions/19661267/replace-spaces-with-underscores-via-bash
OPT="${OPT// /-}"

# TODO: pass to 04 script
echo "hw-ci-$OPT"
export RUNNER_NAME="hw-ci-$OPT"
33 changes: 0 additions & 33 deletions scripts/04_create_new_runner.sh

This file was deleted.

37 changes: 37 additions & 0 deletions scripts/05_create_new_runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

LABEL=${2:-"ubuntu-latest"}
IMAGE_HASH=$(docker image inspect rusefi-ci --format "{{.Id}}" 2>/dev/null)

read -p "Enter the rusEFI board serial ID: " HARDWARE_CI_SERIAL
read -p "Enter the STLink ID: " HARDWARE_CI_STLINK_SERIAL
read -p "Enter the CI VBATT: " HARDWARE_CI_VBATT

echo "go to: https://github.com/FDSoftware/rusefi/settings/actions/runners/new and get a new runner token"
read -p "Enter your runner token: " RUNNER_TOKEN

DOCKER_RUNNER_IMAGE=$(docker images | grep -ioh "\S*rusefi-ci\S*" | head -1)

if CONTAINER_HASH=$(docker container inspect $RUNNER_NAME --format "{{.Image}}" 2>/dev/null) && [ "$IMAGE_HASH" = "$CONTAINER_HASH" ]; then
echo "There is already a runner with the same configuration, skipping"
docker start -i "$RUNNER_NAME"
else
if docker container inspect "$RUNNER_NAME" >/dev/null 2>/dev/null; then
echo "existing runner but there is a more recent base image, recreating"
docker rm "$RUNNER_NAME"
fi
if [ -n "$3" ]; then
MOUNT="-v $PWD/$3:/opt/actions-runner/rusefi-env:ro"
fi

#TODO: remove references to personal repo
docker run --name $RUNNER_NAME --detach --privileged --restart=unless-stopped $MOUNT \
-e RUNNER_NAME="$RUNNER_NAME" \
-e RUNNER_LABELS="$LABEL" \
-e RUNNER_TOKEN="$RUNNER_TOKEN" \
-e HARDWARE_CI_SERIAL="$HARDWARE_CI_SERIAL" \
-e HARDWARE_CI_STLINK_SERIAL="$HARDWARE_CI_STLINK_SERIAL" \
-e HARDWARE_CI_VBATT="$HARDWARE_CI_VBATT" \
-e RUNNER_REPOSITORY_URL=https://github.com/FDSoftware/rusefi \
"$DOCKER_RUNNER_IMAGE:main"
fi

0 comments on commit 2030686

Please sign in to comment.