diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e830e0bf..3b4dfd3d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,30 +1,129 @@ -name: Run Tests +name: Tests on: push: pull_request: - schedule: - - cron: '0 5 * * *' jobs: test: + name: ${{ matrix.redmine }} ${{ matrix.db }} ruby-${{ matrix.ruby }} runs-on: ubuntu-latest strategy: matrix: - redmine: - - v4.1 - - trunk - ruby: - - v2.4 - - v2.6 - database: - - sqlite3 - - postgres + ruby: ['2.6', '2.4'] + redmine: ['4.1-stable', 'master'] + db: ['postgres', 'mysql'] + fail-fast: false + + services: + postgres: + image: postgres:13 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + ports: + - 5432:5432 + + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + mysql: + image: mysql:5.7 + env: + MYSQL_USER: root + MYSQL_PASSWORD: '' + MYSQL_ALLOW_EMPTY_PASSWORD: yes + ports: + - 3306:3306 + options: >- + --health-cmd="mysqladmin ping" + --health-interval=10s + --health-timeout=5s + --health-retries=3 steps: - - name: Redmine plugin test - uses: two-pack/redmine-plugin-test-action@v2 + - name: Verify MySQL connection from host + run: | + mysql --host 127.0.0.1 --port 3306 -uroot -e "SHOW DATABASES" + if: matrix.db == 'mysql' + + - name: Checkout Redmine + uses: actions/checkout@v2 with: - plugin_name: additionals - redmine_version: ${{ matrix.redmine }} - ruby_version: ${{ matrix.ruby }} + repository: redmine/redmine + ref: ${{ matrix.redmine }} + path: redmine + + - name: Checkout additionals + uses: actions/checkout@v2 + with: + repository: AlphaNodes/additionals + path: redmine/plugins/additionals + + - name: Update package archives + run: sudo apt-get update --yes --quiet + + - name: Install package dependencies + run: > + sudo apt-get install --yes --quiet + build-essential + cmake + libicu-dev + libpq-dev + libmysqlclient-dev + + - name: Setup Ruby + uses: actions/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + architecture: 'x64' + + - name: Setup Cache + uses: actions/cache@v1 + with: + path: vendor + key: v1-ruby-${{ matrix.ruby }}-redmine-${{ matrix.redmine }} + + - name: Setup Bundler + run: | + gem install bundler -v '~> 1.0' + bundle config path "$(pwd)/vendor/bundle" + + - name: Prepare Redmine source + working-directory: redmine + run: | + sed -i '/rubocop/d' Gemfile + rm -f .rubocop* + cp plugins/additionals/test/support/database-${{ matrix.db }}.yml config/database.yml + cp plugins/additionals/test/support/configuration.yml config/configuration.yml + + - name: Install Ruby dependencies + working-directory: redmine + run: | + bundle install --jobs=4 --retry=3 --without development + + - name: Run Redmine rake tasks + env: + RAILS_ENV: test + working-directory: redmine + run: | + bundle exec rake generate_secret_token + bundle exec rake db:create db:migrate redmine:plugins:migrate + bundle exec rake db:test:prepare + + - name: Run tests + env: + RAILS_ENV: test + REDMINE_VERSION: ${{ matrix.redmine }} + working-directory: redmine + run: bundle exec rake redmine:plugins:test NAME=additionals RUBYOPT="-W0" + + - name: Run uninstall test + env: + RAILS_ENV: test + REDMINE_VERSION: ${{ matrix.redmine }} + working-directory: redmine + run: bundle exec rake redmine:plugins:migrate NAME=additionals VERSION=0 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f826712a..00000000 --- a/.travis.yml +++ /dev/null @@ -1,43 +0,0 @@ -language: ruby -os: linux -dist: xenial - -rvm: - - 2.6.6 - - 2.5.8 - - 2.4.10 - -services: - - mysql - - postgresql - -env: - - REDMINE_VER=4.1-stable DB=postgresql - - REDMINE_VER=master DB=postgresql - - REDMINE_VER=4.1-stable DB=mysql - - REDMINE_VER=master DB=mysql - -before_install: - - export PLUGIN_NAME=additionals - - export REDMINE_GIT_REPO=git://github.com/redmine/redmine.git - - export REDMINE_PATH=$HOME/redmine - - export BUNDLE_GEMFILE=$REDMINE_PATH/Gemfile - - export RAILS_ENV=test - - git clone $REDMINE_GIT_REPO $REDMINE_PATH - - cd $REDMINE_PATH - - if [[ "$REDMINE_VER" != "master" ]]; then git checkout -b $REDMINE_VER origin/$REDMINE_VER; fi - - sed -i '/rubocop/d' $REDMINE_PATH/Gemfile - - rm -f $REDMINE_PATH/.rubocop* - - cp $TRAVIS_BUILD_DIR/test/support/Gemfile.local $REDMINE_PATH - - ln -s $TRAVIS_BUILD_DIR $REDMINE_PATH/plugins/$PLUGIN_NAME - - cp $TRAVIS_BUILD_DIR/test/support/additional_environment.rb $REDMINE_PATH/config/ - - cp $TRAVIS_BUILD_DIR/test/support/database-$DB-travis.yml $REDMINE_PATH/config/database.yml - -before_script: - - bundle exec rake db:create db:migrate redmine:plugins:migrate - -script: - - if [[ "$REDMINE_VER" != "master" ]] && [[ "$DB" == "postgresql" ]]; then brakeman plugins/$PLUGIN_NAME; fi - - if [[ "$REDMINE_VER" != "master" ]] && [[ "$DB" == "postgresql" ]]; then rubocop plugins/$PLUGIN_NAME; fi - - bundle exec rake redmine:plugins:test NAME=$PLUGIN_NAME RUBYOPT="-W0" - - bundle exec rake redmine:plugins:migrate NAME=$PLUGIN_NAME VERSION=0 diff --git a/docs/index.rst b/docs/index.rst index b20343c0..5d76df81 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -21,8 +21,8 @@ Additionals is a `Redmine`_ plugin for customizing Redmine, providing wiki macro :target: https://additionals.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status -.. image:: https://travis-ci.org/AlphaNodes/additionals.svg?branch=master - :target: https://travis-ci.org/AlphaNodes/additionals +.. image:: https://github.com/AlphaNodes/additionals/workflows/Tests/badge.svg + :target: https://github.com/AlphaNodes/additionals/actions?query=workflow%3A"Run+Tests .. image:: https://github.com/AlphaNodes/additionals/workflows/Run%20Linters/badge.svg :target: https://github.com/AlphaNodes/additionals/actions?query=workflow%3A%22Run+Linters%22 diff --git a/lib/additionals.rb b/lib/additionals.rb index 2bc4f713..7fcfef71 100644 --- a/lib/additionals.rb +++ b/lib/additionals.rb @@ -166,6 +166,7 @@ module Additionals require 'emoji' require 'render_async' require 'rss' + require 'slim' config.after_initialize do # engine_name could be used (additionals_plugin), but can diff --git a/test/support/Gemfile.local b/test/support/Gemfile.local deleted file mode 100644 index 717c7955..00000000 --- a/test/support/Gemfile.local +++ /dev/null @@ -1,11 +0,0 @@ -gem 'rubocop', require: false -gem 'rubocop-performance', require: false -gem 'rubocop-rails', require: false - -gem 'brakeman' -gem 'deface', '1.5.3' -gem 'gemoji', '~> 3.0.0' -gem 'render_async' -gem 'rss' -gem 'slim_lint' -gem 'slim-rails' diff --git a/test/support/additional_environment.rb b/test/support/additional_environment.rb deleted file mode 100644 index 5ab3befa..00000000 --- a/test/support/additional_environment.rb +++ /dev/null @@ -1,4 +0,0 @@ -# for travis debugging -# config.logger = Logger.new $stdout -# config.logger.level = Logger::INFO -# config.log_level = :info diff --git a/test/support/configuration.yml b/test/support/configuration.yml new file mode 100644 index 00000000..54391833 --- /dev/null +++ b/test/support/configuration.yml @@ -0,0 +1 @@ +# = Redmine configuration file diff --git a/test/support/database-mysql-travis.yml b/test/support/database-mysql-travis.yml deleted file mode 100644 index 2acc0773..00000000 --- a/test/support/database-mysql-travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -test: - adapter: mysql2 - database: travis_ci_test - host: localhost - username: root - password: - pool: 5 - encoding: utf8mb4 diff --git a/test/support/database-mysql.yml b/test/support/database-mysql.yml new file mode 100644 index 00000000..160f66ca --- /dev/null +++ b/test/support/database-mysql.yml @@ -0,0 +1,26 @@ +production: + adapter: mysql2 + database: redmine + host: 127.0.0.1 + port: 3306 + username: root + password: + encoding: utf8mb4 + +development: + adapter: mysql2 + database: redmine + port: 3306 + host: 127.0.0.1 + username: root + password: + encoding: utf8mb4 + +test: + adapter: mysql2 + database: redmine + port: 3306 + host: 127.0.0.1 + username: root + password: + encoding: utf8mb4 diff --git a/test/support/database-postgres.yml b/test/support/database-postgres.yml new file mode 100644 index 00000000..97802def --- /dev/null +++ b/test/support/database-postgres.yml @@ -0,0 +1,23 @@ +production: + adapter: postgresql + host: localhost + database: redmine + username: postgres + password: postgres + encoding: utf8 + +development: + adapter: postgresql + host: localhost + database: redmine + username: postgres + password: postgres + encoding: utf8 + +test: + adapter: postgresql + host: localhost + database: redmine + username: postgres + password: postgres + encoding: utf8 diff --git a/test/support/database-postgresql-travis.yml b/test/support/database-postgresql-travis.yml deleted file mode 100644 index f42db204..00000000 --- a/test/support/database-postgresql-travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -test: - adapter: postgresql - database: travis_ci_test - username: postgres - pool: 5 - encoding: utf8