# HG changeset patch # User Jan Vrany # Date 1447029503 0 # Node ID 8ad6734770cddd4d8fd3bddcb4cd6ff69fb7f776 # Parent 5536a6da50e47f61f83f82135a55a49de28e8399 Added CI scripts for PetitParser. diff -r 5536a6da50e4 -r 8ad6734770cd .hgignore --- a/.hgignore Thu Oct 08 09:41:03 2015 +0100 +++ b/.hgignore Mon Nov 09 00:38:23 2015 +0000 @@ -16,3 +16,14 @@ st.chg package-cache mc + +# CI Artefacts +ci/package-cache +ci/pharo* +ci/test-data +ci/*.image +ci/*.changes +ci/*.fuel +ci/*.json +ci/*.xml +ci/*.log diff -r 5536a6da50e4 -r 8ad6734770cd ci/README.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ci/README.md Mon Nov 09 00:38:23 2015 +0000 @@ -0,0 +1,19 @@ +# CI scripts for PetitParser / PetitCompiler + +This directory contains a set of scripts to run CI jobs. + +## Pharo + +To run tests the same way CI does, run: + + wget -O- https://bitbucket.org/janvrany/stx-goodies-petitparser/raw/tip/ci/ci-pharo-test.sh | bash -x + +To run benchmarks the same way CI does, run: + + wget -O- https://bitbucket.org/janvrany/stx-goodies-petitparser/raw/tip/ci/ci-pharo-benchmark.sh | bash -x + + +## Smalltalk/X + +To be written... + diff -r 5536a6da50e4 -r 8ad6734770cd ci/ci-common.sh --- /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 diff -r 5536a6da50e4 -r 8ad6734770cd ci/ci-pharo-benchmark.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ci/ci-pharo-benchmark.sh Mon Nov 09 00:38:23 2015 +0000 @@ -0,0 +1,26 @@ +#!/bin/bash +# +# a CI job to run PetitCompiler benchmarks on Pharo +# +set -e + +if test -x "ci-pharo-common.sh"; then + wget -O "ci-pharo-common.sh" https://bitbucket.org/janvrany/stx-goodies-petitparser/raw/tip/ci/ci-pharo-common.sh +fi +. ci-pharo-common.sh + +ci_download_test_data + +ci_pharo_download_pharo +ci_pharo_download_petitparser + +set +e +./pharo $IMAGE benchmark --tag PetitParser --setup "Author fullName:'Jenkins'" --json -o $PETITCOMPILER_BENCHMARK_REPORT PPCCalipelBenchmark; +status=$? +set -e + +ci_upload_benchmark_results + +exit $status + + diff -r 5536a6da50e4 -r 8ad6734770cd ci/ci-pharo-common.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ci/ci-pharo-common.sh Mon Nov 09 00:38:23 2015 +0000 @@ -0,0 +1,54 @@ +# +# A set of functions to be used in PetitParser's Pharo CI jobs +# + +if test -x "ci-common.sh"; then + echo wget -O "ci-common.sh" https://bitbucket.org/janvrany/stx-goodies-petitparser/raw/tip/ci/ci-common.sh +fi +. ci-common.sh + + +IMAGE_BASE=PetitParser-$BUILD_NUMBER +IMAGE=$IMAGE_BASE.image + +# A function to download Pharo. The version of Pharo +# is taken from environment variable PHARO. If it's not +# defined, defaults to Pharo 5.0 +function ci_pharo_download_pharo { + if [ -z "$PHARO" ]; then + PHARO=5.0 + fi + + if [ ! -x pharo-ui ]; then + rm -rf pharo pharo-ui pharo-vm + wget -O- http://swing.fit.cvut.cz/download/pharo/vm-swing | bash + fi + + if [ ! -r Pharo.image ]; then + rm -rf Pharo.image Pharo.changes + if [ "$PHARO" == "3.0" ]; then + wget -O- get.pharo.org/30 | bash + elif [ "$PHARO" == "4.0" ]; then + wget -O- get.pharo.org/40 | bash + elif [ "$PHARO" == "5.0" ]; then + wget -O- get.pharo.org/50 | bash + else + echo "Unknown PHARO version: $PHARO" + exit 1 + fi + fi +} + +# A function to download PetitCompiler and build an image + +function ci_pharo_download_petitparser { + ./pharo Pharo.image save $IMAGE_BASE + ./pharo $IMAGE config http://smalltalkhub.com/mc/JanVrany/CalipeL-S/main ConfigurationOfCalipeLS --install=0.1 + ./pharo $IMAGE eval --save " + + Gofer new smalltalkhubUser: 'JanKurs' project: 'PetitParser'; + configurationOf: #PetitCompiler; load. + (Smalltalk at: #ConfigurationOfPetitCompiler) perform: #'loadDevelopment'. + " +} + diff -r 5536a6da50e4 -r 8ad6734770cd ci/ci-pharo-test.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ci/ci-pharo-test.sh Mon Nov 09 00:38:23 2015 +0000 @@ -0,0 +1,29 @@ +#!/bin/bash +# +# a CI job to run PetitCompiler tests on Pharo +# +set -e + +if test -x "ci-pharo-common.sh"; then + echo wget -O "ci-pharo-common.sh" fail-here +fi +. ci-pharo-common.sh + +ci_download_test_data + +ci_pharo_download_pharo +ci_pharo_download_petitparser + +rm -rf Petit*Test.xml +# Must turn off errexit option, Pharo return non-zero +# status when one or more tests fail. +set +e +./pharo $IMAGE test --junit-xml-output \ + PetitTests \ + PetitAnalyzer \ + PetitSmalltalk \ + PetitJava \ + PetitIslands \ + PetitCompiler-Tests \ + PetitCompiler-Extras-Tests +set -e