-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to easily run CI jobs locally
- Loading branch information
1 parent
6248846
commit b4afd3f
Showing
4 changed files
with
118 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
build/ | ||
build*/ | ||
.ycm_extra_conf.py | ||
*.tinyrefl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
|
||
# Full path to the ci/ directory, where this script is located | ||
CI_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" | ||
SRC_DIR=$CI_DIR/.. | ||
cd $CI_DIR | ||
|
||
JOB_NAME=$1 | ||
OPTION=$2 | ||
IMAGE_VARIABLE=${JOB_NAME//-/_}__image | ||
LLVM_VERSION_VARIABLE=${JOB_NAME//-/_}__variables__LLVM_VERSION | ||
CROSS_BUILDING_VARIABLE=${JOB_NAME//-/_}__variables__CROSS_BUILDING | ||
|
||
|
||
# Parse Giltab-ci config file | ||
source yaml.sh | ||
create_variables $SRC_DIR/.gitlab-ci.yml | ||
|
||
IMAGE=${!IMAGE_VARIABLE} | ||
LLVM_VERSION=${!LLVM_VERSION_VARIABLE} | ||
LLVM_VERSION=${LLVM_VERSION//\"/} | ||
CROSS_BUILDING=${!CROSS_BUILDING_VARIABLE} | ||
CROSS_BUILDING=${CROSS_BUILDING//\"/} | ||
|
||
if [[ -z "$IMAGE" ]]; then | ||
>&2 echo No valid ci job named \"$JOB_NAME\" found | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -z "$CROSS_BUILDING" ]]; then | ||
CROSS_BUILDING_FLAG="-e CROSS_BUILDING=$CROSS_BUILDING" | ||
fi | ||
|
||
if [[ "$OPTION" == "--clean-build" ]]; then | ||
CLEAN_BUILD_FLAG="-e CLEAN_BUILD=YES" | ||
elif [[ "$OPTION" == "--help" ]]; then | ||
echo run_job <job-name> [option] | ||
echo " " | ||
echo option: | ||
echo --clean-build : Clean buildtree before build | ||
echo --help : Show this help | ||
exit | ||
fi | ||
|
||
if [[ -z "$LLVM_VERSION" ]]; then | ||
>&2 echo LLVM_VERSION variable not set in job $JOB_NAME | ||
exit 2 | ||
fi | ||
|
||
echo Running job $JOB_NAME | ||
echo Using docker image $IMAGE | ||
echo CROSS_BUILDING=$CROSS_BUILDING | ||
echo LLVM_VERSION=$LLVM_VERSION | ||
|
||
docker run -ti --rm --hostname $JOB_NAME -v $SRC_DIR:/repo -w /repo -e CI_JOB_NAME=$JOB_NAME -e LLVM_VERSION=$LLVM_VERSION $CROSS_BUILDING_FLAG $CLEAN_BUILD_FLAG $IMAGE bash -c "./ci/ci.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
# Based on https://gist.github.com/pkuczynski/8665367 | ||
|
||
function parse_yaml() { | ||
local yaml_file=$1 | ||
local prefix=$2 | ||
local s | ||
local w | ||
local fs | ||
|
||
s='[[:space:]]*' | ||
w='[a-zA-Z0-9_.-]*' | ||
fs="$(echo @|tr @ '\034')" | ||
|
||
( | ||
sed -ne '/^--/s|--||g; s|\"|\\\"|g; s/\s*$//g;' \ | ||
-e "/#.*[\"\']/!s| #.*||g; /^#/s|#.*||g;" \ | ||
-e "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \ | ||
-e "s|^\($s\)\($w\)$s[:-]$s\(.*\)$s\$|\1$fs\2$fs\3|p" | | ||
|
||
awk -F"$fs" '{ | ||
indent = length($1)/2; | ||
if (length($2) == 0) { conj[indent]="+";} else {conj[indent]="";} | ||
vname[indent] = $2; | ||
for (i in vname) {if (i > indent) {delete vname[i]}} | ||
if (length($3) > 0) { | ||
vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")} | ||
printf("%s%s%s%s=(\"%s\")\n", "'"$prefix"'",vn, $2, conj[indent-1],$3); | ||
} | ||
}' | | ||
|
||
sed -e 's/_=/+=/g' | | ||
awk 'BEGIN { | ||
FS="="; | ||
OFS="=" | ||
} | ||
/(-|\.).*=/ { | ||
gsub("-|\\.", "_", $1) | ||
} | ||
{ print }' | ||
|
||
) < "$yaml_file" | ||
} | ||
|
||
function create_variables() { | ||
local yaml_file="$1" | ||
eval "$(parse_yaml "$yaml_file")" | ||
} | ||
|