Skip to content

Commit

Permalink
ci: add a seperated script to do freeloader build testing
Browse files Browse the repository at this point in the history
see .github/build.sh

eg.

export NUCLEI_SDK_ROOT=/path/to/nuclei-sdk
.github/build.sh

Signed-off-by: Huaqi Fang <[email protected]>
  • Loading branch information
fanghuaqi committed Dec 6, 2024
1 parent 9641d64 commit 5fc92b3
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 26 deletions.
53 changes: 53 additions & 0 deletions .github/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#/bin/env bash

# Reset
COLOROFF='\033[0m' # Text Reset

# Regular Colors
BLACK='\033[0;30m' # Black
RED='\033[0;31m' # Red
GREEN='\033[0;32m' # Green
YELLOW='\033[0;33m' # Yellow

if [ ! -f $NUCLEI_SDK_ROOT/NMSIS_VERSION ] ; then
echo -e "${RED}NUCLEI_SDK_ROOT environment variable is not set or path not valid, please set it to where your Nuclei SDK located!${COLOROFF}"
echo "eg. export NUCLEI_SDK_ROOT=/path/to/nuclei-sdk"
exit 1
else
echo -e "${YELLOW}Setup Nuclei SDK build environment${COLOROFF}"
pushd ${NUCLEI_SDK_ROOT}
echo -e "${GREEN}Nuclei SDK version is $(git describe --tags --always 2>/dev/null || echo "not a git repo, please check version in ${NUCLEI_SDK_ROOT}/npk.yml")${COLOROFF}"
source setup.sh
popd
fi

echo -e "${YELLOW}Here is your NUCLEI_SDK_ROOT=$NUCLEI_SDK_ROOT ${COLOROFF}"

# Exit on error
set -e

echo -e "${YELLOW}Start to do flashloader build test in different build mode${COLOROFF}"
for mode in "sdk" "loader"; do
for arch in "rv32" "rv64"; do
for spi in "nuspi" "fespi"; do
makeflags="MODE=$mode ARCH=$arch SPI=$spi FLASH=w25q256fv"
echo -e "${YELLOW}Clean and build freeloader for $makeflags ${COLOROFF}"
make $makeflags clean all
if [ "$spi" == "fespi" ] && [ "$mode" == "sdk" ]; then
make $makeflags clean
echo -e "${YELLOW}Test in qemu and check whether pass or fail${COLOROFF}"
timeout --foreground -s SIGTERM 30s make $makeflags SIMU=qemu run_qemu
if [ "x$?" == "x0" ] ; then
echo -e "${GREEN}Test in qemu for $makeflags: PASS ${COLOROFF}"
else
echo -e "${RED}Test in qemu for $makeflags: FAIL ${COLOROFF}"
fi
fi
make $makeflags clean
done
done
done

echo -e "${GREEN}Freeloader build testing passed!${COLOROFF}"

exit 0
29 changes: 3 additions & 26 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
prebuilt_tools/*.tar.gz
key: build

- name: Prepare Tools for Ubuntu
- name: Prepare Tools
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get -q update
Expand Down Expand Up @@ -81,31 +81,8 @@ jobs:
- name: Build and Test Flashloader
run: |
echo "Setup Nuclei SDK build environment"
cd nuclei-sdk
git describe --tags --always
source setup.sh
cd ..
echo "Set NUCLEI_SDK_ROOT=$(pwd)/nuclei-sdk"
export NUCLEI_SDK_ROOT=$(pwd)/nuclei-sdk
echo "Start to do freeloader build testing"
bash .github/build.sh
echo "Start to do flashloader build test in different build mode"
for mode in "sdk" "loader"; do
for arch in "rv32" "rv64"; do
for spi in "nuspi" "fespi"; do
makeflags="MODE=$mode ARCH=$arch SPI=$spi FLASH=w25q256fv"
echo "Clean and Build freeloader for $makeflags"
make $makeflags clean all
if [ "$SPI" == "fespi" ] ; then
make $makeflags clean
echo "Test in qemu and check whether pass or fail"
timeout 60s make $makeflags SIMU=qemu run_qemu
if [ "x$?" == "x0" ] ; then
echo "Test in qemu for $makeflags: PASS"
else
echo "Test in qemu for $makeflags: FAIL"
fi
fi
done
done
done

0 comments on commit 5fc92b3

Please sign in to comment.