From d8e212166f7a090cc1790526dd7546595828903b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Thu, 15 Sep 2022 16:57:14 +0200 Subject: [PATCH] GitHub Actions --- .github/workflows/rubyonrails.yml | 172 ++++++++++++++++++++++++++++++ README.md | 2 +- test/ci/mariadb.yml | 27 ----- test/ci/postgres.yml | 26 ----- test/ci/sqlite3.yml | 23 ---- 5 files changed, 173 insertions(+), 77 deletions(-) create mode 100644 .github/workflows/rubyonrails.yml delete mode 100644 test/ci/mariadb.yml delete mode 100644 test/ci/postgres.yml delete mode 100644 test/ci/sqlite3.yml diff --git a/.github/workflows/rubyonrails.yml b/.github/workflows/rubyonrails.yml new file mode 100644 index 00000000..d0a22867 --- /dev/null +++ b/.github/workflows/rubyonrails.yml @@ -0,0 +1,172 @@ +# Redmine plugin for Document Management System "Features" +# +# Copyright © 2011-22 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. +# +# GitHub CI script + +name: "GitHub CI" +on: + push: + branches: ["action"] + pull_request: + branches: ["action"] +jobs: + plugin_tests: + strategy: + matrix: + engine: [mysql, postgresql, sqlite] + include: + - engine: mysql + # Database configuration for Redmine + database_configuration: > + test: + adapter: mysql2 + database: test + username: redmine + password: redmine + encoding: utf8mb4 + collation: utf8mb4_unicode_ci + # SQL commands to create a database for Redmine + sql1: CREATE DATABASE IF NOT EXISTS test CHARACTER SET utf8mb4; + sql2: CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'redmine'; + sql3: GRANT ALL PRIVILEGES ON test.* TO 'redmine'@'localhost'; + # SQL client command + database_command: mysql -uroot -proot -e + # SQl service + database_service: mysql + - engine: postgresql + # Database configuration for Redmine + database_configuration: > + test: + adapter: postgresql + database: test + username: redmine + password: redmine + host: localhost + # SQL commands to create a database for Redmine + sql1: CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD 'redmine' NOINHERIT VALID UNTIL 'infinity'; + sql2: CREATE DATABASE test WITH ENCODING='UTF8' OWNER=redmine; + sql3: ALTER USER redmine CREATEDB; + # SQL client command + database_command: sudo -u postgres psql -c + # SQL service + database_service: postgresql + - engine: sqlite + # Database configuration for Redmine + database_configuration: > + test: + adapter: sqlite3 + database: db/redmine.sqlite3 + # No database needed here. It's just a file. + runs-on: ubuntu-latest + env: + RAILS_ENV: test + NAME: redmine_dmsf + steps: + - name: Install dependencies + # Install necessary packages + run: | + sudo apt update + sudo apt install -y litmus libreoffice + - name: Clone Redmine + # Get the latest stable Redmine + run: svn export http://svn.redmine.org/redmine/branches/5.0-stable/ /opt/redmine + - name: Checkout code + uses: actions/checkout@v3 + - name: Link the plugin + # Link the plugin to the redmine folder + run: | + ln -s $(pwd) /opt/redmine/plugins/redmine_dmsf + - name: Install Ruby and gems + uses: ruby/setup-ruby@0a29871fe2b0200a17a4497bae54fe5df0d973aa # v1.115.3 + with: + bundler-cache: true + ruby-version: '3.0' + - name: Setup database + # Create the database + run: | + echo "${{matrix.database_configuration}}" > /opt/redmine/config/database.yml + if [[ "${{matrix.database_service}}" ]]; then + sudo systemctl start ${{matrix.engine}} + fi + if [[ "${{matrix.database_command}}" ]]; then + ${{matrix.database_command}} "${{matrix.sql1}}" + ${{matrix.database_command}} "${{matrix.sql2}}" + ${{matrix.database_command}} "${{matrix.sql3}}" + fi + - name: Install Redmine + # Install Redmine + run: | + cd /opt/redmine + echo "gem \"webrick\"" > Gemfile.local + bundle config set --local without 'rmagick development xapian' + bundle install + bundle exec rake generate_secret_token + bundle exec rake db:migrate + bundle exec rake redmine:plugins:migrate + bundle exec rake redmine:load_default_data + env: + REDMINE_LANG: en + - name: Configure WebDAV + # Add configuration for WebDAV to work + run: | + cp /opt/redmine/config/additional_environment.rb.example /opt/redmine/config/additional_environment.rb + echo "config.log_level = :info" >> /opt/redmine/config/additional_environment.rb + echo "# Redmine DMSF's WebDAV" >> /opt/redmine/config/additional_environment.rb + echo "require File.dirname(__FILE__) + '/plugins/redmine_dmsf/lib/redmine_dmsf/webdav/custom_middleware'" >> /opt/redmine/config/additional_environment.rb + echo "config.middleware.insert_before ActionDispatch::Cookies, RedmineDmsf::Webdav::CustomMiddleware" >> /opt/redmine/config/additional_environment.rb + - name: Standard tests + # Run the tests + run: | + cd /opt/redmine + bundle exec rake redmine:plugins:test:units + bundle exec rake redmine:plugins:test:functionals + bundle exec rake redmine:plugins:test:integration + - name: Libraries tests + run: | + cd /opt/redmine + ruby plugins/redmine_dmsf/test/unit/lib/redmine_dmsf/dmsf_macros_test.rb + ruby plugins/redmine_dmsf/test/unit/lib/redmine_dmsf/dmsf_plugin_test.rb + - name: Helpers tests + run: | + cd /opt/redmine + ruby plugins/redmine_dmsf/test/helpers/dmsf_helper_test.rb + ruby plugins/redmine_dmsf/test/helpers/dmsf_queries_helper_test.rb + - name: Litmus + # Prepare Redmine's environment for WebDAV testing + # Run Webrick server + # Run Litmus tests (Omit 'http' tests due to 'timeout waiting for interim response' and locks due to complex bogus conditional) + # Shutdown Webrick + # Clean up Redmine's environment from WebDAV testing + run: | + cd /opt/redmine + bundle exec rake redmine:dmsf_webdav_test_on + bundle exec rails server -u webrick -e test -d + litmus http://localhost:3000/dmsf/webdav/dmsf_test_project admin admin + kill `cat tmp/pids/server.pid` + bundle exec rake redmine:dmsf_webdav_test_off + env: + TESTS: "basic copymove props" + - name: Cleanup + # Rollback plugin's changes to the database + # Stop the database engine + run: | + cd /opt/redmine + bundle exec rake redmine:plugins:migrate VERSION=0 + if [[ "${{matrix.database_service}}" ]]; then + sudo systemctl stop ${{matrix.engine}} + fi diff --git a/README.md b/README.md index f5f7e18f..0ee8a953 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Redmine DMSF Plugin The current version of Redmine DMSF is **3.0.6 devel** -[![pipeline status](https://gitlab.kontron.com/redmine-plugins/redmine_dmsf/badges/devel/pipeline.svg)](https://gitlab.kontron.com/redmine-plugins/redmine_dmsf/pipelines/devel/latest) +![GitHub Action](https://github.com/danmunn/redmine_dmsf/actions/workflows/rubyonrails.yml/badge.svg?branch=devel) [![Support Ukraine Badge](https://bit.ly/support-ukraine-now)](https://github.com/support-ukraine/support-ukraine) Redmine DMSF is Document Management System Features plugin for Redmine issue tracking system; It is aimed to replace current Redmine's Documents module. diff --git a/test/ci/mariadb.yml b/test/ci/mariadb.yml deleted file mode 100644 index 3d7445d4..00000000 --- a/test/ci/mariadb.yml +++ /dev/null @@ -1,27 +0,0 @@ -# Redmine plugin for Document Management System "Features" -# -# Copyright © 2011-22 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 Continuous Integration - -test: - adapter: mysql2 - database: test - 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 deleted file mode 100644 index 8eaf47f3..00000000 --- a/test/ci/postgres.yml +++ /dev/null @@ -1,26 +0,0 @@ -# Redmine plugin for Document Management System "Features" -# -# Copyright © 2011-22 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 Continuous Integration - -test: - adapter: postgresql - database: test - username: redmine - password: redmine - host: localhost \ No newline at end of file diff --git a/test/ci/sqlite3.yml b/test/ci/sqlite3.yml deleted file mode 100644 index 7eb1fd73..00000000 --- a/test/ci/sqlite3.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Redmine plugin for Document Management System "Features" -# -# Copyright © 2011-22 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 Continuous Integration - -test: - adapter: sqlite3 - database: db/redmine.sqlite3 \ No newline at end of file