Skip to content

Commit

Permalink
Added GoCD CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Neko-Box-Coder committed Nov 26, 2023
1 parent 44a1a7e commit 7a14ca6
Show file tree
Hide file tree
Showing 8 changed files with 641 additions and 44 deletions.
29 changes: 29 additions & 0 deletions CI/LinuxSetupFor_ssGUI.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# This is for Ubuntu 22.04

set -e

apt update
apt upgrade -y

# Allow greater tls version compativility
apt install -y gnutls-bin

# Tools for building
apt install -y cmake
apt install -y g++

# XOrg and OpenGL
apt install -y mesa-common-dev
apt install -y mesa-utils
apt install -y xvfb
# apt install -y libx11-dev
apt install -y libxrandr-dev
apt install -y libxcursor-dev


# Run this on agent
#Xvfb :5 -screen 0 1280x720x24 &
#export DISPLAY=:5
#disown
186 changes: 186 additions & 0 deletions CI/NotifyPipeline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
#!/bin/bash

set -e

POSITIONAL_ARGS=()
HELP_STR="
-h | --help Show Help
-a | --auth-token <token> (Required) Personal Access Token
-d | --domain <domain name> (Required) Domain name for GoCD Server
-p | --port <port> GoCD Server Port
--pipeline-name <pipeline name> (Required) Pipename to trigger
-e | --environment <name> <value> Environment Variable to add
--env-pair <name1>:<name2> <value1>:<value2> Adding Environment Variables separated by colon
--http Use http instead https
"

USE_HTTP=false

# List of environment variables
ENV_VARS_NAMES=()
ENV_VARS_VALUES=()

while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
echo "$HELP_STR"
exit 0
;;
-a|--auth-token)
TOKEN="$2"
shift # past argument
shift # past value
;;
-d|--domain)
DOMAIN="$2"
shift # past argument
shift # past value
;;
-p|--port)
PORT="$2"
shift # past argument
shift # past value
;;
--pipeline-name)
PIPELINE_NAME="$2"
shift # past argument
shift # past value
;;
-e|--environment)
ENV_VARS_NAMES+=("$2")

CUR_ENV_VALUE=$(echo "$3" | sed ':a
N
$!ba
s/\n/\\n/g
s/\"/\\\"/g')

ENV_VARS_VALUES+=("$CUR_ENV_VALUE")

echo "Current Env Name: $2"
echo "Current Env Value: $CUR_ENV_VALUE"

shift # past argument
shift # past value
shift # past value
#-t|--target)
# TARGET="$2"
# shift # past argument
# shift # past value
# ;;
--env-pair)
IFS=":" read CUR_NAME_1 CUR_NAME_2 SPLIT_EXCESS <<< "$2"
# Check if there is exactly one colon in the argument string
if [ "$CUR_NAME_1:$CUR_NAME_2" != "$2" ]; then
echo "Error: Env-Pair should contain exactly one colon."
echo "CUR_NAME_1: $CUR_NAME_1"
echo "CUR_NAME_2: $CUR_NAME_2"
echo "SPLIT_EXCESS: $SPLIT_EXCESS"
exit 1
fi
ENV_VARS_NAMES+=("$CUR_NAME_1" "$CUR_NAME_2")

IFS=":" read CUR_VALUE_1 CUR_VALUE_2 SPLIT_EXCESS <<< "$3"
# Check if there is exactly one colon in the argument string
if [ "$CUR_VALUE_1:$CUR_VALUE_2" != "$3" ]; then
echo "Error: Env-Pair should contain exactly one colon."
echo "CUR_VALUE_1: $CUR_VALUE_1"
echo "CUR_VALUE_2: $CUR_VALUE_2"
echo "SPLIT_EXCESS: $SPLIT_EXCESS"
exit 1
fi

