equal
deleted
inserted
replaced
|
1 # |
|
2 # A set of functions to be used in PetitParser's CI jobs |
|
3 # |
|
4 |
|
5 # Set up some environment variables (if not set by CI) |
|
6 if [ -z "$BUILD_NUMBER" ]; then |
|
7 BUILD_NUMBER=0 |
|
8 fi |
|
9 PETITCOMPILER_DATA_DIRECTORY=test-data |
|
10 PETITCOMPILER_BENCHMARK_REPORT=benchmark-results-$BUILD_NUMBER.json |
|
11 |
|
12 function ci_download_and_unzip_file { |
|
13 local url=$1 |
|
14 local where=$PETITCOMPILER_DATA_DIRECTORY |
|
15 local file=${url##*/} |
|
16 local directory=${file%.zip} |
|
17 local status=0 |
|
18 |
|
19 if [ ! -d "$PETITCOMPILER_DATA_DIRECTORY/$directory" ]; then |
|
20 pushd "$PETITCOMPILER_DATA_DIRECTORY" |
|
21 wget -O "$file" "$url" |
|
22 set +e |
|
23 unzip -o "$file" |
|
24 status=$? |
|
25 set -e |
|
26 case "$status" in |
|
27 0) |
|
28 status=0 |
|
29 ;; |
|
30 1) |
|
31 status=0 |
|
32 ;; |
|
33 2) |
|
34 status=0 |
|
35 ;; |
|
36 *) |
|
37 ;; |
|
38 esac |
|
39 rm -f "$file" |
|
40 popd |
|
41 else |
|
42 echo "Skipped $directory (already present)" |
|
43 fi |
|
44 return "$status" |
|
45 } |
|
46 |
|
47 function ci_download_test_data { |
|
48 if [ ! -x "$PETITCOMPILER_DATA_DIRECTORY" ]; then |
|
49 mkdir -p "$PETITCOMPILER_DATA_DIRECTORY" |
|
50 fi |
|
51 ci_download_and_unzip_file http://scg.unibe.ch/download/jk/petit-compiler/java-src.zip |
|
52 ci_download_and_unzip_file http://scg.unibe.ch/download/jk/petit-compiler/smalltalk-src.zip |
|
53 ci_download_and_unzip_file http://scg.unibe.ch/download/jk/petit-compiler/ruby-src.zip |
|
54 ci_download_and_unzip_file http://scg.unibe.ch/download/jk/petit-compiler/python-src.zip |
|
55 } |
|
56 |
|
57 function ci_upload_benchmark_results { |
|
58 if [ -f "$PETITCOMPILER_BENCHMARK_REPORT" ]; then |
|
59 url 'https://swing.fit.cvut.cz/calipel/imports/push-import' \ |
|
60 --user "$CALIPEL_USER:$CALIPEL_PASSWORD" \ |
|
61 --compressed \ |
|
62 -H 'Content-Type: application/json' \ |
|
63 --data "@$PETITCOMPILER_BENCHMARK_REPORT" |
|
64 fi |
|
65 } |