Skip to content
Snippets Groups Projects
.gitlab-ci.yml 18.9 KiB
Newer Older
Piotr Gawron's avatar
Piotr Gawron committed
image: node

  - packaging
Piotr Gawron's avatar
Piotr Gawron committed

variables:
  POSTGRES_DB: map_viewer
  POSTGRES_USER: map_viewer
  POSTGRES_PASSWORD: "123qweasdzxc"

Piotr Gawron's avatar
Piotr Gawron committed
test:frontend:
  coverage: '/Statements[:\ ]+(\d+.\d+)\%/'
Piotr Gawron's avatar
Piotr Gawron committed
  script:
    - cd frontend-js
    - npm install  
Piotr Gawron's avatar
Piotr Gawron committed
    - npm test
Piotr Gawron's avatar
Piotr Gawron committed
.jdk_8_template: &jdk_8_definition
  image: maven:3.6.0-jdk-8
Piotr Gawron's avatar
Piotr Gawron committed
  services:
    - postgres:9.6
  stage: test
  coverage: '/(\d+.\d+) \% covered/'
Piotr Gawron's avatar
Piotr Gawron committed

.jdk_11_template: &jdk_11_definition
  image: maven:3.6.0-jdk-11
  services:
    - postgres:9.6
  stage: test
  coverage: '/(\d+.\d+) \% covered/'

.test_backend_commons_template:
Piotr Gawron's avatar
Piotr Gawron committed
  script: &test_backend_commons_definition
#xvfb is for X11 connection used by some parts of the java code: https://stackoverflow.com/a/47575851/1127920
Piotr Gawron's avatar
Piotr Gawron committed
    - apt-get update
    - DEBIAN_FRONTEND=noninteractive apt-get install -y xvfb

    - mvn -DskipTests=true clean install -pl commons -am
    - mvn test -pl commons
Piotr Gawron's avatar
Piotr Gawron committed
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' commons/target/site/jacoco/jacoco.csv
Piotr Gawron's avatar
Piotr Gawron committed
.test_backend_annotation_template:
  script: &test_backend_annotation_definition
    - cp test-db-ci.properties /etc/minerva/db.properties

    - mvn -DskipTests=true clean install -pl annotation -am
    - mvn test -pl annotation
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' annotation/target/site/jacoco/jacoco.csv
Piotr Gawron's avatar
Piotr Gawron committed

.test_backend_CellDesigner-plugin_template:
  script: &test_backend_CellDesigner_plugin_definition
Piotr Gawron's avatar
Piotr Gawron committed
#xvfb is for X11 connection used by some parts of the java code: https://stackoverflow.com/a/47575851/1127920
    - apt-get update
    - apt-get install -y xvfb
    - Xvfb :99 &
    - export DISPLAY=:99

    - mvn -DskipTests=true clean install -pl CellDesigner-plugin -am
    - mvn test -pl CellDesigner-plugin
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' CellDesigner-plugin/target/site/jacoco/jacoco.csv
Piotr Gawron's avatar
Piotr Gawron committed
.test_backend_converter_template:
  script: &test_backend_converter_definition
    - mvn -DskipTests=true clean install -pl converter -am
    - mvn test -pl converter
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' converter/target/site/jacoco/jacoco.csv
Piotr Gawron's avatar
Piotr Gawron committed
.test_backend_converter_graphics_template:
  script: &test_backend_converter_graphics_definition
    - mvn -DskipTests=true clean install -pl converter-graphics -am
    - mvn test -pl converter-graphics
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' converter-graphics/target/site/jacoco/jacoco.csv
Piotr Gawron's avatar
Piotr Gawron committed
.test_backend_converter_CellDesigner_template:
  script: &test_backend_converter_CellDesigner_definition
    - mvn -DskipTests=true clean install -pl converter-CellDesigner -am
