Improve tests on github, drop travis and fix slim loading

This commit is contained in:
Alexander Meindl 2020-11-29 16:58:44 +01:00
parent 799d0e180e
commit c2a6f0b8b0
11 changed files with 169 additions and 91 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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'

View File

@ -1,4 +0,0 @@
# for travis debugging
# config.logger = Logger.new $stdout
# config.logger.level = Logger::INFO
# config.log_level = :info

View File

@ -0,0 +1 @@
# = Redmine configuration file

View File

@ -1,8 +0,0 @@
test:
adapter: mysql2
database: travis_ci_test
host: localhost
username: root
password:
pool: 5
encoding: utf8mb4

View File

@ -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

View File

@ -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

View File

@ -1,6 +0,0 @@
test:
adapter: postgresql
database: travis_ci_test
username: postgres
pool: 5
encoding: utf8