CUR_VALUE_1=$(echo "$CUR_VALUE_1" | sed ':a
N
$!ba
s/\n/\\n/g
s/\"/\\\"/g')

CUR_VALUE_2=$(echo "$CUR_VALUE_2" | sed ':a
N
$!ba
s/\n/\\n/g
s/\"/\\\"/g')

ENV_VARS_VALUES+=("$CUR_VALUE_1" "$CUR_VALUE_2")

shift # past argument
shift # past value
shift # past value

;;
--http)
USE_HTTP=true
shift # past argument
;;
#--default)
# DEFAULT=YES
# shift # past argument
# ;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
echo "Unknown field $1"
exit 1
#shift # past argument
#POSITIONAL_ARGS+=("$1") # save positional arg
;;
esac
done

# Check if all arguments are populated
if [ -z $TOKEN ] || [ -z $DOMAIN ] || [ -z $PIPELINE_NAME ]; then
echo "Error: Not all arguments are provided."
echo "TOKEN: $TOKEN"
echo "DOMAIN: $DOMAIN"
echo "PIPELINE_NAME: $PIPELINE_NAME"
exit 1
fi

# Print the values of the environment variables
#echo "USER_STRING: $USER_STRING"
#echo "BRANCH_STRING: $BRANCH_STRING"

# Print all variables
#echo "TOKEN: $TOKEN"
#echo "DOMAIN: $DOMAIN"
#echo "PORT: $PORT"
#echo "PIPELINE_NAME: $PIPELINE_NAME"
#echo "TARGET: $TARGET"
#echo "USER_STRING: $USER_STRING"
#echo "BRANCH_STRING: $BRANCH_STRING"

HTTP_STR="$([ $USE_HTTP == true ] && echo "http" || echo "https")"
PORT_STR="$([ -z $PORT ] && echo "" || echo ":$PORT")"

# Assemble Environment Variables Json String
ENV_VARS_JSON=""
for (( i=0; i<${#ENV_VARS_NAMES[@]}; i++ )); do
if [ $i -gt 0 ]; then
ENV_VARS_JSON="$ENV_VARS_JSON, "
fi

ENV_VARS_JSON="$ENV_VARS_JSON
{
\"name\": \"${ENV_VARS_NAMES[$i]}\",
\"secure\": false,
\"value\": \"${ENV_VARS_VALUES[$i]}\"
}"
done

ENV_VARS_JSON="\"environment_variables\": [${ENV_VARS_JSON}]"

curl --fail-with-body "$HTTP_STR://$DOMAIN$PORT_STR/go/api/pipelines/$PIPELINE_NAME/schedule" \
-H "Authorization: Bearer $TOKEN" \
-H 'Accept: application/vnd.go.cd.v1+json' \
-H 'Content-Type: application/json' \
-X POST \
-d "{ \
${ENV_VARS_JSON}, \
\"update_materials_before_scheduling\": true \
}"

# Return success status
exit 0
27 changes: 18 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -660,24 +660,33 @@ endif()

# This is only called when embed target is specified for CMake
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/Embed2C" EXCLUDE_FROM_ALL)

include("${CMAKE_CURRENT_LIST_DIR}/External/Embed2C/embedFile.cmake")

set(EMBED_EXEC_PATH "")
GET_EXEC_PATH(EMBED_EXEC_PATH)

function(CopyResources targetDir)
file(MAKE_DIRECTORY ${targetDir})
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_LIST_DIR}/Resources ${targetDir}/Resources)
endfunction()

file(SIZE "${CMAKE_CURRENT_LIST_DIR}/Src/ssGUI/EmbeddedResources.c" EMBEDDED_FILE_SIZE)
if(EMBEDDED_FILE_SIZE LESS 1024)
EMBED_FILES("${CMAKE_CURRENT_LIST_DIR}/Src/ssGUI/EmbeddedResources.c"
"${CMAKE_CURRENT_LIST_DIR}/Resources/NotoSans-Regular.ttf"
"NotoSans_Regular"
"${CMAKE_CURRENT_LIST_DIR}/Resources/DownArrow.png"
"DownArrow"
"${CMAKE_CURRENT_LIST_DIR}/Resources/RotationCursor.png"
"RotationCursor"
"${CMAKE_CURRENT_LIST_DIR}/Resources/WindowIcon.png"
"WindowIcon")
set(DEFAULT_RESOURCES_TO_EMBED "${CMAKE_CURRENT_LIST_DIR}/Resources/NotoSans-Regular.ttf"
"NotoSans_Regular"
"${CMAKE_CURRENT_LIST_DIR}/Resources/DownArrow.png"
"DownArrow"
"${CMAKE_CURRENT_LIST_DIR}/Resources/RotationCursor.png"
"RotationCursor"
"${CMAKE_CURRENT_LIST_DIR}/Resources/WindowIcon.png"
"WindowIcon")

#message("DEFAULT_RESOURCES_TO_EMBED: ${DEFAULT_RESOURCES_TO_EMBED}")

EMBED_FILES("${EMBED_EXEC_PATH}"
"${CMAKE_CURRENT_LIST_DIR}/Src/ssGUI/EmbeddedResources.c"
"${DEFAULT_RESOURCES_TO_EMBED}")

file(SIZE "${CMAKE_CURRENT_LIST_DIR}/Src/ssGUI/EmbeddedResources.c" EMBEDDED_FILE_SIZE)
if(EMBEDDED_FILE_SIZE LESS 1024)
Expand Down
2 changes: 1 addition & 1 deletion External/Embed2C
Submodule Embed2C updated 2 files
+14 −5 README.md
+6 −19 embedFile.cmake
13 changes: 8 additions & 5 deletions Src/Examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeScripts/Executables.cmake")
# Check if example resources is populated
file(SIZE "${CMAKE_CURRENT_LIST_DIR}/ExamplesResources.c" EMBEDDED_FILE_SIZE)
if(EMBEDDED_FILE_SIZE LESS 1024)
EMBED_FILES("${CMAKE_CURRENT_LIST_DIR}/ExamplesResources.c"
"${CMAKE_CURRENT_LIST_DIR}/../../Resources/sd.png"
"ssGUI_Example_sd"
"${CMAKE_CURRENT_LIST_DIR}/../../Resources/NotoSans-Bold.ttf"
"ssGUI_Example_NotoSans_Bold;ssLogger")
set(EXAMPLE_RESOURCES_TO_EMBED "${CMAKE_CURRENT_LIST_DIR}/../../Resources/sd.png"
"ssGUI_Example_sd"
"${CMAKE_CURRENT_LIST_DIR}/../../Resources/NotoSans-Bold.ttf"
"ssGUI_Example_NotoSans_Bold")

EMBED_FILES("${EMBED_EXEC_PATH}"
"${CMAKE_CURRENT_LIST_DIR}/ExamplesResources.c"
"${EXAMPLE_RESOURCES_TO_EMBED}")

file(SIZE "${CMAKE_CURRENT_LIST_DIR}/ExamplesResources.c" EMBEDDED_FILE_SIZE)
if(EMBEDDED_FILE_SIZE LESS 1024)
Expand Down
1 change: 1 addition & 0 deletions Src/Tests/AutoTests/RunAllTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -e
function runTest()
{
if [ -f $1 ]; then
chmod +x $1
$1
else
echo "[Auto Test Warning] $1 doesn't exist, skipping"
Expand Down
51 changes: 34 additions & 17 deletions Src/Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@ include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeScripts/Executables.cmake")
# Check if test resources is populated
file(SIZE "${CMAKE_CURRENT_LIST_DIR}/TestsResources.c" EMBEDDED_FILE_SIZE)
if(EMBEDDED_FILE_SIZE LESS 1024)
EMBED_FILES("${CMAKE_CURRENT_LIST_DIR}/TestsResources.c"
"${CMAKE_CURRENT_LIST_DIR}/../../Resources/arial.ttf"
"ssGUI_Test_arial"
"${CMAKE_CURRENT_LIST_DIR}/../../Resources/NotoColorEmoji.ttf"
"ssGUI_Test_NotoColorEmoji"
"${CMAKE_CURRENT_LIST_DIR}/../../Resources/sd.png"
"ssGUI_Test_sd"
"${CMAKE_CURRENT_LIST_DIR}/../../Resources/sdTestEdge.png"
"ssGUI_Test_sd_edge"
"${CMAKE_CURRENT_LIST_DIR}/../../Resources/NotoSans-Bold.ttf"
"ssGUI_Test_NotoSans_Bold")
set(TESTS_RESOURCES_TO_EMBED "${CMAKE_CURRENT_LIST_DIR}/../../Resources/arial.ttf"
"ssGUI_Test_arial"
"${CMAKE_CURRENT_LIST_DIR}/../../Resources/NotoColorEmoji.ttf"
"ssGUI_Test_NotoColorEmoji"
"${CMAKE_CURRENT_LIST_DIR}/../../Resources/sd.png"
"ssGUI_Test_sd"
"${CMAKE_CURRENT_LIST_DIR}/../../Resources/sdTestEdge.png"
"ssGUI_Test_sd_edge"
"${CMAKE_CURRENT_LIST_DIR}/../../Resources/NotoSans-Bold.ttf"
"ssGUI_Test_NotoSans_Bold")

EMBED_FILES("${EMBED_EXEC_PATH}"
"${CMAKE_CURRENT_LIST_DIR}/TestsResources.c"
"${TESTS_RESOURCES_TO_EMBED}")

file(SIZE "${CMAKE_CURRENT_LIST_DIR}/TestsResources.c" EMBEDDED_FILE_SIZE)
if(EMBEDDED_FILE_SIZE LESS 1024)
Expand All @@ -31,26 +34,40 @@ set_target_properties(ssGUI_Test_Resources PROPERTIES FOLDER "Tests")
# Auto Tests
# ----------------------------------------------------------
#if(NOT ssGUI_MOCK_BACKEND_MODE STREQUAL "${ssGUI_MOCK_OPTION_STRING}")
AddFilesToExecutables( "${CMAKE_CURRENT_LIST_DIR}/AutoTests/BackendTests/"
"${CMAKE_CURRENT_BINARY_DIR}/AutoTests/BackendTests/"
"Tests/AutoTests/BackendTests"
"ssGUI;ssGUI_Test_Resources;ssTest;ssLogger")

# TODO(NOW): Update to CppOverride
#AddFilesToExecutables( "${CMAKE_CURRENT_LIST_DIR}/AutoTests/BackendTests/"
# "${CMAKE_CURRENT_BINARY_DIR}/AutoTests/BackendTests/"
# "Tests/AutoTests/BackendTests"
# "ssGUI;ssGUI_Test_Resources;ssTest;ssLogger")
#else()
# message(WARNING "ssGUI_MOCK_BACKEND_MODE is set to ${ssGUI_MOCK_OPTION_STRING}, skipping backend tests")
# message(WARNING "Set ssGUI_MOCK_BACKEND_MODE to not be ${ssGUI_MOCK_OPTION_STRING} in order to produce backend tests")
#endif()

# TODO(NOW): Update to CppOverride
#if(NOT ssGUI_MOCK_BACKEND_MODE STREQUAL "${ssGUI_MOCK_OFF_OPTION_STRING}")
# AddFilesToExecutables( "${CMAKE_CURRENT_LIST_DIR}/AutoTests/BackendTests/"
# "${CMAKE_CURRENT_BINARY_DIR}/AutoTests/BackendTests/"
# "Tests/AutoTests/BackendTests"
# "ssGUI;ssGUI_Test_Resources;ssTest;ssLogger;SimpleOverride")
#else()
# AddFilesToExecutables( "${CMAKE_CURRENT_LIST_DIR}/AutoTests/BackendTests/"
# "${CMAKE_CURRENT_BINARY_DIR}/AutoTests/BackendTests/"
# "Tests/AutoTests/BackendTests"
# "ssGUI;ssGUI_Test_Resources;ssTest;ssLogger")
#endif()

if(NOT ssGUI_MOCK_BACKEND_MODE STREQUAL "${ssGUI_MOCK_OFF_OPTION_STRING}")
AddFilesToExecutables( "${CMAKE_CURRENT_LIST_DIR}/AutoTests/EventCallbackTests/"
"${CMAKE_CURRENT_BINARY_DIR}/AutoTests/EventCallbackTests/"
"Tests/AutoTests/EventCallbackTests"
"ssGUI;ssGUI_Test_Resources;ssTest;ssLogger")
"ssGUI;ssGUI_Test_Resources;ssTest;ssLogger;SimpleOverride")

AddFilesToExecutables( "${CMAKE_CURRENT_LIST_DIR}/AutoTests/GUIObjectTests/"
"${CMAKE_CURRENT_BINARY_DIR}/AutoTests/GUIObjectTests/"
"Tests/AutoTests/GUIObjectTests"
"ssGUI;ssGUI_Test_Resources;ssTest;ssLogger")
"ssGUI;ssGUI_Test_Resources;ssTest;ssLogger;SimpleOverride")
else()
message(WARNING "ssGUI_MOCK_BACKEND_MODE is set to ${ssGUI_MOCK_OFF_OPTION_STRING}, skipping tests")
endif()
Expand Down
Loading

0 comments on commit 7a14ca6

Please sign in to comment.