Piotr Gawron's avatar
Piotr Gawron committed
    - mvn test -pl converter-CellDesigner
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' converter-CellDesigner/target/site/jacoco/jacoco.csv
Piotr Gawron's avatar
Piotr Gawron committed
.test_backend_converter_SBGNML_template:
  script: &test_backend_converter_SBGNML_definition
    - mkdir /etc/minerva/
    - cp test-db-ci.properties /etc/minerva/db.properties
    - mvn -DskipTests=true clean install -pl converter-SBGNML -am
    - mvn test -pl converter-SBGNML
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' converter-SBGNML/target/site/jacoco/jacoco.csv
Piotr Gawron's avatar
Piotr Gawron committed
.test_backend_converter_SBML_template:
  script: &test_backend_converter_SBML_definition
    - mvn -DskipTests=true clean install -pl converter-sbml -am
    - mvn test -pl converter-sbml
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' converter-sbml/target/site/jacoco/jacoco.csv
Piotr Gawron's avatar
Piotr Gawron committed
.test_backend_model_template:
  script: &test_backend_model_definition
    - mvn -DskipTests=true clean install -pl model -am
    - mvn test -pl model
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' model/target/site/jacoco/jacoco.csv
Piotr Gawron's avatar
Piotr Gawron committed
.test_backend_model_command_template:
  script: &test_backend_model_command_definition
    - mvn -DskipTests=true clean install -pl model-command -am
    - mvn test -pl model-command
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' model-command/target/site/jacoco/jacoco.csv
Piotr Gawron's avatar
Piotr Gawron committed
.test_backend_pathvisio_template:
  script: &test_backend_pathvisio_definition
    - mvn -DskipTests=true clean install -pl pathvisio -am
    - mvn test -pl pathvisio
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' pathvisio/target/site/jacoco/jacoco.csv
Piotr Gawron's avatar
Piotr Gawron committed
.test_backend_persist_template:
  script: &test_backend_persist_definition
Piotr Gawron's avatar
Piotr Gawron committed
    - mkdir /etc/minerva/
    - cp test-db-ci.properties /etc/minerva/db.properties
    - mvn -DskipTests=true clean install -pl persist -am
    - mvn test -pl persist
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' persist/target/site/jacoco/jacoco.csv
Piotr Gawron's avatar
Piotr Gawron committed
.test_backend_rest_template:
  script: &test_backend_rest_definition
    - mkdir /etc/minerva/
    - cp test-db-ci.properties /etc/minerva/db.properties
    - mvn -DskipTests=true clean install -pl rest-api -am
    - mvn test -pl rest-api
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' rest-api/target/site/jacoco/jacoco.csv
Piotr Gawron's avatar
Piotr Gawron committed
.test_backend_web_template:
  script: &test_backend_web_definition
    - apt-get update
    - DEBIAN_FRONTEND=noninteractive apt-get install -y curl gnupg git ant
    - curl -sL https://deb.nodesource.com/setup_9.x | bash -
    - DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs
    - mkdir /etc/minerva/
    - cp test-db-ci.properties /etc/minerva/db.properties
    - mvn -DskipTests=true clean install -pl web -am
    - mvn test -pl web
Piotr Gawron's avatar
Piotr Gawron committed
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' web/target/site/jacoco/jacoco.csv
Piotr Gawron's avatar
Piotr Gawron committed
.test_backend_service_template:
  script: &test_backend_service_definition
    - mkdir /etc/minerva/
    - cp test-db-ci.properties /etc/minerva/db.properties
    - mvn -DskipTests=true clean install -pl service -am
    - mvn test -pl service
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions,"% covered" }' service/target/site/jacoco/jacoco.csv
Piotr Gawron's avatar
Piotr Gawron committed

test:backend:commons:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_commons_definition

test:backend:commons:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_commons_definition

test:backend:annotation:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_annotation_definition

test:backend:annotation:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_annotation_definition

test:backend:CellDesigner_plugin:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_CellDesigner_plugin_definition

