Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jesse/feature/test ci cd #19

Merged
merged 5 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,28 @@ on:
branches: [ "master" ]

jobs:
build:

build-linux:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Checkout submodules
run: git submodule update --init --recursive
- name: Install Deps
run: sudo apt install freeglut3-dev libx11-dev clang-15
- name: Build
run: ./make.sh

build-windows:
runs-on: windows-latest
steps:
- name: Set up MinGW
uses: egor-tensin/setup-mingw@v2
with:
platform: x64
- uses: actions/checkout@v3
- name: Checkout submodules
run: git submodule update --init --recursive
- name: Build
shell: bash
run: ./make.sh

167 changes: 119 additions & 48 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,58 @@ BUNDLED_EXAMPLES="
"
# $EXAMPLES/wave_function_collapse_terrain

declare -a build_job_pids
declare -a build_job_names

# Call like: addPid "job name" <pid>
addPid() {
local name=$1
local pid=$2
# echo "$name -- $pid"
build_job_pids=(${build_job_pids[@]} $pid)
build_job_names=(${build_job_names[@]} $name)
}

waitOnPids() {
while [ ${#build_job_pids[@]} -ne 0 ]; do
# echo "Waiting for pids: ${build_job_pids[@]}"
local range=$(eval echo {0..$((${#build_job_pids[@]}-1))})
local i
for i in $range; do
if ! kill -0 ${build_job_pids[$i]} 2> /dev/null; then

exit_code=0
wait ${build_job_pids[$i]} || exit_code=$?

if [ $exit_code -eq 0 ]; then
echo -e "$Success ${build_job_pids[$i]} ${build_job_names[$i]} (exited $exit_code)"
else
echo -e "$Failed ${build_job_pids[$i]} ${build_job_names[$i]} (exited $exit_code)"
exit 1
fi

unset build_job_pids[$i]
fi
done
build_job_pids=("${build_job_pids[@]}") # Expunge nulls created by unset.
sleep 0.25
done
}

# waitOnPids() {
# EXIT_CODE=0
# for job in "${build_job_pids[@]}"; do
# name="${build_job_names[@]}"
# CODE=0;
# wait ${job} || CODE=$?
# if [[ "${CODE}" == "0" ]]; then
# echo -e "$Success $name : ${job}"
# else
# echo "At least one test failed with exit code => ${CODE}" ;
# EXIT_CODE=1;
# fi
# done
# }

EXECUTABLES_TO_BUILD="
$SRC/game_loader.cpp
Expand Down Expand Up @@ -78,7 +130,7 @@ function MakeDebugLibRelease
BuildDebugSystem
[ $? -ne 0 ] && exit 1

wait
waitOnPids
sync

echo "#pragma once" > $DEBUG_LIB_RELEASE_DIR/api.h
Expand Down Expand Up @@ -113,9 +165,12 @@ function BuildExecutables
$PLATFORM_INCLUDE_DIRS \
-I "$ROOT" \
-I "$SRC" \
-I "$INCLUDE" \
-I "$INCLUDE" \
-o "$output_basename""$PLATFORM_EXE_EXTENSION" \
$executable && echo -e "$Success $executable" &
$executable &

addPid "$executable" $!

done
}

Expand All @@ -128,15 +183,18 @@ function BuildDebugOnlyTests
echo -e "$Building $executable"
clang++ \
$CXX_OPTIONS \
$BONSAI_INTERNAL \
$BONSAI_INTERNAL \
$PLATFORM_CXX_OPTIONS \
$PLATFORM_LINKER_OPTIONS \
$PLATFORM_DEFINES \
$PLATFORM_INCLUDE_DIRS \
-I "$ROOT" \
-I"$SRC" \
-o "$output_basename""$PLATFORM_EXE_EXTENSION" \
$executable && echo -e "$Success $executable" &
$executable &

addPid "$executable" $!

done
}

Expand All @@ -150,16 +208,17 @@ function BuildTests
clang++ \
$OPTIMIZATION_LEVEL \
$CXX_OPTIONS \
$BONSAI_INTERNAL \
$BONSAI_INTERNAL \
$PLATFORM_CXX_OPTIONS \
$PLATFORM_LINKER_OPTIONS \
$PLATFORM_DEFINES \
$PLATFORM_INCLUDE_DIRS \
-I "$ROOT" \
-I "$SRC" \
-I "$INCLUDE" \
-I "$INCLUDE" \
-o "$output_basename""$PLATFORM_EXE_EXTENSION" \
$executable && echo -e "$Success $executable" &
$executable &
addPid "$executable" $!
done
}

Expand All @@ -170,23 +229,22 @@ function BuildDebugSystem
DEBUG_SRC_FILE="$INCLUDE/bonsai_debug/debug.cpp"
output_basename="$BIN/lib_debug_system"
echo -e "$Building $DEBUG_SRC_FILE"
clang++ \
$OPTIMIZATION_LEVEL \
$CXX_OPTIONS \
$BONSAI_INTERNAL \
$PLATFORM_CXX_OPTIONS \
$PLATFORM_LINKER_OPTIONS \
$PLATFORM_DEFINES \
$PLATFORM_INCLUDE_DIRS \
$SHARED_LIBRARY_FLAGS \
-I "$ROOT" \
-I "$SRC" \
-I "$INCLUDE" \
-o $output_basename \
"$DEBUG_SRC_FILE" && \
mv "$output_basename" "$output_basename""_loadable""$PLATFORM_LIB_EXTENSION" && \
sync && \
echo -e "$Success $output_basename" &
clang++ \
$OPTIMIZATION_LEVEL \
$CXX_OPTIONS \
$BONSAI_INTERNAL \
$PLATFORM_CXX_OPTIONS \
$PLATFORM_LINKER_OPTIONS \
$PLATFORM_DEFINES \
$PLATFORM_INCLUDE_DIRS \
$SHARED_LIBRARY_FLAGS \
-I "$ROOT" \
-I "$SRC" \
-I "$INCLUDE" \
-o $output_basename \
"$DEBUG_SRC_FILE" && \
mv "$output_basename" "$output_basename""_loadable""$PLATFORM_LIB_EXTENSION" &
addPid "$executable" $!
}

function BuildExamples
Expand All @@ -196,24 +254,24 @@ function BuildExamples
for executable in $EXAMPLES_TO_BUILD; do
echo -e "$Building $executable"
SetOutputBinaryPathBasename "$executable" "$BIN"
clang++ \
-D DEBUG_SYSTEM_API=1 \
$OPTIMIZATION_LEVEL \
$CXX_OPTIONS \
$BONSAI_INTERNAL \
$PLATFORM_CXX_OPTIONS \
$PLATFORM_LINKER_OPTIONS \
$PLATFORM_DEFINES \
$PLATFORM_INCLUDE_DIRS \
$SHARED_LIBRARY_FLAGS \
-I "$ROOT" \
-I "$INCLUDE" \
-I "$SRC" \
-I "$executable" \
-o "$output_basename" \
"$executable/game.cpp" && \
mv "$output_basename" "$output_basename""_loadable""$PLATFORM_LIB_EXTENSION" && \
echo -e "$Success $executable" &
clang++ \
-D DEBUG_SYSTEM_API=1 \
$OPTIMIZATION_LEVEL \
$CXX_OPTIONS \
$BONSAI_INTERNAL \
$PLATFORM_CXX_OPTIONS \
$PLATFORM_LINKER_OPTIONS \
$PLATFORM_DEFINES \
$PLATFORM_INCLUDE_DIRS \
$SHARED_LIBRARY_FLAGS \
-I "$ROOT" \
-I "$INCLUDE" \
-I "$SRC" \
-I "$executable" \
-o "$output_basename" \
"$executable/game.cpp" && \
mv "$output_basename" "$output_basename""_loadable""$PLATFORM_LIB_EXTENSION" &
addPid "$executable" $!
done
}

Expand All @@ -236,7 +294,8 @@ function BuildWithClang
echo -e ""
ColorizeTitle "Complete"

wait
waitOnPids
sync

echo -e ""
echo -e "$Delimeter"
Expand Down Expand Up @@ -278,7 +337,6 @@ function BuildWithEMCC {

# --embed-file shaders \
# --embed-file models \

}


Expand Down Expand Up @@ -349,7 +407,7 @@ function RunPoofHelper {
-I include/ \
-D _M_X64 \
-D _M_CEE \
-D POOF_PREPROCESSOR \
-D POOF_PREPROCESSOR \
$PLATFORM_DEFINES \
$BONSAI_INTERNAL \
-o generated \
Expand All @@ -369,17 +427,30 @@ function RunPoof
# [ -d generated ] && rm -Rf generated

RunPoofHelper src/game_loader.cpp && echo -e "$Success poofed src/game_loader.cpp" &
addPid "" $!

# RunPoofHelper include/bonsai_debug/debug.cpp && echo -e "$Success poofed src/include/bonsai_debug/debug.cpp" &
# addPid "" $!

# RunPoofHelper examples/asset_picker/game.cpp && echo -e "$Success poofed examples/asset_picker/game.cpp" &
# addPid "" $!

# RunPoofHelper examples/the_wanderer/game.cpp && echo -e "$Success poofed examples/the_wanderer/game.cpp" &
# addPid "" $!

# RunPoofHelper examples/turn_based/game.cpp && echo -e "$Success poofed examples/turn_based/game.cpp" &
# addPid "" $!

RunPoofHelper examples/tools/voxel_synthesis_rule_baker/game.cpp && echo -e "$Success poofed examples/tools/voxel_synthesis_rule_baker/game.cpp" &
addPid "" $!

# RunPoofHelper src/tools/asset_packer.cpp && echo -e "$Success poofed src/tools/asset_packer.cpp" &
# RunPoofHelper src/tools/voxel_synthesis_rule_baker.cpp && echo -e "$Success poofed src/tools/voxel_synthesis_rule_baker.cpp" &
# addPid "" $!

# RunPoofHelper src/tools/voxel_synthesis_rule_baker.cpp && echo -e "$Success poofed src/tools/voxel_synthesis_rule_baker.cpp" &
# addPid "" $!

wait
waitOnPids
sync

[ -d tmp ] && rmdir tmp
Expand Down