Skip to content

Commit

Permalink
ci: ship Docker Image with all the necessary tools for build
Browse files Browse the repository at this point in the history
 - this was done to ensure that all workflows already contain the required tools, without the need to download them at runtime

Signed-off-by: Bindea Cristian <[email protected]>
  • Loading branch information
bindea-cristian committed Sep 6, 2024
1 parent 03afef0 commit 801e5a0
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/appimage-armhf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
/bin/bash -c 'cd $HOME && \
sudo chown -R runner:runner scopy && \
cd $HOME/scopy && \
./ci/armhf/armhf_build_process.sh install_packages download_cmake download_crosscompiler move_sysroot build_scopy build_iio-emu create_appdir create_appimage move_appimage
./ci/armhf/armhf_build_process.sh install_packages move_tools move_sysroot build_scopy build_iio-emu create_appdir create_appimage move_appimage
'
- name: Set short git commit SHA
shell: bash
Expand Down
4 changes: 4 additions & 0 deletions ci/armhf/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!sysroot.tar.gz
!armhf_build_process.sh
!armhf_build_config.sh
8 changes: 3 additions & 5 deletions ci/armhf/armhf_build_config.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

LIBIIO_VERSION=v0.25
LIBIIO_VERSION=libiio-v0
LIBAD9361_BRANCH=main
GLOG_BRANCH=v0.4.0
LIBM2K_BRANCH=main
Expand All @@ -18,12 +18,10 @@ export APPIMAGE=1

PYTHON_VERSION=python3.9 # default python version used in CI scripts, can be changed to match locally installed python

STAGING_AREA=$SRC_DIR/CI/armhf/staging

STAGING_AREA=$SRC_DIR/ci/armhf/staging
SRC_SCRIPT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
STAGING_AREA=$SRC_SCRIPT/staging
SYSROOT=$STAGING_AREA/sysroot
SYSROOT_TAR=$STAGING_AREA/sysroot.tar.gz
SYSROOT_DOCKER=$SRC_DIR/ci/armhf/docker/sysroot.tar.gz
TOOLCHAIN=$STAGING_AREA/cross-pi-gcc
TOOLCHAIN_BIN=$TOOLCHAIN/bin
TOOLCHAIN_HOST="arm-linux-gnueabihf"
Expand Down
14 changes: 13 additions & 1 deletion ci/armhf/armhf_build_process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ set -ex
git config --global --add safe.directory $HOME/scopy
SRC_DIR=$(git rev-parse --show-toplevel 2>/dev/null ) || \
SRC_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && cd ../../ && pwd )
source $SRC_DIR/ci/armhf/armhf_build_config.sh
SRC_SCRIPT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

source $SRC_SCRIPT/armhf_build_config.sh

echo -- USING CMAKE COMMAND:
echo $CMAKE
Expand Down Expand Up @@ -347,6 +349,16 @@ move_sysroot(){
fi
}

# move the staging folder that contains the tools needed for the build to the known location
move_tools(){
[ -d /home/runner/staging ] && mv /home/runner/staging $STAGING_AREA || echo "Staging folder not found or already moved"
if [ ! -d $STAGING_AREA ]; then
echo "Missing tools folder, downloading now"
download_cmake
download_crosscompiler
fi
}

# move and rename the AppImage artifact
move_appimage(){
mv $APP_IMAGE $SRC_DIR/Scopy-armhf.AppImage
Expand Down
6 changes: 3 additions & 3 deletions ci/armhf/create_docker_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ create_sysroot(){
tar_and_move_sysroot(){
pushd $STAGING_AREA
sudo tar -czvf "${SYSROOT_TAR##*/}" sysroot
sudo mv $SYSROOT_TAR $SYSROOT_DOCKER
sudo mv $SYSROOT_TAR $SRC_DIR/ci/armhf
popd
}

create_image(){
pushd ${SRC_DIR}/ci/armhf/docker
sudo docker build --load --tag cristianbindea/scopy2-armhf-appimage:testing .
pushd ${SRC_DIR}/ci/armhf
sudo docker build --load --tag cristianbindea/scopy2-armhf-appimage:testing -f docker/Dockerfile .
# sudo DOCKER_BUILDKIT=0 docker build --tag cristianbindea/scopy2-armhf-appimage:testing . # build the image using old backend
popd
}
Expand Down
6 changes: 5 additions & 1 deletion ci/armhf/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ COPY --from=sysroot_builder /home/${USER}/scopy/ci/armhf/staging/sysroot/share /
COPY --from=sysroot_builder /home/${USER}/scopy/ci/armhf/staging/sysroot/include /home/${USER}/sysroot/include
WORKDIR /home/${USER}/sysroot
RUN ln -s usr/bin bin && ln -s usr/lib lib && ln -s usr/sbin sbin
WORKDIR /home/${USER}
WORKDIR /home/${USER}
COPY armhf_build_process.sh /home/${USER}/armhf_build_process.sh
COPY armhf_build_config.sh /home/${USER}/armhf_build_config.sh
RUN /home/${USER}/armhf_build_process.sh install_packages download_cmake download_crosscompiler && \
rm /home/${USER}/armhf_build_process.sh /home/${USER}/armhf_build_config.sh
3 changes: 2 additions & 1 deletion ci/x86_64/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ RUN echo "${USER} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-$USER && \
USER $USER
WORKDIR /home/${USER}/scripts
COPY x86-64_appimage_process.sh .
RUN ./x86-64_appimage_process.sh configure_system
RUN ./x86-64_appimage_process.sh download_tools configure_system
RUN mv /home/${USER}/scripts/staging /home/${USER}/staging

ENV CI_SCRIPT=ON
WORKDIR /home/${USER}
Expand Down
11 changes: 10 additions & 1 deletion ci/x86_64/x86-64_appimage_process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,15 @@ generate_ci_envs(){
$SRC_DIR/ci/general/gen_ci_envs.sh > $SRC_DIR/ci/x86_64/gh-actions.envs
}

# move the staging folder that contains the tools needed for the build to the known location
move_tools(){
[ -d /home/runner/staging ] && mv /home/runner/staging $STAGING_AREA || echo "Staging folder not found or already moved"
if [ ! -d $STAGING_AREA ]; then
echo "Missing tools folder, downloading now"
download_tools
fi
}

move_appimage(){
mv $APP_IMAGE $SRC_DIR
}
Expand All @@ -450,7 +459,7 @@ build_deps(){
}

run_workflow(){
download_tools
[ "$CI_SCRIPT" == "ON" ] && move_tools || download_tools
build_iio-emu
build_scopy
create_appdir
Expand Down

0 comments on commit 801e5a0

Please sign in to comment.