#CellDesigner is working on java 8 and is incompatible with java 11
#test:backend:CellDesigner_plugin:jdk-11:
#  <<: *jdk_11_definition
#  script: *test_backend_CellDesigner_plugin_definition
Piotr Gawron's avatar
Piotr Gawron committed

test:backend:converter:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_converter_definition

test:backend:converter:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_converter_definition

test:backend:converter_graphics:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_converter_graphics_definition

test:backend:converter_graphics:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_converter_graphics_definition

test:backend:converter_SBGNML:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_converter_SBGNML_definition

test:backend:converter_SBGNML:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_converter_SBGNML_definition

test:backend:converter_SBML:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_converter_SBML_definition

test:backend:converter_SBML:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_converter_SBML_definition

test:backend:model:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_model_definition

test:backend:model:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_model_definition

test:backend:model_command:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_model_command_definition

test:backend:model_command:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_model_command_definition

test:backend:pathvisio:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_pathvisio_definition

test:backend:pathvisio:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_pathvisio_definition

test:backend:persist:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_persist_definition

test:backend:persist:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_persist_definition

test:backend:rest:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_rest_definition

test:backend:rest:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_rest_definition

test:backend:service:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_service_definition

test:backend:service:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_service_definition

test:backend:web:jdk-8:
  <<: *jdk_8_definition
  script: *test_backend_web_definition

test:backend:web:jdk-11:
  <<: *jdk_11_definition
  script: *test_backend_web_definition

  image: maven:3.6.0-jdk-8
Piotr Gawron's avatar
Piotr Gawron committed
  tags:
     - privileged
Piotr Gawron's avatar
Piotr Gawron committed
    expire_in: 1 day
    paths:
      - minerva.war
  script:
    - DEBIAN_FRONTEND=noninteractive apt-get install -y curl gnupg git ant
    - curl -sL https://deb.nodesource.com/setup_9.x | bash -
    - DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs
    - ant maven-build
    - cp web/target/web-1.0.war minerva.war

Piotr Gawron's avatar
Piotr Gawron committed
test:dependency_conflict:
  image: maven:3.6.0-jdk-8
    - DEBIAN_FRONTEND=noninteractive apt-get install -y curl gnupg git ant
    - curl -sL https://deb.nodesource.com/setup_9.x | bash -
    - DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs

    - mvn clean install -DskipTests=true
    - set +e
    - mvn dependency:tree -Dverbose | grep conflict | cat > conflicts.txt
    - set -e
    - conflicts=`cat conflicts.txt| wc -l`
    - echo Found conflicts $conflicts ':'
    - cat conflicts.txt
    - test 0 = $conflicts

build_debian_package:
  image: debian
  stage: packaging
  tags:
     - privileged
  dependencies:
    - build_war
  artifacts:
    paths:
      - "debian/*.deb"
  script:
    - mkdir web/target/
Piotr Gawron's avatar
Piotr Gawron committed
    - mv minerva.war web/target/web-1.0.war
    - DEBIAN_FRONTEND=noninteractive apt-get install -y dh-make build-essential lintian devscripts xsltproc fakeroot xsltproc docbook-xsl
    - export DEBFULLNAME="Piotr Gawron"
    - export DEBEMAIL="piotr.gawron@uni.lu"
    - debian/create-debian-pkg.sh
test_upgrade_debian_package:
  image: debian:stretch
  stage: test
  only:
    - tags
