--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ci/ci-common.sh Mon Nov 09 00:38:23 2015 +0000
@@ -0,0 +1,65 @@
+#
+# A set of functions to be used in PetitParser's CI jobs
+#
+
+# Set up some environment variables (if not set by CI)
+if [ -z "$BUILD_NUMBER" ]; then
+ BUILD_NUMBER=0
+fi
+PETITCOMPILER_DATA_DIRECTORY=test-data
+PETITCOMPILER_BENCHMARK_REPORT=benchmark-results-$BUILD_NUMBER.json
+
+function ci_download_and_unzip_file {
+ local url=$1
+ local where=$PETITCOMPILER_DATA_DIRECTORY
+ local file=${url##*/}
+ local directory=${file%.zip}
+ local status=0
+
+ if [ ! -d "$PETITCOMPILER_DATA_DIRECTORY/$directory" ]; then
+ pushd "$PETITCOMPILER_DATA_DIRECTORY"
+ wget -O "$file" "$url"
+ set +e
+ unzip -o "$file"
+ status=$?
+ set -e
+ case "$status" in
+ 0)
+ status=0
+ ;;
+ 1)
+ status=0
+ ;;
+ 2)
+ status=0
+ ;;
+ *)
+ ;;
+ esac
+ rm -f "$file"
+ popd
+ else
+ echo "Skipped $directory (already present)"
+ fi
+ return "$status"
+}
+
+function ci_download_test_data {
+ if [ ! -x "$PETITCOMPILER_DATA_DIRECTORY" ]; then
+ mkdir -p "$PETITCOMPILER_DATA_DIRECTORY"
+ fi
+ ci_download_and_unzip_file http://scg.unibe.ch/download/jk/petit-compiler/java-src.zip
+ ci_download_and_unzip_file http://scg.unibe.ch/download/jk/petit-compiler/smalltalk-src.zip
+ ci_download_and_unzip_file http://scg.unibe.ch/download/jk/petit-compiler/ruby-src.zip
+ ci_download_and_unzip_file http://scg.unibe.ch/download/jk/petit-compiler/python-src.zip
+}
+
+function ci_upload_benchmark_results {
+ if [ -f "$PETITCOMPILER_BENCHMARK_REPORT" ]; then
+ url 'https://swing.fit.cvut.cz/calipel/imports/push-import' \
+ --user "$CALIPEL_USER:$CALIPEL_PASSWORD" \
+ --compressed \
+ -H 'Content-Type: application/json' \
+ --data "@$PETITCOMPILER_BENCHMARK_REPORT"
+ fi
+}
\ No newline at end of file