diff --git a/configure_ci.sh b/configure_ci.sh index 43ced45..81e4813 100755 --- a/configure_ci.sh +++ b/configure_ci.sh @@ -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; } \ No newline at end of file diff --git a/scripts/02_setup_runner_container.sh b/scripts/02_setup_runner_container.sh index 91c0352..a72fb2c 100755 --- a/scripts/02_setup_runner_container.sh +++ b/scripts/02_setup_runner_container.sh @@ -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 . \ No newline at end of file +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 diff --git a/scripts/03_setup_udev_rules.sh b/scripts/03_setup_udev_rules.sh new file mode 100755 index 0000000..a0464b0 --- /dev/null +++ b/scripts/03_setup_udev_rules.sh @@ -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 </dev/null) - - -# antes de crear el runner falta: -# reglas udev en caso de ser necesario -# probar conexion con STLink -# probar conexion con pcb de rusefi - - -if CONTAINER_HASH=$(docker container inspect $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 "$NAME" -else - if docker container inspect "$NAME" >/dev/null 2>/dev/null; then - echo "existing runner but there is a more recent base image, recreating" - docker rm "$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 $NAME --detach --privileged --restart=unless-stopped $MOUNT \ - -e RUNNER_NAME="$NAME" \ - -e RUNNER_LABELS="$LABEL" \ - -e RUNNER_TOKEN="$RUNNER_TOKEN" \ - -e RUNNER_REPOSITORY_URL=https://github.com/FDSoftware/rusefi \ - rusefi-ci -fi diff --git a/scripts/05_create_new_runner.sh b/scripts/05_create_new_runner.sh new file mode 100755 index 0000000..3f08ca0 --- /dev/null +++ b/scripts/05_create_new_runner.sh @@ -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