# we need to run it in privileged mode due to: https://stackoverflow.com/questions/29683231/tomcat7-fail-to-start-inside-ubuntu-docker-container
  tags:
     - privileged
  services:
     - name: piotrgawron/debian-repo
       alias: debian-repo
  dependencies:
     - build_debian_package
  script:
     - apt-get update
     - DEBIAN_FRONTEND=noninteractive apt-get install -y ssh software-properties-common dirmngr wget curl apt-transport-https postgresql
     - service postgresql start
     - debian_file=$(ls debian/*.deb)
     - version=$(echo $debian_file| cut -f2 -d"_")
     - echo "PUT $debian_file /docker/incoming" | sftp -o StrictHostKeyChecking=no user@debian-repo
     - ssh root@debian-repo /usr/local/sbin/reprepro-import
     - apt-add-repository "deb http://repo-r3lab.uni.lu/debian/ stable main"
Piotr Gawron's avatar
Piotr Gawron committed
     - apt-key adv --no-tty --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xcb185f4e31872412
     - echo debconf minerva/internal/skip-preseed boolean true | debconf-set-selections
     - echo debconf minerva/dbconfig-install select true | debconf-set-selections
     - echo debconf minerva/pgsql/app-pass select secret_password | debconf-set-selections
     - echo debconf minerva/remote/host select localhost | debconf-set-selections
     - echo debconf minerva/db/dbname select minerva_db | debconf-set-selections
     - echo debconf minerva/db/app-user select minerva_user@localhost | debconf-set-selections
     - apt-get update
#hacky way of installing minerva on docker - by default rc-invoke is preventing services changes on docker
     - mv /usr/sbin/policy-rc.d /usr/sbin/policy-rc.d.backup
     - mv gitlab-ci-policy-rc.d /usr/sbin/policy-rc.d
     - chmod 0755 /usr/sbin/policy-rc.d
     - DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated minerva

#local repository with new version
     - apt-add-repository "deb http://debian-repo/ unstable main"
     - apt-get update --allow-unauthenticated
     - apt-get dist-upgrade -y --allow-unauthenticated
Piotr Gawron's avatar
Piotr Gawron committed
     - mv /usr/sbin/policy-rc.d.backup /usr/sbin/policy-rc.d
     - service tomcat8 start
#we need to wait a bit for tomcat start
     - sleep 15
     - wget http://localhost:8080/minerva/

#test if we can login and get configuration using new version
     - test 200 = $(curl --write-out %{http_code} --silent --output /dev/null -c cookie.txt http://localhost:8080/minerva/api/doLogin)
     - test 200 = $(curl --write-out %{http_code} --silent --output configuration.json --cookie cookie.txt http://localhost:8080/minerva/api/configuration/)
     - test 1 = $(cat configuration.json| grep $version | wc -l)

  image: debian:stretch
Piotr Gawron's avatar
Piotr Gawron committed
# we need to run it in privileged mode due to: https://stackoverflow.com/questions/29683231/tomcat7-fail-to-start-inside-ubuntu-docker-container
  tags:
     - privileged
  services:
     - name: piotrgawron/debian-repo
       alias: debian-repo
  dependencies:
     - build_debian_package
     - DEBIAN_FRONTEND=noninteractive apt-get install -y ssh software-properties-common dirmngr wget curl postgresql
     - service postgresql start
     - debian_file=$(ls debian/*.deb)
Piotr Gawron's avatar
Piotr Gawron committed
     - echo "PUT $debian_file /docker/incoming" | sftp -o StrictHostKeyChecking=no user@debian-repo
     - ssh root@debian-repo /usr/local/sbin/reprepro-import
     - apt-add-repository "deb http://debian-repo/ unstable main"
     - echo debconf minerva/internal/skip-preseed boolean true | debconf-set-selections
     - echo debconf minerva/dbconfig-install select true | debconf-set-selections
     - echo debconf minerva/pgsql/app-pass select secret_password | debconf-set-selections
     - echo debconf minerva/remote/host select localhost | debconf-set-selections
     - echo debconf minerva/db/dbname select minerva_db | debconf-set-selections
     - echo debconf minerva/db/app-user select minerva_user@localhost | debconf-set-selections
Piotr Gawron's avatar
Piotr Gawron committed
#hacky way of installing minerva on docker - by default rc-invoke is preventing services changes on docker
     - mv /usr/sbin/policy-rc.d /usr/sbin/policy-rc.d.backup
     - mv gitlab-ci-policy-rc.d /usr/sbin/policy-rc.d
     - chmod 0755 /usr/sbin/policy-rc.d
     - DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated minerva
     - mv /usr/sbin/policy-rc.d.backup /usr/sbin/policy-rc.d 
     - service tomcat8 start
Piotr Gawron's avatar
Piotr Gawron committed
#we need to wait a bit for tomcat start
     - sleep 15
     - wget http://localhost:8080/minerva/
Piotr Gawron's avatar
Piotr Gawron committed
#test if we can login and list projects
     - test 200 = $(curl --write-out %{http_code} --silent --output /dev/null -c cookie.txt http://localhost:8080/minerva/api/doLogin)
     - test 200 = $(curl --write-out %{http_code} --silent --output /dev/null --cookie cookie.txt http://localhost:8080/minerva/api/projects/)

Piotr Gawron's avatar
Piotr Gawron committed
build_rpm:
  image: centos:7
  stage: packaging
Piotr Gawron's avatar
Piotr Gawron committed
  dependencies:
    - build_war
Piotr Gawron's avatar
Piotr Gawron committed
  tags:
     - privileged
  artifacts:
    paths:
      - "rpm/rpmbuildtemp/RPMS/noarch/minerva-*.rpm"
  script:
    - yum -y install rpmdevtools unzip
    - rpm/buildrpm.sh minerva.war
Piotr Gawron's avatar
Piotr Gawron committed
rpmlint:
  image: centos:7
  stage: test
  dependencies:
    - build_rpm
  tags:
     - privileged
Piotr Gawron's avatar
Piotr Gawron committed
  script:
    - yum -y install rpmlint
    - rpmlint rpm/rpmbuildtemp/RPMS/noarch/minerva-*.rpm
test_deploy_with_db_without_superadmin_rights:
  image: tomcat:7-jre8
  stage: test
  services:
    - postgres:9.6
  dependencies:
    - build_war
  tags:
    - privileged
  only:
    - tags
  script:
    - apt-get update
    - DEBIAN_FRONTEND=noninteractive apt-get install -y postgresql-client
    - mkdir /etc/minerva
    - echo "database.uri=jdbc:postgresql://postgres:5432/test" > /etc/minerva/db.properties
    - echo "database.username=test" >> /etc/minerva/db.properties
    - echo "database.password=test" >> /etc/minerva/db.properties
    - echo "CREATE DATABASE test;CREATE USER test WITH ENCRYPTED PASSWORD 'test';GRANT ALL PRIVILEGES ON DATABASE test TO test;" >tmp.sql
    - PGPASSWORD=$POSTGRES_PASSWORD psql -h postgres -U $POSTGRES_USER $POSTGRES_DB < tmp.sql
    - mv minerva.war /usr/local/tomcat/webapps/minerva.war
    - /usr/local/tomcat/bin/startup.sh
    - sleep 15
    - wget http://localhost:8080/minerva/
#test if we can login and list projects
    - test 200 = $(curl --write-out %{http_code} --silent --output /dev/null -c cookie.txt http://localhost:8080/minerva/api/doLogin)
    - test 200 = $(curl --write-out %{http_code} --silent --output /dev/null --cookie cookie.txt http://localhost:8080/minerva/api/projects/)


.test_database_template: &test_database_definition
  image: maven:3.6.0-jdk-8
  stage: test
  script:
    - mkdir /etc/minerva/
    - cp test-db-ci.properties /etc/minerva/db.properties
    - mvn -DskipTests=true clean install -pl persist -am
    - mvn test -pl persist

test_postgres_9_3_compatibility:
  <<: *test_database_definition
  services:
    - postgres:9.3

test_postgres_10_compatibility:
  services:
    - postgres:10

test_postgres_11_compatibility: