From 6d91260d789f6c165a5630f8d22c0fdb17e4b70b Mon Sep 17 00:00:00 2001 From: "Karel.Picman" Date: Wed, 3 Nov 2021 12:53:25 +0100 Subject: [PATCH] #1309 Gitlab CI --- .gitlab-ci.yml | 72 ++++++++++++++++++++++ .travis.yml | 69 --------------------- Dockerfile | 25 ++++++++ README.md | 2 + test/ci/ci.sh | 122 +++++++++++++++++++++++++++++++++++++ test/ci/mariadb.yml | 23 ++++++- test/ci/postgres.yml | 23 ++++++- test/ci/redmine_install.sh | 115 ---------------------------------- test/ci/sqlite3.yml | 22 ++++++- 9 files changed, 284 insertions(+), 189 deletions(-) delete mode 100644 .travis.yml delete mode 100644 test/ci/redmine_install.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e69de29b..5c41402c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -0,0 +1,72 @@ +# Redmine plugin for Document Management System "Features" +# +# Copyright © 2011-21 Karel Pičman +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# The main file for GitLab Continous Integration + +image: docker:stable + +before_script: + - docker info + +stages: + - dmsf + +mariadb: + stage: dmsf + tags: + - docker + script: + # Create an image + - docker build -t dmsf_image -f Dockerfile . + # Run the container, optionally run some tests/apps in it + - docker rm -f dmsf_container 2>/dev/null || true + - docker run --name dmsf_container dmsf_image bash ./test/ci/ci.sh mariadb + # Remove the container + - docker rm dmsf_container + # Remove image + - docker rmi dmsf_image + +postgres: + stage: dmsf + tags: + - docker + script: + # Create an image + - docker build -t dmsf_image -f Dockerfile . + # Run the container, optionally run some tests/apps in it + - docker rm -f dmsf_container 2>/dev/null || true + - docker run --name dmsf_container dmsf_image bash ./test/ci/ci.sh postgres + # Remove the container + - docker rm dmsf_container + # Remove image + - docker rmi dmsf_image + +sqlite3: + stage: dmsf + tags: + - docker + script: + # Create an image + - docker build -t dmsf_image -f Dockerfile . + # Run the container, optionally run some tests/apps in it + - docker rm -f dmsf_container 2>/dev/null || true + - docker run --name dmsf_container dmsf_image bash ./test/ci/ci.sh sqlite3 + # Remove the container + - docker rm dmsf_container + # Remove image + - docker rmi dmsf_image diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 88eb8d64..00000000 --- a/.travis.yml +++ /dev/null @@ -1,69 +0,0 @@ -# encoding: utf-8 -# -# Redmine plugin for Document Management System "Features" -# -# Copyright © 2012 Daniel Munn -# Copyright © 2011-21 Karel Pičman -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -language: ruby - -sudo: true - -dist: bionic - -rvm: - - 2.6 - -before_install: - - sudo apt-get -y install litmus curl - -before_script: - - sudo mysql -e 'CREATE DATABASE IF NOT EXISTS test CHARACTER SET utf8mb4;' - - sudo mysql -e "CREATE USER 'dmsf'@'localhost' IDENTIFIED BY 'eGCq9ueVpUH3'"; - - sudo mysql -e "GRANT ALL PRIVILEGES ON test.* TO 'dmsf'@'localhost'"; - - psql -c 'create database test;' -U postgres - - export WORKSPACE=`pwd`/workspace - - export PATH_TO_DMSF=`pwd` - - export PATH_TO_REDMINE=$WORKSPACE/redmine - - export BUNDLE_GEMFILE=$PATH_TO_REDMINE/Gemfile - - mkdir -p ${WORKSPACE} - - cp -f ./test/ci/${DB}.yml ${WORKSPACE}/database.yml - - bash -x ./test/ci/redmine_install.sh -c - - bash -x ./test/ci/redmine_install.sh -i - -script: - - bash -x ./test/ci/redmine_install.sh -t - -after_script: - - bash -x ./test/ci/redmine_install.sh -u - -env: - global: - - DB=sqlite REDMINE_GIT_TAG=4.2-stable - - DB=mysql REDMINE_GIT_TAG=4.2-stable - - DB=postgres REDMINE_GIT_TAG=4.2-stable - -cache: bundler - -services: - - mysql - - postgresql - -addons: - mariadb: '10.4' - apt: - update: true diff --git a/Dockerfile b/Dockerfile index e69de29b..79df3f02 100644 --- a/Dockerfile +++ b/Dockerfile @@ -0,0 +1,25 @@ +# Redmine plugin for Document Management System "Features" +# +# Copyright © 2011-21 Karel Pičman +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# The Docker file definition for GitLab Continous Integration + +FROM debian:latest +RUN apt-get update +RUN apt-get -qq install mariadb-server postgresql sqlite3 libsqlite3-dev ruby ruby-dev build-essential libmariadb-dev libpq-dev subversion git litmus +COPY . /app +WORKDIR /app diff --git a/README.md b/README.md index 89a389d9..6b426179 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ Redmine DMSF Plugin The current version of Redmine DMSF is **2.4.11 devel** +[![pipeline status](https://gitlab.kontron.com/redmine-plugins/redmine_dmsf/badges/devel-2.4.11/pipeline.svg)](https://gitlab.kontron.com/redmine-plugins/redmine_dmsf/pipelines/devel-2.4.11/latest) + Redmine DMSF is Document Management System Features plugin for Redmine issue tracking system; It is aimed to replace current Redmine's Documents module. Redmine DMSF now comes bundled with Webdav functionality: if switched on within plugin settings this will be accessible from /dmsf/webdav. diff --git a/test/ci/ci.sh b/test/ci/ci.sh index e69de29b..2b27af7e 100644 --- a/test/ci/ci.sh +++ b/test/ci/ci.sh @@ -0,0 +1,122 @@ +#!/bin/bash +# Redmine plugin for Document Management System "Features" +# +# Copyright © 2011-21 Karel Pičman +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# The script for GitLab Continous Integration + +# Exit if any command fails +set -e + +# Display the first argument (DB engine) +echo $1 + +# Variables +REDMINE_REPO=http://svn.redmine.org/redmine/branches/4.2-stable/ +REDMINE_PATH=/opt/redmine + +# Init +rm -rf "${REDMINE_PATH}" + +# Clone Redmine +svn export "${REDMINE_REPO}" "${REDMINE_PATH}" + +# Add the plugin +ln -s /app "${REDMINE_PATH}"/plugins/redmine_dmsf + +# Prepare the database +cp "./test/ci/$1.yml" "${REDMINE_PATH}/config/database.yml" +case $1 in + + mariadb) + /etc/init.d/$1 start + mariadb -e "CREATE DATABASE IF NOT EXISTS test CHARACTER SET utf8mb4" + mariadb -e "CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'redmine'"; + mariadb -e "GRANT ALL PRIVILEGES ON test.* TO 'redmine'@'localhost'"; + ;; + + postgres) + /etc/init.d/$1ql start + su -c "psql -c \"CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD 'redmine' NOINHERIT VALID UNTIL 'infinity';\"" postgres + su -c "psql -c \"CREATE DATABASE test WITH ENCODING='UTF8' OWNER=redmine;\"" postgres + su -c "psql -c \"ALTER USER redmine CREATEDB;\"" postgres + ;; + + sqlite3) + ;; + + *) + echo 'Missing argument' + exit 1 + ;; +esac + +# Install Redmine +cd "${REDMINE_PATH}" +gem install bundler +RAILS_ENV=test bundle config set --local without 'rmagick xapian development' +RAILS_ENV=test bundle install +RAILS_ENV=test bundle exec rake generate_secret_token +RAILS_ENV=test bundle exec rake db:migrate +RAILS_ENV=test bundle exec rake redmine:plugins:migrate +RAILS_ENV=test REDMINE_LANG=en bundle exec rake redmine:load_default_data + +# Run Redmine tests +#RAILS_ENV=test bundle exec rake test + +# Run DMSF tests +bundle exec rake redmine:plugins:test:units NAME=redmine_dmsf RAILS_ENV=test +bundle exec rake redmine:plugins:test:functionals NAME=redmine_dmsf RAILS_ENV=test +bundle exec rake redmine:plugins:test:integration NAME=redmine_dmsf RAILS_ENV=test + +# Litmus + +# Prepare Redmine's environment for WebDAV testing +RAILS_ENV=test bundle exec rake redmine:dmsf_webdav_test_on + +# Run Webrick server +bundle exec rails server webrick -e test -d + +# Run Litmus tests (Omit 'http' tests due to 'timeout waiting for interim response') +TESTS="basic copymove props locks" litmus http://localhost:3000/dmsf/webdav/dmsf_test_project admin admin + +# Shutdown Webrick +kill `cat tmp/pids/server.pid` + +# Clean up Redmine's environment from WebDAV testing +RAILS_ENV=test bundle exec rake redmine:dmsf_webdav_test_off + +case $1 in + + mariadb) + /etc/init.d/$1 stop + ;; + + postgres) + /etc/init.d/$1ql stop + ;; + + sqlite3) + ;; + + *) + echo 'Missing argument' + exit 1 + ;; +esac + +echo "$1 Okay" diff --git a/test/ci/mariadb.yml b/test/ci/mariadb.yml index dad1f7b7..c1f82d89 100644 --- a/test/ci/mariadb.yml +++ b/test/ci/mariadb.yml @@ -1,8 +1,27 @@ +# Redmine plugin for Document Management System "Features" +# +# Copyright © 2011-21 Karel Pičman +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# MariDb file definition for GitLab Continous Integration test: adapter: mysql2 database: test - username: dmsf - password: "eGCq9ueVpUH3" + username: redmine + password: "redmine" encoding: utf8mb4 collation: utf8mb4_unicode_ci \ No newline at end of file diff --git a/test/ci/postgres.yml b/test/ci/postgres.yml index 0269c6e1..b8988c32 100644 --- a/test/ci/postgres.yml +++ b/test/ci/postgres.yml @@ -1,5 +1,26 @@ +# Redmine plugin for Document Management System "Features" +# +# Copyright © 2011-21 Karel Pičman +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# PosgreSQL file definition for GitLab Continous Integration test: adapter: postgresql database: test - encoding: utf8 \ No newline at end of file + username: redmine + password: redmine + host: localhost \ No newline at end of file diff --git a/test/ci/redmine_install.sh b/test/ci/redmine_install.sh deleted file mode 100644 index 31ded2f3..00000000 --- a/test/ci/redmine_install.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/bin/bash -# encoding: utf-8 -# -# Redmine plugin for Document Management System "Features" -# -# Copyright © 2012 Daniel Munn -# Copyright © 2011-21 Karel Pičman -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -if [[ ! -v REDMINE_GIT_REPO ]]; then - export REDMINE_GIT_REPO=git://github.com/redmine/redmine.git -fi -if [[ ! -v REDMINE_GIT_TAG ]]; then - export REDMINE_GIT_TAG=4.1-stable -fi - -clone() -{ - # Exit if the cloning fails - set -e - - rm -rf ${PATH_TO_REDMINE} - git clone -b ${REDMINE_GIT_TAG} --depth=100 --quiet ${REDMINE_GIT_REPO} ${PATH_TO_REDMINE} -} - -test() -{ - # Exit if a test fails - set -e - - cd ${PATH_TO_REDMINE} - - # Run tests within application - bundle exec rake redmine:plugins:test:units NAME=redmine_dmsf RAILS_ENV=test - bundle exec rake redmine:plugins:test:functionals NAME=redmine_dmsf RAILS_ENV=test - bundle exec rake redmine:plugins:test:integration NAME=redmine_dmsf RAILS_ENV=test - - # Litmus - # Prepare Redmine's environment for WebDAV testing - bundle exec rake redmine:dmsf_webdav_test_on RAILS_ENV=test - # Run Webrick server - bundle exec rails server webrick -e test -d - # Run Litmus tests - litmus http://localhost:3000/dmsf/webdav/dmsf_test_project admin admin - # Shutdown Webrick - kill `cat tmp/pids/server.pid` - # Clean up Redmine's environment from WebDAV testing - bundle exec rake redmine:dmsf_webdav_test_off RAILS_ENV=test -} - -uninstall() -{ - # Exit if the migration fails - set -e - - cd ${PATH_TO_REDMINE} - - # clean up database - bundle exec rake redmine:plugins:migrate NAME=redmine_dmsf VERSION=0 RAILS_ENV=test -} - -install() -{ - # Exit if the installation fails - set -e - - # cd to redmine folder - cd ${PATH_TO_REDMINE} - echo current directory is `pwd` - - # Create a link to the dmsf plugin - ln -sf ${PATH_TO_DMSF} plugins/redmine_dmsf - - # Copy database.yml - cp ${WORKSPACE}/database.yml config/ - - # Install gems - # Not ideal, but at present Travis-CI will not install with xapian enabled: - bundle install --without xapian rmagick development RAILS_ENV=test - - # Run Redmine database migrations - bundle exec rake db:migrate --trace RAILS_ENV=test - - # Load Redmine database default data - bundle exec rake redmine:load_default_data REDMINE_LANG=en RAILS_ENV=test - - # generate session store/secret token - bundle exec rake generate_secret_token RAILS_ENV=test - - # Run the plugin database migrations - bundle exec rake redmine:plugins:migrate RAILS_ENV=test -} - -while getopts :ictu opt -do case "$opt" in - c) clone; exit 0;; - i) install; exit 0;; - t) test; exit 0;; - u) uninstall; exit 0;; - [?]) echo "i: install; c: clone redmine; t: run tests; u: uninstall";; - esac -done \ No newline at end of file diff --git a/test/ci/sqlite3.yml b/test/ci/sqlite3.yml index f9e3c7cf..dba45f2c 100644 --- a/test/ci/sqlite3.yml +++ b/test/ci/sqlite3.yml @@ -1,5 +1,23 @@ +# Redmine plugin for Document Management System "Features" +# +# Copyright © 2011-21 Karel Pičman +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# SQLite file definition for GitLab Continous Integration test: adapter: sqlite3 - database: db/test.sqlite3 - timeout: 500 \ No newline at end of file + database: db/redmine.sqlite3 \ No newline at end of file